mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-19 19:38:40 +00:00
cmd/k8s-operator: remove times requeues in proxy deletion path.
Our reconcile loop gets triggered again when the StatefulSet object finally disappears (in addition to when its deletion starts, as indicated by DeletionTimestamp != 0). So, we don't need to queue additional reconciliations to proceed with the remainder of the cleanup, that happens organically. Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
c0fcab01ac
commit
8ccd707218
@ -229,14 +229,15 @@ func (a *ServiceReconciler) cleanupIfRequired(ctx context.Context, svc *corev1.S
|
|||||||
}
|
}
|
||||||
if sts != nil {
|
if sts != nil {
|
||||||
if !sts.GetDeletionTimestamp().IsZero() {
|
if !sts.GetDeletionTimestamp().IsZero() {
|
||||||
// Deletion in progress, check again later.
|
// Deletion in progress, check again later. We'll get another
|
||||||
return reconcile.Result{RequeueAfter: time.Second}, nil
|
// 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))
|
err := a.DeleteAllOf(ctx, &appsv1.StatefulSet{}, client.InNamespace(a.operatorNamespace), client.MatchingLabels(ml), client.PropagationPolicy(metav1.DeletePropagationForeground))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return reconcile.Result{}, fmt.Errorf("deleting statefulset: %w", err)
|
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)
|
id, _, err := a.getDeviceInfo(ctx, svc)
|
||||||
|
@ -114,9 +114,9 @@ func TestLoadBalancerClass(t *testing.T) {
|
|||||||
// synchronous StatefulSet deletion triggers a requeue. But, the StatefulSet
|
// synchronous StatefulSet deletion triggers a requeue. But, the StatefulSet
|
||||||
// didn't create any child resources since this is all faked, so the
|
// didn't create any child resources since this is all faked, so the
|
||||||
// deletion goes through immediately.
|
// deletion goes through immediately.
|
||||||
expectRequeue(t, sr, "default", "test")
|
expectReconciled(t, sr, "default", "test")
|
||||||
expectMissing[appsv1.StatefulSet](t, fc, "operator-ns", shortName)
|
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")
|
expectReconciled(t, sr, "default", "test")
|
||||||
expectMissing[appsv1.StatefulSet](t, fc, "operator-ns", shortName)
|
expectMissing[appsv1.StatefulSet](t, fc, "operator-ns", shortName)
|
||||||
expectMissing[corev1.Service](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
|
// synchronous StatefulSet deletion triggers a requeue. But, the StatefulSet
|
||||||
// didn't create any child resources since this is all faked, so the
|
// didn't create any child resources since this is all faked, so the
|
||||||
// deletion goes through immediately.
|
// deletion goes through immediately.
|
||||||
expectRequeue(t, sr, "default", "test")
|
expectReconciled(t, sr, "default", "test")
|
||||||
expectMissing[appsv1.StatefulSet](t, fc, "operator-ns", shortName)
|
expectMissing[appsv1.StatefulSet](t, fc, "operator-ns", shortName)
|
||||||
// Second time around, the rest of cleanup happens.
|
// Second time around, the rest of cleanup happens.
|
||||||
expectReconciled(t, sr, "default", "test")
|
expectReconciled(t, sr, "default", "test")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user