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

feat(proxy): Allow to remove the proxy cache headers #10445

Merged
merged 7 commits into from
Aug 8, 2023

Conversation

utix
Copy link
Contributor

@utix utix commented Mar 7, 2023

Update of #7829

Summary

Adding Miss/Hit, Age and cache key to answer shouldn't be the default behavior.
Add option to remove the proxy cache headers from the response.
If the kong debug is set keep the headers

Full changelog

The following headers:

  • X-Cache-Status
  • X-Cache-Key
  • Age

can be now be removed from the answer via the response_headers option,
for example to remove all:

        config = {
          [...]
          response_headers = {
            age = false,
            ["X-Cache-Status"] = false,
            ["X-Cache-Key"]  = false
          }

Default behavior to have all the header set is kept for retro compatibility reason.

Refactor test to remove duplicated lines and use get, post and delete helpers instead of send

@utix utix mentioned this pull request Mar 7, 2023
@hanshuebner hanshuebner force-pushed the feat/proxy_cache_debug branch from 631d6a3 to f7fd4ad Compare March 7, 2023 15:48
@chronolaw chronolaw changed the title Feat/proxy cache debug feat(proxy): proxy cache debug Mar 8, 2023
@hanshuebner hanshuebner requested a review from hbagdi March 9, 2023 09:17
@hanshuebner
Copy link
Contributor

@hbagdi Please give this your final review.

@hanshuebner hanshuebner force-pushed the feat/proxy_cache_debug branch from f7fd4ad to 17eece8 Compare March 9, 2023 09:18
@hbagdi
Copy link
Member

hbagdi commented Mar 9, 2023

Is this potentially a breaking change in terms of the behavior of the proxy?

@utix
Copy link
Contributor Author

utix commented Mar 9, 2023

@hbagdi I have described the impact.

Remove proxy cache headers from response if the kong debug is not set.

Nothing has changed on the caching part, just the headers added in the response.
imho such header shouldn't be added by default.

If you think it is a breaking change I can add a configuration param in addition of debug mode to control if headers are added

@hanshuebner
Copy link
Contributor

Remove proxy cache headers from response if the kong debug is not set.

Nothing has changed on the caching part, just the headers added in the response. imho such header shouldn't be added by default.

The reason why we've not just merged this change is that even though your opinion matches ours, we don't know how many customers rely on the incorrect behavior of Kong. We're still in the decision process.

If you think it is a breaking change I can add a configuration param in addition of debug mode to control if headers are added

Adding a specific configuration parameter to disable incorrect behavior of previous versions of Kong should be the last resort, but we may want to go that route and make the correct change, like you proposed, in the next major release. Please bear with us for a couple of more days.

@hbagdi
Copy link
Member

hbagdi commented Mar 27, 2023

@hanshuebner How is this not a breaking change?

@hanshuebner
Copy link
Contributor

@hbagdi All the arguments have been made. From your question, I take it that you don't agree that we can merge this. Please let us know how to proceed.

@kikito
Copy link
Member

kikito commented Mar 28, 2023

@hbagdi The gist of the problem here is the interpretation of what the headers X-Cache-Status, X-Cache-Key, Age are.

  • If we interpret that they are "headers that are only useful when debugging a problem" then generating them all the time was a bug. Anyone relying on this for doing this was thus relying on buggy behavior. So with this interpretation, merging this is not a breaking change (because breaking buggy behaviour is not a breaking change).
  • If we interpret that "the way things were working before is acceptable" - that sending those headers all the time is correct, then this is a change in functionality and a breaking change. The soonest we would be able to merge this would be with a proper deprecation on Kong 4.0. We could start emitting deprecation messages in the logs in the meantime.

@utix
Copy link
Contributor Author

utix commented Mar 28, 2023

Not sure that not being able to not sent the header was acceptable.
If you think this is a breaking change, I can add a flag to add them or not, set to true by default.
And when the flag is set to false, the debug mode will add them at demand.

@hbagdi
Copy link
Member

hbagdi commented Mar 28, 2023

The API was not clear and the RFCs do not make it obvious that these headers are for debugging.
Doing a breaking change without giving our users a way out (being able to get back the old behavior) for such an API should be avoided.

I recommend adding a flag as @utix suggests to avoid this breaking change, especially since the plugin has been around for a long time.

@hanshuebner hanshuebner added the pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... label Mar 29, 2023
@hbagdi
Copy link
Member

hbagdi commented Mar 29, 2023

Another alternate solution is to go for an "allowlist" based approach which gives user the control over which headers should be emitted by Kong when this plugin is run. That essentially gives user a toggle over each header and allows the user to emit the cache status header (generally considered useful) and hide the cache key header (generally hidden) and other combinations.

@utix
Copy link
Contributor Author

utix commented Mar 29, 2023

I was planning to add a flag for each header, to put it on the answer. set to true by default to keep the behavior
And force all on debug mode

@hbagdi
Copy link
Member

hbagdi commented Mar 29, 2023

Is a single configuration field that is an array of string better? Or worse?

@hbagdi hbagdi added the author/community PRs from the open-source community (not Kong Inc) label Apr 5, 2023
@stale
Copy link

stale bot commented Apr 20, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Apr 20, 2023
@utix
Copy link
Contributor Author

utix commented Apr 21, 2023

I have added a response_headers field into the configuration with 3 fields:

  • age
  • X-Cache-Status
  • X-Cache-Key

Allowing to set or unset the presence of the header into the response.

As discussed, to keep previous behavior, all fields are present by default.

Copy link
Contributor

@hanshuebner hanshuebner left a comment

Choose a reason for hiding this comment

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

Almost there! Now there is only the missing CHANGELOG entry and the docs update to be done. Also, the pull request title and description need some work to reflect what the change is about. @utix can you do that?

@hbagdi
Copy link
Member

hbagdi commented Jun 7, 2023

This needs a compat change as well i.e. addition to removed_fields.lua.

@hbagdi
Copy link
Member

hbagdi commented Jun 26, 2023

Closing because of lack of activity. We would like to accept this contribution if anyone wishes to pick this back up.

@hbagdi hbagdi closed this Jun 26, 2023
@hbagdi hbagdi removed this from the 3.4.0 milestone Jun 26, 2023
@utix
Copy link
Contributor Author

utix commented Jun 26, 2023 via email

@hbagdi
Copy link
Member

hbagdi commented Jun 26, 2023

That and #10445 (comment). Please re-open if you want to take this to the finish line.

@utix utix changed the title feat(proxy): proxy cache debug feat(proxy): Allow to remove the proxy cache headers Jun 27, 2023
@utix
Copy link
Contributor Author

utix commented Jun 27, 2023

I have reword the PR, changelog commit is done on my fork, I don't have permission to reopen the PR.
Not sure what is a compat change, here as asked the previous configuration will still trigger the same behavior.

@hanshuebner
Copy link
Contributor

hanshuebner commented Jul 4, 2023

@utix The removed_fields.lua update is required to make older dataplanes compatible with newer control planes. When preparing a configuration to be sent to a data plane, the control plane removes configuration fields that are present in the current configuration but that were not supported in the version of the target data plane. The removed_fields.lua file lists, for each version, what fields were added. Please include the new configuration fields in the section for 3.3->3.4.

utix and others added 7 commits July 11, 2023 18:02
The following headers:
* X-Cache-Status
* X-Cache-Key
* Age

are now set only if the header kong-debug is set to 1
And they are removed from the cache value
… the

response

Keep previous behavior with default configuration.
Debug header allows to get all info, each header has a configuration field
to be or not into the response
@utix utix force-pushed the feat/proxy_cache_debug branch from d41eb8e to 2e15a2b Compare July 11, 2023 16:07
@utix
Copy link
Contributor Author

utix commented Aug 6, 2023

@hanshuebner is it good now ? If something else is needed can you highlight it ?

@hanshuebner hanshuebner merged commit 5e09745 into Kong:master Aug 8, 2023
@hanshuebner
Copy link
Contributor

@utix Finally merged, thank you for the contribution and your efforts getting it over the line!

@utix
Copy link
Contributor Author

utix commented Aug 8, 2023

Thanks for your support to make it happen

@outsinre
Copy link
Contributor

Will double-check when CE2EE merge.

lhanjian added a commit that referenced this pull request Dec 23, 2024
…ock dictionary in RLA (#10445)

Added a new configuration field `lock_dictionary_name` to support specifying an independent shared memory for storing locks.

https://konghq.atlassian.net/browse/FTI-6266
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants