diff --git a/pkg/controllers/node/health/controller.go b/pkg/controllers/node/health/controller.go index db4e96f932..3179b34b1b 100644 --- a/pkg/controllers/node/health/controller.go +++ b/pkg/controllers/node/health/controller.go @@ -120,10 +120,19 @@ func (c *Controller) Reconcile(ctx context.Context, node *corev1.Node) (reconcil if err := c.annotateTerminationGracePeriod(ctx, nodeClaim); err != nil { return reconcile.Result{}, client.IgnoreNotFound(err) } + c.deleteNodeClaim(ctx, nodeClaim, node) + + return c.deleteNodeClaim(ctx, nodeClaim, node) +} + +// deleteNodeClaim removes the NodeClaim from the api-server +func (c *Controller) deleteNodeClaim(ctx context.Context, nodeClaim *v1.NodeClaim, node *corev1.Node) (reconcile.Result, error) { + if !nodeClaim.DeletionTimestamp.IsZero() { + return nil + } if err := c.kubeClient.Delete(ctx, nodeClaim); err != nil { return reconcile.Result{}, client.IgnoreNotFound(err) } - // The deletion timestamp has successfully been set for the Node, update relevant metrics. log.FromContext(ctx).V(1).Info("deleting unhealthy node") metrics.NodeClaimsDisruptedTotal.Inc(map[string]string{