Skip to content

Commit 20aa5f1

Browse files
Merge pull request #2957 from sttts/sttts-workspace-deletion-optimization
🐛 tenancy: only delete LogicalCluster if needed
2 parents 2dbc5df + a6c6920 commit 20aa5f1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pkg/reconciler/tenancy/workspace/workspace_reconcile_deletion.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ func (r *deletionReconciler) reconcile(ctx context.Context, workspace *tenancyv1
6262
clusterName = logicalcluster.Name(a)
6363
}
6464

65-
if _, err := r.getLogicalCluster(ctx, clusterName.Path()); err != nil && !apierrors.IsNotFound(err) {
65+
logicalCluster, err := r.getLogicalCluster(ctx, clusterName.Path())
66+
if err != nil && !apierrors.IsNotFound(err) {
6667
return reconcileStatusStopAndRequeue, err
6768
} else if apierrors.IsNotFound(err) {
6869
finalizers := sets.New[string](workspace.Finalizers...)
@@ -74,9 +75,11 @@ func (r *deletionReconciler) reconcile(ctx context.Context, workspace *tenancyv1
7475
return reconcileStatusContinue, nil
7576
}
7677

77-
logger.Info("Deleting LogicalCluster")
78-
if err := r.deleteLogicalCluster(ctx, clusterName.Path()); err != nil {
79-
return reconcileStatusStopAndRequeue, err
78+
if logicalCluster.DeletionTimestamp.IsZero() {
79+
logger.Info("Deleting LogicalCluster")
80+
if err := r.deleteLogicalCluster(ctx, clusterName.Path()); err != nil {
81+
return reconcileStatusStopAndRequeue, err
82+
}
8083
}
8184

8285
// here we are waiting for the other shard to remove the finalizer of the Workspace

0 commit comments

Comments
 (0)