8000 feat: Relax immutability requirements on match statements for generate rules by tomasaschan · Pull Request #12784 · kyverno/kyverno · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 9 commits into from
Apr 16, 2025

Conversation

tomasaschan
Copy link
Contributor

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 using synchronize: 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 to match statements if no rule in the policy uses synchronize: 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

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.
  • This is a feature and I have added CLI tests that are applicable.
  • My PR needs to be cherry picked to a specific release branch which is .
  • My PR contains new or altered behavior to Kyverno and
    • CLI support should be added and my PR doesn't contain that functionality.

Further Comments

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 15, 2025
…rules

Signed-off-by: Tomas Aschan <tomasl@spotify.com>
Signed-off-by: Tomas Aschan <tomasl@spotify.com>
Copy link
codecov bot commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.

Project coverage is 14.36%. Comparing base (0e81c2a) to head (cc16e8d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/validation/policy/generate.go 90.90% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member
@realshuting realshuting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Thanks @tomasaschan !

@realshuting
Copy link
Member

/cherry-pick release-1.14

@realshuting realshuting merged commit eae3a19 into kyverno:main Apr 16, 2025
504 of 528 checks passed
gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Apr 16, 2025
…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>
@tomasaschan tomasaschan deleted the relax-generate-immutability branch April 16, 2025 15:06
@realshuting realshuting added the cherry-pick-completed The PR was cherry-picked (or merged) to required release branches label Apr 16, 2025
eddycharly pushed a commit that referenced this pull request Apr 16, 2025
…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>
Denish3436 pushed a commit to Denish3436/kyverno that referenced this pull request Apr 24, 2025
…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>
marevers pushed a commit to marevers/kyverno that referenced this pull request May 5, 2025
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-completed The PR was cherry-picked (or merged) to required release branches cherry-pick-required milestone 1.14.0 size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Allow changing match statements on generate policies _iff_ synchronize is off
3 participants
0