Skip to content

Commit

Permalink
fix: added missing logic to label nodes when we cordon them
Browse files Browse the repository at this point in the history
  • Loading branch information
amargherio committed Jul 15, 2024
1 parent 2ea84e1 commit 8494231
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package node

import (
"context"

"go.uber.org/zap"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -18,8 +19,11 @@ func CordonNode(ctx context.Context, clientset kubernetes.Interface, node *v1.No
return nil
}

// cordon the node
// update the labels to show mechanic cordoned the node and cordon the node
node.Spec.Unschedulable = true
labels := node.GetLabels()
labels["mechanic.cordoned"] = "true"
node.SetLabels(labels)
_, err := clientset.CoreV1().Nodes().Update(ctx, node, metav1.UpdateOptions{})
if err != nil {
log.Errorw("Failed to cordon node", "node", node.Name, "error", err)
Expand Down

0 comments on commit 8494231

Please sign in to comment.