-
Notifications
You must be signed in to change notification settings - Fork 85
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
KDP Reconciler does not set observedGeneration on the managed resource #391
Comments
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
I agree this would be useful, and shouldn't be terribly hard to implement. I guess the "hard" part is to determine whether the declarative resource definition has |
/remove-lifecycle stale |
Thinking a bit more about this, it is already possible to do this with the current features of KDP, by utilizing the // in your setup code, where you pass all the other options to set up the declarative reconciler
// We use a StatusBuilder to avoid having to implement all of declarative.Status; we only need BuildStatus
// https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/blob/master/pkg/patterns/declarative/status.go#L80
declarative.WithStatus(&declarative.StatusBuilder{
BuildStatusImpl: &myCustomStatus{},
})
type myCustomStatus struct {}
func (*myCustomStatus) BuildStatus(ctx context.Context, statusInfo *StatusInfo) error {
// here, statusInfo has a property Subject which is the declarative object
// cast that to your custom resource type, so you can mutate the status at will
subj, ok := statusInfo.Subject.(*MyCustomResource)
if !ok {
return errors.New("expected a %T, but got a %T", &MyCustomResource{}, statusInfo.Subject)
}
// mutations to status here will be saved to the API server by the KDP reconciler
subj.Status.ObservedGeneration = subj.ObjectMeta.Generation
return nil
} This is admittedly quite a bit of ceremony in order to do something very common, but if you also want to do other things (e.g. calculate a set of conditions) you probably already do most of it, and the line that actually sets observed generation is the only new code needed. It might be interesting to try to simplify this, by e.g. providing a helper feature that removes the need for all the boilerplate, but we'd have to design that a bit carefully to ensure it plays well with the existing status features. @justinsb Do you have any thoughts on this? In particular, could we make it easier to build helpers for things like this by finally actually removing the old-and-deprecated methods on |
What would you like to be added: I would like for the KDP reconciler to have built-in support for setting the observedGeneration on the status of the managed resource.
Why is this needed: This makes it easier to determine when a KDP controller has reconciled the current spec of the managed resource.
The text was updated successfully, but these errors were encountered: