Skip to content

Commit

Permalink
Fix panic in termination flow (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis authored Feb 7, 2023
1 parent a6491a7 commit 6abab23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/controllers/machine/terminator/terminator.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func (t *Terminator) TerminateNode(ctx context.Context, node *v1.Node) error {
if err := t.kubeClient.Patch(ctx, node, client.MergeFrom(stored)); err != nil {
return err
}
terminationSummary.Observe(time.Since(node.DeletionTimestamp.Time).Seconds())
// We use stored.DeletionTimestamp since the api-server may give back a node after the patch without a deletionTimestamp
terminationSummary.Observe(time.Since(stored.DeletionTimestamp.Time).Seconds())
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/controllers/termination/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ func (c *Controller) Finalize(ctx context.Context, node *v1.Node) (reconcile.Res
return reconcile.Result{}, nil
}
if err := c.terminator.Cordon(ctx, node); err != nil {
return reconcile.Result{}, fmt.Errorf("cordoning node, %w", err)
return reconcile.Result{}, client.IgnoreNotFound(fmt.Errorf("cordoning node, %w", err))
}
if err := c.terminator.Drain(ctx, node); err != nil {
if terminator.IsNodeDrainError(err) {
c.recorder.Publish(events.NodeFailedToDrain(node, err))
return reconcile.Result{Requeue: true}, nil
}
return reconcile.Result{}, fmt.Errorf("draining node, %w", err)
return reconcile.Result{}, client.IgnoreNotFound(fmt.Errorf("draining node, %w", err))
}
if err := c.terminator.TerminateNode(ctx, node); err != nil {
return reconcile.Result{}, fmt.Errorf("terminating node, %w", err)
return reconcile.Result{}, client.IgnoreNotFound(fmt.Errorf("terminating node, %w", err))
}
return reconcile.Result{}, nil
}
Expand Down

0 comments on commit 6abab23

Please sign in to comment.