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

[response-ratelimiting] Missing upstream usage headers in Kong 3.8 #13682

Open
1 task done
t-yuki opened this issue Sep 17, 2024 · 2 comments · May be fixed by #13696
Open
1 task done

[response-ratelimiting] Missing upstream usage headers in Kong 3.8 #13682

t-yuki opened this issue Sep 17, 2024 · 2 comments · May be fixed by #13696
Labels

Comments

@t-yuki
Copy link

t-yuki commented Sep 17, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Kong version ($ kong version)

Kong 3.8.0.0

Current Behavior

No usage headers such as X-RateLimit-Remaining-Videos: 10 for upstream requests.

Expected Behavior

When I do request the api, X-RateLimit-Remaining-Videos: 10 header should be present in upstream request.

Steps To Reproduce

  1. In a docker environment,
  2. When I config a service with response-ratelimiting plugin configued with the below for an echo-api upstream server such as https://postman-echo.com/get,
  3. Request the service.
  4. Response doen't contain X-RateLimit-Remaining-Videos header.
plugins:
- name: response-ratelimiting
 config:
   limits:
     videos:
       minute: 10
   policy: local

Anything else?

According to the plugin document page https://docs.konghq.com/hub/kong-inc/response-ratelimiting/#upstream-headers , the plugin should append the usage headers for each limit before proxying it to the upstream service, but it is missing on Kong 3.8

I guess the change in 3c0aa60#diff-e799a72960fa7f956455fff4cca7947749b5c6ecd7cb1e18f220931911eb0bcfR106 caused this behaivior.

Before Kong 3.8, it was set by kong.service.request.set_header function so upstream requests contain remaining usage headers.
But in this change, it was replaced by pdk_rl_store_response_header and pdk_rl_apply_response_headers functions those finally manipulates ngx.header https://github.com/Kong/kong/blob/3.8.0/kong/pdk/private/rate_limiting.lua#L7 , that is client response headers, not request headers for upstream.

@ADD-SP
Copy link
Contributor

ADD-SP commented Sep 20, 2024

Thanks, @t-yuki, I agree with your analysis, and we welcome this fix from the community. Are you willing to open a pull request to fix it?

Internal ticket: KAG-5447

@ADD-SP ADD-SP added the bug label Sep 20, 2024
@t-yuki
Copy link
Author

t-yuki commented Sep 20, 2024

@ADD-SP thanks. I've opened PR #13696

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants