-
Notifications
You must be signed in to change notification settings - Fork 19
Handle non-string labels and annotations #411
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
Handle non-string labels and annotations #411
Conversation
|
An updated "mismatch" test was a good demonstration of the old behavior. Here's what the test would require with the old behavior, when the policy has invalid labels and annotations: And it's clear that if the policy was enforced, it would delete the labels and annotations. |
Previously, if labels or annotations inside an objectTemplate used values that were not strings, the ConfigurationPolicy might try to remove all labels or annotations on that object. That behavior was potentially destructive, and it was easy for a policy author to accidentally trigger by getting some quotes wrong in their template, or by using `yes` as a value (which is interpreted by some parsers as a boolean `true`). Now, the ConfigurationPolicy will emit a special error if the input object template has invalid labels or annotations. Refs: - https://issues.redhat.com/browse/ACM-26186 Signed-off-by: Justin Kulikauskas <[email protected]>
217a12b to
c806d02
Compare
dhaiducek
left a comment
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.
This looks great to me! Thanks for working it out!
|
|
||
| # Compliance messages: | ||
| NonCompliant; violation - pods [nginx-pod-e2e-10] found but not as specified in namespace managed | ||
| NonCompliant; violation - invalid annotation, error: contains non-string value in the map under key "case": 10 is of the type int64, expected string |
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.
This error is so clearly written it makes me want to cry 🥹
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.
It is pretty nice :D
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dhaiducek, JustinKuli The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
c20f555
into
open-cluster-management-io:main
Previously, if labels or annotations inside an objectTemplate used values that were not strings, the ConfigurationPolicy might try to remove all labels or annotations on that object. That behavior was potentially destructive, and it was easy for a policy author to accidentally trigger by getting some quotes wrong in their template, or by using
yesas a value (which is interpreted by some parsers as a booleantrue).Now, the ConfigurationPolicy will emit a special error if the input object template has invalid labels or annotations.
Refs: