feat: add observedGeneration in status#80
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
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.
Suhani95
left a comment
There was a problem hiding this comment.
Hi @sandert-k8s Good change overall.
However, there are no production call sites using obj.GetGeneration() yet, so most updates will still set observedGeneration = 0. In Kubernetes patterns, this field is only meaningful when it reflects the actual reconciled generation. It might be worth wiring this into controller/status paths.
Signed-off-by: sandert-k8s <sandert98@gmail.com>
Signed-off-by: sandert-k8s <sandert98@gmail.com>
Hi! Definitely :) Thats done in this PR: kyverno/kyverno#15889 . But thats still draft, because it needs this kyverno-api version to work. |
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