-
Notifications
You must be signed in to change notification settings - Fork 335
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: rateLimitDeployment ignoring pod labels and annotation merge #4228
fix: rateLimitDeployment ignoring pod labels and annotation merge #4228
Conversation
Signed-off-by: Oscar Boher <[email protected]>
Signed-off-by: Oscar Boher <[email protected]>
…defined Signed-off-by: Oscar Boher <[email protected]>
Signed-off-by: Oscar Boher <[email protected]>
Signed-off-by: Oscar Boher <[email protected]>
…er/gateway into fix/ratelimit-deployment-labels
Signed-off-by: Oscar Boher <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4228 +/- ##
=======================================
Coverage 65.69% 65.69%
=======================================
Files 200 200
Lines 24095 24101 +6
=======================================
+ Hits 15829 15833 +4
- Misses 7134 7135 +1
- Partials 1132 1133 +1 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Oscar Boher <[email protected]>
…er/gateway into fix/ratelimit-deployment-labels
podLabels := rateLimitLabels() | ||
if r.rateLimitDeployment.Pod.Labels != nil { | ||
maps.Copy(podLabels, r.rateLimitDeployment.Pod.Labels) | ||
maps.Copy(podLabels, rateLimitLabels()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can L195 be removed ? since L192 is already setting it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So maps.Copy(dest, src)
overwrites keys existing in both maps with the src
value. I want to make sure noone can override one of the selector labels from the rateLimitLabels
, so I'm doing the last maps.Copy to overwrite with the selector labels in case someone added one of those labels in their values.
Also the destination map must not be nil so I cannot do something like:
podLabels := r.rateLimitDeployment.Pod.Labels
maps.Copy(podLabels, rateLimitLabels())
as it will fail if no pod labels are provided.
It looks a bit funny, I just didn't want to implement a function that merges two maps, but maybe it's worth it for clarity's sake. Let me know if you think so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah thats a good way to ensure the labels can't be overridden
nit: this as a code comment would be helpful so the next dev gets the "why"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks !
Signed-off-by: Oscar Boher <[email protected]>
…er/gateway into fix/ratelimit-deployment-labels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks !
What type of PR is this?
fix
What this PR does / why we need it:
rateLimitDeployment.pod.labels
where not applying to rate limit pods.prometheus annotations where ignored if
rateLimitDeployment.pod.annotations
was definedWhich issue(s) this PR fixes:
Fixes #4226