Skip to content

feat: add observedGeneration in status#80

Open
sandert-k8s wants to merge 1 commit intokyverno:mainfrom
sandert-k8s:add-generation
Open

feat: add observedGeneration in status#80
sandert-k8s wants to merge 1 commit intokyverno:mainfrom
sandert-k8s:add-generation

Conversation

@sandert-k8s
Copy link
Copy Markdown

@sandert-k8s sandert-k8s commented Apr 17, 2026

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

  • [ x] I have read the contributing guidelines.
  • [ x] 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.

Copilot AI review requested due to automatic review settings April 17, 2026 07:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.SetReadyByCondition to accept a generation value and set metav1.Condition.ObservedGeneration.
  • Update existing unit tests to use the new method signature.
  • Add unit tests verifying ObservedGeneration is 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.

Comment thread api/policies.kyverno.io/v1alpha1/conditions.go Outdated
Comment thread api/policies.kyverno.io/v1alpha1/conditions.go Outdated
Signed-off-by: sandert-k8s <sandert98@gmail.com>
Co-authored-by: GitHub Copilot (model Claude Sonnet 4.6) <noreply@github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants