Skip to content

Commit

Permalink
Fix not-found handling on delete and fix event msg
Browse files Browse the repository at this point in the history
  • Loading branch information
nstogner committed Mar 6, 2024
1 parent 33b641a commit 4fe6ac9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tpu-provisioner/internal/cloud/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ func (g *GKE) DeleteNodePoolForNode(node *corev1.Node) error {

op, err := g.Service.Projects.Locations.Clusters.Delete(g.ClusterContext.NodePoolName(name)).Do()
if err != nil {
if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == http.StatusNotFound {
return nil
}
return fmt.Errorf("deleting node pool %q: %w", name, err)
}

Expand Down
2 changes: 1 addition & 1 deletion tpu-provisioner/internal/controller/deletion_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (r *DeletionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
return ctrl.Result{}, nil
} else {
r.Recorder.Event(&node, corev1.EventTypeWarning, EventFailedDeletingNodePool, "Failed to delete Node Pool: "+err.Error())
return ctrl.Result{}, client.IgnoreNotFound(err)
return ctrl.Result{}, err
}
}
r.Recorder.Event(&node, corev1.EventTypeNormal, EventNodePoolDeleted, DeletedNodePoolEventMessage)
Expand Down
2 changes: 1 addition & 1 deletion tpu-provisioner/internal/controller/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ const (
EventNodePoolEnsured = "NodePoolEnsured"
EventDeletingNodePool = "DeletingNodePool"
EventNodePoolDeleted = "NodePoolDeleted"
DeletingNodePoolEventMessage = "Deleted Node Pool."
DeletingNodePoolEventMessage = "Deleting Node Pool."
DeletedNodePoolEventMessage = "Deleted Node Pool."
)

0 comments on commit 4fe6ac9

Please sign in to comment.