-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: Relax immutability requirements on match statements for generate rules #12784
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: Relax immutability requirements on match statements for generate rules #12784
Conversation
…rules Signed-off-by: Tomas Aschan <tomasl@spotify.com>
Signed-off-by: Tomas Aschan <tomasl@spotify.com>
e73dff0
to
db3f376
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12784 +/- ##
==========================================
+ Coverage 14.34% 14.36% +0.01%
==========================================
Files 926 926
Lines 102681 102698 +17
==========================================
+ Hits 14734 14752 +18
+ Misses 86225 86224 -1
Partials 1722 1722 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 @tomasaschan !
/cherry-pick release-1.14 |
…e rules (#12784) * feat: Allow changing match statements for non-synchronizing generate rules Signed-off-by: Tomas Aschan <tomasl@spotify.com> * fix: Address a couple of incorrect format string errors Signed-off-by: Tomas Aschan <tomasl@spotify.com> --------- Signed-off-by: Tomas Aschan <tomasl@spotify.com> Co-authored-by: shuting <shuting@nirmata.com>
…e rules (#12784) (#12800) * feat: Allow changing match statements for non-synchronizing generate rules * fix: Address a couple of incorrect format string errors --------- Signed-off-by: Tomas Aschan <tomasl@spotify.com> Co-authored-by: Tomas Aschan <1550920+tomasaschan@users.noreply.github.com> Co-authored-by: shuting <shuting@nirmata.com>
…e rules (kyverno#12784) * feat: Allow changing match statements for non-synchronizing generate rules Signed-off-by: Tomas Aschan <tomasl@spotify.com> * fix: Address a couple of incorrect format string errors Signed-off-by: Tomas Aschan <tomasl@spotify.com> --------- Signed-off-by: Tomas Aschan <tomasl@spotify.com> Co-authored-by: shuting <shuting@nirmata.com>
…e rules (kyverno#12784) * feat: Allow changing match statements for non-synchronizing generate rules Signed-off-by: Tomas Aschan <tomasl@spotify.com> * fix: Address a couple of incorrect format string errors Signed-off-by: Tomas Aschan <tomasl@spotify.com> --------- Signed-off-by: Tomas Aschan <tomasl@spotify.com> Co-authored-by: shuting <shuting@nirmata.com> Signed-off-by: Martijn Evers <mevers@gk-software.com>
Explanation
This updates the immutability validation for generate rules to allow updating the
match
statements if and only if the policy before the change is not usingsynchronize: true
.Updating
match
was previously disallowed to avoid confusing or incorrect sync behavior when the set of trigger resources would change, but that is not a concern for non-synchronizing rules. This change relaxes the requirements slightly, by allowing updates tomatch
statements if no rule in the policy usessynchronize: true
.It would, theoretically, be possible to relax this requirement even further, by matching rules before/after up by name, and applying this logic per rule rather than per policy, but doing so would require a larger refactor of the entire immutability checking code, as the current implementation works by resetting the values of all mutable fiels to a known value, hashing the resulting rule object, and then comparing the policy before and after the update by comparing the set of hashes; in other words, no such by-name match-up is done today. In the interest of leaving this change as small as possible, that is left out of scope.
Related issue
Fixes #12766
Milestone of this PR
Documentation (required for features)
My PR contains new or altered behavior to Kyverno.
What type of PR is this
Proposed Changes
Proof Manifests
Checklist
Further Comments