-
Notifications
You must be signed in to change notification settings - Fork 70
🐛 Add teardown on revision archival #2502
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -131,61 +131,65 @@ func checkForUnexpectedClusterExtensionRevisionFieldChange(a, b ocv1.ClusterExte | |||||||||||||||||
| return !equality.Semantic.DeepEqual(a.Spec, b.Spec) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev *ocv1.ClusterExtensionRevision) (ctrl.Result, error) { | ||||||||||||||||||
| func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, cer *ocv1.ClusterExtensionRevision) (ctrl.Result, error) { | ||||||||||||||||||
| l := log.FromContext(ctx) | ||||||||||||||||||
|
|
||||||||||||||||||
| revision, opts, err := c.toBoxcutterRevision(ctx, rev) | ||||||||||||||||||
| if !cer.DeletionTimestamp.IsZero() { | ||||||||||||||||||
| return c.delete(ctx, cer) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| revision, opts, err := c.toBoxcutterRevision(ctx, cer) | ||||||||||||||||||
| if err != nil { | ||||||||||||||||||
| setRetryingConditions(rev, err.Error()) | ||||||||||||||||||
| setRetryingConditions(cer, err.Error()) | ||||||||||||||||||
| return ctrl.Result{}, fmt.Errorf("converting to boxcutter revision: %v", err) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
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. why do we need to move this further down?
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. depends on whether we want to remove revision creation from the deletion path or not. Since we want the garbage collector to handle deletion, it could avoid transient (or maybe even persistent) errors from getting in the way. If so, it might also make sense to move it closer to where |
||||||||||||||||||
| if !rev.DeletionTimestamp.IsZero() || rev.Spec.LifecycleState == ocv1.ClusterExtensionRevisionLifecycleStateArchived { | ||||||||||||||||||
| return c.teardown(ctx, rev) | ||||||||||||||||||
| revisionEngine, err := c.RevisionEngineFactory.CreateRevisionEngine(ctx, cer) | ||||||||||||||||||
| if err != nil { | ||||||||||||||||||
| setRetryingConditions(cer, err.Error()) | ||||||||||||||||||
| return ctrl.Result{}, fmt.Errorf("failed to create revision engine: %v", err) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if cer.Spec.LifecycleState == ocv1.ClusterExtensionRevisionLifecycleStateArchived { | ||||||||||||||||||
| if err := c.TrackingCache.Free(ctx, cer); err != nil { | ||||||||||||||||||
| markAsAvailableUnknown(cer, ocv1.ClusterExtensionRevisionReasonReconciling, err.Error()) | ||||||||||||||||||
| return ctrl.Result{}, fmt.Errorf("error stopping informers: %v", err) | ||||||||||||||||||
| } | ||||||||||||||||||
|
||||||||||||||||||
| } | |
| } | |
| // If the teardown finalizer has already been removed, teardown/archive is complete. | |
| // In that case, skip calling archive() to avoid unnecessary updates and reconcile churn. | |
| if !controllerutil.ContainsFinalizer(cer, clusterExtensionRevisionTeardownFinalizer) { | |
| return ctrl.Result{}, nil | |
| } |
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.
I've restructured things to only ensureFinalizer in the Active code path
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.
is really needed in this PR to rename arg from
revtocer? It makes the diff bigger than it needs to be.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.
I feel it reads better, especially when you have two parallel revision objects. It makes it easier to know that you're operating over the CER vs the Boxcutter revision. It might even be worth going forward and renaming revision to boxcutterRevision or bcRev, or something like that.
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.
If it would be helpful, I could revert it for this PR and do a follow up with just that change