Skip to content

Commit 1587d23

Browse files
committed
rename corev1alpha1.LogicalClusterFinalizer to LogicalClusterFinalizerName
This is required so we can use the LogicalClusterFinalizer as a custom string type like we do it with LogicalClusterInitializer On-behalf-of: SAP <[email protected]> Signed-off-by: Simon Bein <[email protected]>
1 parent cfaad25 commit 1587d23

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

pkg/reconciler/tenancy/workspace/workspace_reconcile_deletion.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (r *deletionReconciler) reconcile(ctx context.Context, workspace *tenancyv1
5252
finSet := sets.New(workspace.Finalizers...)
5353

5454
// we want our finalizer to be removed last, so check if other finalizers exist
55-
if finSet.Has(corev1alpha1.LogicalClusterFinalizer) && finSet.Len() > 1 {
55+
if finSet.Has(corev1alpha1.LogicalClusterFinalizerName) && finSet.Len() > 1 {
5656
return reconcileStatusContinue, nil
5757
}
5858

@@ -64,7 +64,7 @@ func (r *deletionReconciler) reconcile(ctx context.Context, workspace *tenancyv1
6464
// if the logicalcluster was never created, we can directly remove the
6565
// workspace finalizer
6666
if !ok {
67-
workspace.Finalizers = sets.List(finSet.Delete(corev1alpha1.LogicalClusterFinalizer))
67+
workspace.Finalizers = sets.List(finSet.Delete(corev1alpha1.LogicalClusterFinalizerName))
6868
return reconcileStatusContinue, nil
6969
}
7070

@@ -100,9 +100,9 @@ func (r *deletionReconciler) reconcile(ctx context.Context, workspace *tenancyv1
100100
// fall-through
101101
}
102102
if apierrors.IsNotFound(getErr) {
103-
if finSet.Has(corev1alpha1.LogicalClusterFinalizer) {
104-
logger.Info(fmt.Sprintf("Removing finalizer %s", corev1alpha1.LogicalClusterFinalizer))
105-
workspace.Finalizers = sets.List(finSet.Delete(corev1alpha1.LogicalClusterFinalizer))
103+
if finSet.Has(corev1alpha1.LogicalClusterFinalizerName) {
104+
logger.Info(fmt.Sprintf("Removing finalizer %s", corev1alpha1.LogicalClusterFinalizerName))
105+
workspace.Finalizers = sets.List(finSet.Delete(corev1alpha1.LogicalClusterFinalizerName))
106106
return reconcileStatusStopAndRequeue, nil // spec change
107107
}
108108
return reconcileStatusContinue, nil

pkg/reconciler/tenancy/workspace/workspace_reconcile_deletion_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ func TestReconcile(t *testing.T) {
9393
ObjectMeta: metav1.ObjectMeta{
9494
DeletionTimestamp: ptr.To(metav1.Now()),
9595
Finalizers: []string{
96-
corev1alpha1.LogicalClusterFinalizer,
96+
corev1alpha1.LogicalClusterFinalizerName,
9797
"other-finalizer",
9898
},
9999
},
100100
},
101101
expFinalizers: []string{
102-
corev1alpha1.LogicalClusterFinalizer,
102+
corev1alpha1.LogicalClusterFinalizerName,
103103
"other-finalizer",
104104
},
105105
},
@@ -110,7 +110,7 @@ func TestReconcile(t *testing.T) {
110110
ObjectMeta: metav1.ObjectMeta{
111111
DeletionTimestamp: ptr.To(metav1.Now()),
112112
Finalizers: []string{
113-
corev1alpha1.LogicalClusterFinalizer,
113+
corev1alpha1.LogicalClusterFinalizerName,
114114
},
115115
},
116116
Status: tenancyv1alpha1.WorkspaceStatus{
@@ -128,7 +128,7 @@ func TestReconcile(t *testing.T) {
128128
ObjectMeta: metav1.ObjectMeta{
129129
DeletionTimestamp: ptr.To(metav1.Now()),
130130
Finalizers: []string{
131-
corev1alpha1.LogicalClusterFinalizer,
131+
corev1alpha1.LogicalClusterFinalizerName,
132132
},
133133
Annotations: map[string]string{
134134
workspaceClusterAnnotationKey: "test",
@@ -144,7 +144,7 @@ func TestReconcile(t *testing.T) {
144144
// we do not remove our finalizers in this case, as we wait
145145
// for another reconciliation loop
146146
expFinalizers: []string{
147-
corev1alpha1.LogicalClusterFinalizer,
147+
corev1alpha1.LogicalClusterFinalizerName,
148148
},
149149
// we do expect our logicalCluster to be removed
150150
expLogicalClusters: map[string]*corev1alpha1.LogicalCluster{},
@@ -156,7 +156,7 @@ func TestReconcile(t *testing.T) {
156156
ObjectMeta: metav1.ObjectMeta{
157157
DeletionTimestamp: ptr.To(metav1.Now()),
158158
Finalizers: []string{
159-
corev1alpha1.LogicalClusterFinalizer,
159+
corev1alpha1.LogicalClusterFinalizerName,
160160
},
161161
},
162162
},

pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (r *schedulingReconciler) reconcile(ctx context.Context, workspace *tenancy
141141
shardNameHash, hasShard := workspace.Annotations[WorkspaceShardHashAnnotationKey]
142142
clusterNameString, hasCluster := workspace.Annotations[workspaceClusterAnnotationKey]
143143
clusterName := logicalcluster.Name(clusterNameString)
144-
hasFinalizer := sets.New[string](workspace.Finalizers...).Has(corev1alpha1.LogicalClusterFinalizer)
144+
hasFinalizer := sets.New[string](workspace.Finalizers...).Has(corev1alpha1.LogicalClusterFinalizerName)
145145

146146
parentThis, err := r.getLogicalCluster(logicalcluster.From(workspace))
147147
if err != nil && !apierrors.IsNotFound(err) {
@@ -180,7 +180,7 @@ func (r *schedulingReconciler) reconcile(ctx context.Context, workspace *tenancy
180180
workspace.Annotations[workspaceClusterAnnotationKey] = cluster.String()
181181
}
182182
if !hasFinalizer {
183-
workspace.Finalizers = append(workspace.Finalizers, corev1alpha1.LogicalClusterFinalizer)
183+
workspace.Finalizers = append(workspace.Finalizers, corev1alpha1.LogicalClusterFinalizerName)
184184
}
185185
if !hasShard || !hasCluster || !hasFinalizer {
186186
// this is the first part of our two-phase commit

sdk/apis/core/v1alpha1/logicalcluster_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ const (
5252
// LogicalClusterName is the name of the LogicalCluster singleton.
5353
LogicalClusterName = "cluster"
5454

55-
// LogicalClusterFinalizer attached to the owner of the LogicalCluster resource (usually a Workspace) so that we can control
55+
// LogicalClusterFinalizerName attached to the owner of the LogicalCluster resource (usually a Workspace) so that we can control
5656
// deletion of LogicalCluster resources.
57-
LogicalClusterFinalizer = "core.kcp.io/logicalcluster"
57+
LogicalClusterFinalizerName = "core.kcp.io/logicalcluster"
5858
)
5959

6060
// LogicalClusterPhaseType is the type of the current phase of the logical cluster.

test/e2e/workspace/deletion_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func TestWorkspaceLogicalClusterRelationship(t *testing.T) {
9696
ws, err := clientset.Cluster(fixtureRoot).TenancyV1alpha1().Workspaces().Get(ctx, wsName, v1.GetOptions{})
9797
require.NoError(c, err, "error getting workspace")
9898
require.NotEqual(c, nil, ws.DeletionTimestamp)
99-
require.Contains(c, ws.Finalizers, corev1alpha1.LogicalClusterFinalizer)
99+
require.Contains(c, ws.Finalizers, corev1alpha1.LogicalClusterFinalizerName)
100100
}, wait.ForeverTestTimeout, 100*time.Millisecond, "waiting for workspace to be marked for deletion")
101101

102102
// remove the custom finalizer from the logicalcluster object

0 commit comments

Comments
 (0)