Skip to content
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

Auto set observed generation #1081

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions codegen/cmd/injection-gen/generators/reconciler_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error {
}
}

// Since the Reconciler observed this object, update the Status.ObservedGeneration
// to match the objects ObservedGeneration.
resource.Status.ObservedGeneration = original.Generation
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that this alone is enough. If ReconcileKind returned an error before updating Status then we might inadvertently convey readiness before we mean to by auto-bumping ObsGen before the conditions are (successfully) updated. I would be supportive of doing this whenever the return code is not an error 🤷‍♂

Copy link
Member

Choose a reason for hiding this comment

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

@n3wscott has a good point too, we [will] use this for a couple resources in Serving that don't touch status, and shouldn't update this. I'd be ok with having a way of turning all the status stuff off.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

we might inadvertently convey readiness before we mean to by auto-bumping ObsGen before the conditions are (successfully) updated.

I am not sure I follow this. Both this and the status of conditions are updated in updateStatus. No? This does however mean that reconcilers have to follow the contract of always setting Conditions before returning.

I'd be ok with having a way of turning all the status stuff off.

Yes i agree with this.


// Synchronize the status.
if equality.Semantic.DeepEqual(original.Status, resource.Status) {
// If we didn't change anything then don't call updateStatus.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, o *{{.type|raw}}) {{.rec

// TODO: add custom reconciliation logic here.

o.Status.ObservedGeneration = o.Generation
return newReconciledNormal(o.Namespace, o.Name)
}

Expand Down