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

fix: use upstream path in modify response #269

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

seanbanko
Copy link

Some open-source projects expose a Prometheus-compatible API at at a subpath, e.g. /prometheus. We should use the upstream.Path configured when matching the resp.Request.URL.Path in ModifyResponse so that we can handle the case of a non-root upstream path when proxying /api/v1/rules and /api/v1/alerts.

@seanbanko seanbanko force-pushed the use-upstream-path-in-modify-response branch from c12ba39 to 3b35b04 Compare February 6, 2025 21:28
@squat
Copy link
Member

squat commented Feb 6, 2025

Hi @seanbanko can you add a concrete test case? Otherwise I'm sure this will regress

Signed-off-by: Sean Banko <[email protected]>
@seanbanko seanbanko force-pushed the use-upstream-path-in-modify-response branch from c8ad898 to 734ea73 Compare February 6, 2025 22:58
@seanbanko
Copy link
Author

seanbanko commented Feb 6, 2025

Hi @seanbanko can you add a concrete test case? Otherwise I'm sure this will regress

Great call. I've added a simple test case to TestRules that fails if the upstream path concatenation is removed from r.modifiers.

I copied rules_match_namespace_ns1.golden to rules_match_namespace_ns1_non_root_upstream.golden to make the purpose of the test clear, but we could also just use rules_match_namespace_ns1.golden in the test instead to make it clear that the expected result is the same.

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.

2 participants