Skip to content

Commit

Permalink
Modify node object instead of making new (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrandon1 authored Nov 9, 2023
1 parent 9a4a697 commit 9784d65
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions tests/utils/nodes/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,10 @@ func ensureAllNodesAreLabeled(client corev1Typed.CoreV1Interface, label string)

// LabelNode labels a node by a given node name.
func LabelNode(client corev1Typed.CoreV1Interface, node *corev1.Node, label, value string) error {
node.Labels[label] = value

// Set the label
_, err := client.Nodes().Update(context.TODO(), &corev1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: node.Name,
Labels: map[string]string{label: value},
},
}, metav1.UpdateOptions{})
_, err := client.Nodes().Update(context.TODO(), node, metav1.UpdateOptions{})

return err
}
Expand Down

0 comments on commit 9784d65

Please sign in to comment.