Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CacheFilter: parses the allowed_vary_headers from the cache config. #12928

Merged
merged 6 commits into from
Sep 11, 2020

Conversation

cbdm
Copy link
Contributor

@cbdm cbdm commented Sep 1, 2020

Commit Message: CacheFilter: parses the allowed_vary_headers from the cache config.

Signed-off-by: Caio caiomelo@google.com

Additional Description:
Parses the allowlist from the cache config proto; this allows users to define a set of rules to control which headers can be varied in the cache.

Risk Level: Low
Testing: Unit testing
Docs Changes: Updated cache proto's comments regarding allowed_vary_headers
Release Notes: N/A
Fixes #10131

cbdm added 2 commits September 1, 2020 20:44
Signed-off-by: Caio <caiomelo@google.com>
Signed-off-by: Caio <caiomelo@google.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy[\w/]*/(v1alpha\d?|v1|v2alpha\d?|v2))|(api/envoy/type/(matcher/)?\w+.proto).
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #12928 was opened by cbdm.

see: more, trace.

Signed-off-by: Caio <caiomelo@google.com>
@jmarantz
Copy link
Contributor

jmarantz commented Sep 2, 2020

Can you make a C++ class for the allow-list rather than passing around a vector of matchers?

Also is this a good time to introduce a config object so we don't have to reconstruct the allow structure on every request?

@cbdm
Copy link
Contributor Author

cbdm commented Sep 2, 2020

Could you point me to a configuration example in an existing filter? I'm not sure how to proceed with that one.

@htuch
Copy link
Member

htuch commented Sep 3, 2020

/lgtm api
/lgtm v2-freeze

Signed-off-by: Caio <caiomelo@google.com>
@cbdm
Copy link
Contributor Author

cbdm commented Sep 3, 2020

@jmarantz thanks for the link! I'll look into how we can change the config of the plugin to be closer to gzip.

Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the delay -- I thought you might have been planning to do the conversion to the explicit config as part of this PR.

Mostly looks good; just some nits. Can you leave a TODO at least if you are not going to do this conversion to an explicit config in this PR?

/wait

// Checks if the headers contain an allowed value in the Vary header.
static bool isAllowed(const std::vector<Matchers::StringMatcherPtr>& allowlist,
const Http::ResponseHeaderMap& headers);

// Checks if the headers contain a non-empty value in the Vary header.
static bool hasVary(const Http::ResponseHeaderMap& headers);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these static methods still be public? Or will they now be used only internal to the class as helpers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasVary and createVaryKey are used by simple_http_cache, so those should stay public. I'll make the other two methods private.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the logic of parseAllowlist to the constructor and made parseHeaderValues more generic and moved it into CacheHeaderUtils.
Let me know if that's okay.

@cbdm
Copy link
Contributor Author

cbdm commented Sep 9, 2020

Sorry for the delay on my end too; I'm starting to look at the config just now because of the long weekend.
We do have a TODO added from the previous PR, I could expand it to say the gzip is a good example to mirror.

@cbdm
Copy link
Contributor Author

cbdm commented Sep 11, 2020

Hi, from the discussion in #12901, I feel like the explicit config should be a separate PR. What do you think?

jmarantz
jmarantz previously approved these changes Sep 11, 2020
Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

master merge needed

@cbdm
Copy link
Contributor Author

cbdm commented Sep 11, 2020

I was already working on it :-)

@cbdm
Copy link
Contributor Author

cbdm commented Sep 11, 2020

@jmarantz gentle ping after merge and all tests passed.

@jmarantz jmarantz merged commit 6a994d5 into envoyproxy:master Sep 11, 2020
lhluo pushed a commit to lhluo/envoy that referenced this pull request Sep 11, 2020
…code

* upstream/master:
  lint: add more linters for using absl:: over std:: (envoyproxy#13043)
  udpa: filesystem list collection support for inline entries. (envoyproxy#13028)
  filter: http: jwt: implement matching for HTTP CONNECT (envoyproxy#13064)
  [fuzz] split http filter logic into a fuzzing class (envoyproxy#13016)
  xds: allow empty delta update (envoyproxy#12699)
  CacheFilter: parses the allowed_vary_headers from the cache config. (envoyproxy#12928)
  router: extend HTTP CONNECT route matching criteria (envoyproxy#13056)
  docs: clarify use of Extended CONNECT for h/2 (envoyproxy#13051)
  build: shellcheck tools/ (envoyproxy#13007)
  [fuzz] Refactored Health Checker Impl Tests (envoyproxy#13017)

Signed-off-by: Lihao Luo <lihao@squareup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CacheFilter: Parse and handle 'vary' response headers
3 participants