-
Notifications
You must be signed in to change notification settings - Fork 161
Implement UpToDate condition in managed reconciler #945
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -972,7 +972,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (resu | |
| log.Debug("Reconciliation is paused either through the `spec.managementPolicies` or the pause annotation", "annotation", meta.AnnotationKeyReconciliationPaused) | ||
| record.Event(managed, event.Normal(reasonReconciliationPaused, "Reconciliation is paused either through the `spec.managementPolicies` or the pause annotation", | ||
| "annotation", meta.AnnotationKeyReconciliationPaused)) | ||
| status.MarkConditions(xpv2.ReconcilePaused()) | ||
| status.MarkConditions(xpv2.ReconcilePaused(), xpv2.PausedUnknown()) | ||
| // if the pause annotation is removed or the management policies changed, we will have a chance to reconcile | ||
| // again and resume and if status update fails, we will reconcile again to retry to update the status | ||
| return reconcile.Result{}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) | ||
|
|
@@ -1496,7 +1496,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (resu | |
| // https://github.com/crossplane/crossplane/issues/289 | ||
| reconcileAfter := r.pollIntervalHook(managed, r.effectivePollInterval(managed)) | ||
| log.Debug("External resource is up to date", "requeue-after", time.Now().Add(reconcileAfter)) | ||
| status.MarkConditions(xpv2.ReconcileSuccess()) | ||
| status.MarkConditions(xpv2.ReconcileSuccess(), xpv2.ObserveMatched()) | ||
| r.metricRecorder.recordFirstTimeReady(managed) | ||
|
|
||
| // record that we intentionally did not update the managed resource | ||
|
|
@@ -1516,7 +1516,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (resu | |
| if !policy.ShouldUpdate() { | ||
| reconcileAfter := r.pollIntervalHook(managed, r.effectivePollInterval(managed)) | ||
| log.Debug("Skipping update due to managementPolicies. Reconciliation succeeded", "requeue-after", time.Now().Add(reconcileAfter)) | ||
| status.MarkConditions(xpv2.ReconcileSuccess()) | ||
| status.MarkConditions(xpv2.ReconcileSuccess(), xpv2.UpdateRestricted().WithMessage(observation.Diff)) | ||
|
bobh66 marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what are we thinking for the size of these diffs and limits on k8s conditions fields? i think should we consider truncating this diff to be safe?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a good idea. |
||
|
|
||
| return reconcile.Result{RequeueAfter: reconcileAfter}, errors.Wrap(updateStatus(), errUpdateManagedStatus) | ||
| } | ||
|
|
@@ -1535,7 +1535,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (resu | |
| } | ||
|
|
||
| record.Event(managed, event.Warning(reasonCannotUpdate, err)) | ||
| status.MarkConditions(xpv2.ReconcileError(errors.Wrap(err, errReconcileUpdate))) | ||
| status.MarkConditions(xpv2.ReconcileError(errors.Wrap(err, errReconcileUpdate)), xpv2.UpdateFailed().WithMessage(observation.Diff)) | ||
|
|
||
| return reconcile.Result{Requeue: true}, errors.Wrap(updateStatus(), errUpdateManagedStatus) | ||
| } | ||
|
|
@@ -1566,7 +1566,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (resu | |
| reconcileAfter := r.pollIntervalHook(managed, r.effectivePollInterval(managed)) | ||
| log.Debug("Successfully requested update of external resource", "requeue-after", time.Now().Add(reconcileAfter)) | ||
| record.Event(managed, event.Normal(reasonUpdated, "Successfully requested update of external resource")) | ||
| status.MarkConditions(xpv2.ReconcileSuccess()) | ||
| status.MarkConditions(xpv2.ReconcileSuccess(), xpv2.UpdateRequested().WithMessage(observation.Diff)) | ||
|
|
||
| return reconcile.Result{RequeueAfter: reconcileAfter}, errors.Wrap(updateStatus(), errUpdateManagedStatus) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we prevent stale UpToDate conditions on the other error paths too?
Thanks for wiring this in. Right now the new condition is only updated in these branches, so any pre-observe error or a later failure after a fresh
Observe()can leave the previous UpToDate condition on the object. That can make users see an oldObserveMatched/Update*result even though the latest reconcile never reached that conclusion. Would it make sense to compute a fresh UpToDate condition once per reconcile and include it in every subsequent status update, or explicitly mark it Unknown when observe never completes?As per coding guidelines,
**/pkg/reconciler/**: "Conditions must be actionable for users (not developers), stable/deterministic, with proper Type/Reason/Message format."Also applies to: 1439-1440, 1459-1459, 1478-1478, 1509-1509
🤖 Prompt for AI Agents