-
Notifications
You must be signed in to change notification settings - Fork 73
🐛 fix: (boxcutter) Enable archival and spec changes for ProgressDeadlineExceeded revisions #2610
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 |
|---|---|---|
|
|
@@ -31,7 +31,6 @@ import ( | |
| "sigs.k8s.io/controller-runtime/pkg/builder" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
| "sigs.k8s.io/controller-runtime/pkg/event" | ||
| "sigs.k8s.io/controller-runtime/pkg/handler" | ||
| "sigs.k8s.io/controller-runtime/pkg/log" | ||
| "sigs.k8s.io/controller-runtime/pkg/predicate" | ||
|
|
@@ -81,7 +80,10 @@ func (c *ClusterObjectSetReconciler) Reconcile(ctx context.Context, req ctrl.Req | |
| reconciledRev := existingRev.DeepCopy() | ||
| res, reconcileErr := c.reconcile(ctx, reconciledRev) | ||
|
|
||
| if pd := existingRev.Spec.ProgressDeadlineMinutes; pd > 0 { | ||
| // Progress deadline enforcement only applies to Active revisions, not Archived ones. | ||
| // Archived revisions may need to retry teardown operations and should not have their | ||
| // Progressing condition or requeue behavior overridden by the deadline check. | ||
| if pd := existingRev.Spec.ProgressDeadlineMinutes; pd > 0 && reconciledRev.Spec.LifecycleState != ocv1.ClusterObjectSetLifecycleStateArchived { | ||
| cnd := meta.FindStatusCondition(reconciledRev.Status.Conditions, ocv1.ClusterObjectSetTypeProgressing) | ||
| isStillProgressing := cnd != nil && cnd.Status == metav1.ConditionTrue && cnd.Reason != ocv1.ReasonSucceeded | ||
| succeeded := meta.IsStatusConditionTrue(reconciledRev.Status.Conditions, ocv1.ClusterObjectSetTypeSucceeded) | ||
|
|
@@ -344,29 +346,12 @@ type Sourcoser interface { | |
| } | ||
|
|
||
| func (c *ClusterObjectSetReconciler) SetupWithManager(mgr ctrl.Manager) error { | ||
| skipProgressDeadlineExceededPredicate := predicate.Funcs{ | ||
| UpdateFunc: func(e event.UpdateEvent) bool { | ||
| rev, ok := e.ObjectNew.(*ocv1.ClusterObjectSet) | ||
|
Contributor
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. I would extract the whole update func into standalone function, not just the logic under
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. Done
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. @pedjak |
||
| if !ok { | ||
| return true | ||
| } | ||
| // allow deletions to happen | ||
| if !rev.DeletionTimestamp.IsZero() { | ||
| return true | ||
| } | ||
| if cnd := meta.FindStatusCondition(rev.Status.Conditions, ocv1.ClusterObjectSetTypeProgressing); cnd != nil && cnd.Status == metav1.ConditionFalse && cnd.Reason == ocv1.ReasonProgressDeadlineExceeded { | ||
| return false | ||
| } | ||
| return true | ||
| }, | ||
| } | ||
| c.Clock = clock.RealClock{} | ||
| return ctrl.NewControllerManagedBy(mgr). | ||
| For( | ||
| &ocv1.ClusterObjectSet{}, | ||
| builder.WithPredicates( | ||
| predicate.ResourceVersionChangedPredicate{}, | ||
| skipProgressDeadlineExceededPredicate, | ||
| ), | ||
| ). | ||
| WatchesRawSource( | ||
|
|
@@ -684,7 +669,33 @@ func setRetryingConditions(cos *ocv1.ClusterObjectSet, message string) { | |
| } | ||
| } | ||
|
|
||
| // markAsProgressing sets the Progressing condition to True with the given reason. | ||
| // | ||
| // Once ProgressDeadlineExceeded has been set for the current generation, this function | ||
| // blocks only the RollingOut reason to prevent a reconcile loop for Active revisions. | ||
| // The loop would occur when reconcile() sees in-transition objects and sets | ||
| // Progressing=True/RollingOut, then the progress deadline check immediately resets it | ||
| // to ProgressDeadlineExceeded, causing a status-only update that triggers another reconcile. | ||
| // | ||
| // Archived revisions are exempt because they skip progress deadline enforcement entirely, | ||
| // so their status updates won't be overridden. | ||
| // | ||
| // Other reasons like Succeeded and Retrying are always allowed because: | ||
| // - Succeeded represents terminal success (rollout eventually completed) | ||
| // - Retrying represents transient errors that need to be visible in status | ||
| // | ||
| // If the generation changed since ProgressDeadlineExceeded was recorded, the guard | ||
| // allows all updates through so the condition reflects the new generation. | ||
| func markAsProgressing(cos *ocv1.ClusterObjectSet, reason, message string) { | ||
| if cnd := meta.FindStatusCondition(cos.Status.Conditions, ocv1.ClusterObjectSetTypeProgressing); cnd != nil && | ||
| cnd.Status == metav1.ConditionFalse && cnd.Reason == ocv1.ReasonProgressDeadlineExceeded && | ||
| cnd.ObservedGeneration == cos.Generation && | ||
| reason == ocv1.ReasonRollingOut && | ||
| cos.Spec.LifecycleState != ocv1.ClusterObjectSetLifecycleStateArchived { | ||
| log.Log.V(1).Info("skipping markAsProgressing: ProgressDeadlineExceeded is sticky for RollingOut on Active revisions", | ||
| "requestedReason", reason, "revision", cos.Name, "lifecycleState", cos.Spec.LifecycleState) | ||
| return | ||
| } | ||
camilamacedo86 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| meta.SetStatusCondition(&cos.Status.Conditions, metav1.Condition{ | ||
| Type: ocv1.ClusterObjectSetTypeProgressing, | ||
| Status: metav1.ConditionTrue, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.