frontend: implement cache control#1974
Merged
pracucci merged 12 commits intocortexproject:masterfrom Jan 17, 2020
Merged
Conversation
pracucci
reviewed
Jan 13, 2020
Contributor
pracucci
left a comment
There was a problem hiding this comment.
Good job! Changes make sense to me. I just left a minor comment.
Contributor
|
Could you also add changelog entry? |
gouthamve
reviewed
Jan 16, 2020
CHANGELOG.md
Outdated
Contributor
There was a problem hiding this comment.
Full stop and add the PR number too please :)
Contributor
Author
There was a problem hiding this comment.
That was fast 😄 will do.
Add an extra `Headers` field to the `PrometheusResponse` message which contains the headers and their values that came from Prometheus. Use them in other places to deduce if the response should be cached. If `Cache-Control` is equal to `no-store` then it is *not* cached. This will be used by the Thanos project to indicate when a partial response has been returned. In such cases the result should not be cached so that invalid data would not be stored there. Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
`Cache-Control` might contain more than one value so check all of them. Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
b8011eb to
24ee2c1
Compare
gouthamve
approved these changes
Jan 16, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
👋 from the Thanos project. Thanks, first of all, for your work on making the frontend component work with regular Prometheus end-points! We would like to extend it a bit so that it would fit better for use with Thanos. One of the things is that we would like to avoid caching the results when Thanos gets what is called a "partial response" - when one of the nodes does not respond but some end-result with partial data is still returned to the user. Obviously, such data is incomplete and might very well change after a minute or two so it must not be cached.
Thus, let's capture the headers from the response as well. They will be used to determine if the result should be cached. For that reason two new variables are introduced:
cachecontrolHeaderwhich is equal toCache-Control- this is the header that will be checkednoCacheValuewhich is equal tono-store- that is the value that we are looking for to determine if the result should be cachedMore documents/ideas are available here: thanos-io/thanos#1651
Example user: thanos-io/thanos#1984. I actually tested that this works as expected with that PR applied on top of
master.Added a simple test for the function which determines if the result should be cached based on the response's headers.
All ideas/feedback/suggestions welcome as I have never contributed to Cortex thus I am unfamiliar with the codebase. Also, I wonder if you would be even open to accepting something like this. Obviously this is missing such things like documentation & E2E tests, and so on so let's discuss this before moving further. Thanks a lot!