Skip to content

feat: add observedGeneration to CommonStatus #414

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

Conversation

sdowell
Copy link
Contributor

@sdowell sdowell commented Feb 11, 2025

This updates the built in CommonStatus struct to provide observedGeneration behavior when using one of the provided status builders. Custom implementations of the BuildStatus interface could already set observedGeneration if desired, but this provides an opinionated default to the addon implementations.

What this PR does / why we need it: Sets status.observedGeneration for the built-in CommonStatus type. This makes it easier to determine when a KDP controller which uses the Addon object has reconciled the current spec of the managed resource.

Which issue(s) this PR fixes:
Fixes #391

This updates the built in CommonStatus struct to provide
observedGeneration behavior when using one of the provided status
builders. Custom implementations of the BuildStatus interface could
already set observedGeneration if desired, but this provides an
opinionated default to the addon implementations.
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 11, 2025
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 11, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @sdowell. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 11, 2025
@tomasaschan
Copy link
Member

/ok-to-test

Thanks! I need to wrap my head around what happens for users who already define ObservedGenerarion and also use CommonStatus, when they upgrade to a version that has this patch - will they get a build error? Runtime error? Or will it just work? - but other than that it looks great!

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 12, 2025
@sdowell
Copy link
Contributor Author

sdowell commented Feb 12, 2025

/ok-to-test

Thanks! I need to wrap my head around what happens for users who already define ObservedGenerarion and also use CommonStatus, when they upgrade to a version that has this patch - will they get a build error? Runtime error? Or will it just work? - but other than that it looks great!

My understanding is that the intended pattern of using the Addon object structs (CommonStatus/CommonSpec) is to embed the addon struct(s) into your CRD struct.

If a user upgrades to the new k-d-p version and already defined an observedGeneration field on their CRD, there would now be duplicate entries of observedGeneration on the struct. For example:

type Status struct {
	addonv1alpha1.CommonStatus     `json:",inline"`
	// +kubebuilder:default:=0
	ObservedGeneration int64 `json:"observedGeneration"`
}

My understanding is that it shouldn't encounter any build errors and the already defined field should take precedence for marshalling/unmarshalling. In this case I think the recommendation would be to replace the already defined field with the CommonStatus builtin to avoid confusion.

And if they didn't already have an observedGeneration field on their struct, it would be added upon upgrading.

@tomasaschan
Copy link
Member

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 26, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sdowell, tomasaschan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 26, 2025
@k8s-ci-robot k8s-ci-robot merged commit a579283 into kubernetes-sigs:master Feb 26, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KDP Reconciler does not set observedGeneration on the managed resource
3 participants