diff --git a/cmd/k8s-operator/operator.go b/cmd/k8s-operator/operator.go index 20bbf73dd..3e7f56dec 100644 --- a/cmd/k8s-operator/operator.go +++ b/cmd/k8s-operator/operator.go @@ -229,14 +229,15 @@ func (a *ServiceReconciler) cleanupIfRequired(ctx context.Context, svc *corev1.S } if sts != nil { if !sts.GetDeletionTimestamp().IsZero() { - // Deletion in progress, check again later. - return reconcile.Result{RequeueAfter: time.Second}, nil + // Deletion in progress, check again later. We'll get another + // notification when the deletion is complete. + return reconcile.Result{}, nil } err := a.DeleteAllOf(ctx, &appsv1.StatefulSet{}, client.InNamespace(a.operatorNamespace), client.MatchingLabels(ml), client.PropagationPolicy(metav1.DeletePropagationForeground)) if err != nil { return reconcile.Result{}, fmt.Errorf("deleting statefulset: %w", err) } - return reconcile.Result{RequeueAfter: time.Second}, nil + return reconcile.Result{}, nil } id, _, err := a.getDeviceInfo(ctx, svc) diff --git a/cmd/k8s-operator/operator_test.go b/cmd/k8s-operator/operator_test.go index f06fa9258..8b559fddb 100644 --- a/cmd/k8s-operator/operator_test.go +++ b/cmd/k8s-operator/operator_test.go @@ -114,9 +114,9 @@ func TestLoadBalancerClass(t *testing.T) { // synchronous StatefulSet deletion triggers a requeue. But, the StatefulSet // didn't create any child resources since this is all faked, so the // deletion goes through immediately. - expectRequeue(t, sr, "default", "test") + expectReconciled(t, sr, "default", "test") expectMissing[appsv1.StatefulSet](t, fc, "operator-ns", shortName) - // Second time around, the rest of cleanup happens. + // The deletion triggers another reconcile, to finish the cleanup. expectReconciled(t, sr, "default", "test") expectMissing[appsv1.StatefulSet](t, fc, "operator-ns", shortName) expectMissing[corev1.Service](t, fc, "operator-ns", shortName) @@ -206,7 +206,7 @@ func TestAnnotations(t *testing.T) { // synchronous StatefulSet deletion triggers a requeue. But, the StatefulSet // didn't create any child resources since this is all faked, so the // deletion goes through immediately. - expectRequeue(t, sr, "default", "test") + expectReconciled(t, sr, "default", "test") expectMissing[appsv1.StatefulSet](t, fc, "operator-ns", shortName) // Second time around, the rest of cleanup happens. expectReconciled(t, sr, "default", "test")