feat: add observedGeneration in status#80
Open
sandert-k8s wants to merge 1 commit intokyverno:mainfrom
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the policy ConditionStatus helper so it can populate observedGeneration on metav1.Condition, allowing controllers to record which resource generation a condition was computed from.
Changes:
- Extend
ConditionStatus.SetReadyByConditionto accept a generation value and setmetav1.Condition.ObservedGeneration. - Update existing unit tests to use the new method signature.
- Add unit tests verifying
ObservedGenerationis set and updated on repeated calls.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| api/policies.kyverno.io/v1alpha1/conditions.go | Adds a generation parameter to SetReadyByCondition and writes it into the condition’s ObservedGeneration field. |
| api/policies.kyverno.io/v1alpha1/conditions_test.go | Updates existing tests for the new signature and adds coverage for ObservedGeneration behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
65c1868 to
c8d8a88
Compare
This was referenced Apr 17, 2026
Signed-off-by: sandert-k8s <sandert98@gmail.com> Co-authored-by: GitHub Copilot (model Claude Sonnet 4.6) <noreply@github.com>
b8df551 to
a96a73d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
This change adds the observedGeneration to the status object. This is already part of the CRD (so no CRD change required), but it was just not picked up by the controller. This has been added. Also keeps backward compatibility.
Related PR
kyverno/kyverno#15889
Related issue
2 Related issues:
kyverno/kyverno#12256
argoproj/argo-cd#27354 (review)
Proposed Changes
This change adds the observedGeneration to the status field to track if the processed generation is the same as in the annotation.
Checklist