diff --git a/e2e/node.go b/e2e/node.go index d2a258a0ce7..2226199b222 100644 --- a/e2e/node.go +++ b/e2e/node.go @@ -45,13 +45,19 @@ func addLabelsToNodes(f *framework.Framework, labels map[string]string) error { return nil } -func deleteNodeLabel(c kubernetes.Interface, labelKey string) error { +func deleteNodeLabels(c kubernetes.Interface, labelKeys []string) error { nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{}) if err != nil { return fmt.Errorf("failed to list node: %w", err) } for i := range nodes.Items { - e2enode.RemoveLabelOffNode(c, nodes.Items[i].Name, labelKey) + if err := testutils.RemoveLabelOffNode(c, nodes.Items[i].Name, labelKeys); err != nil { + return fmt.Errorf("failed to remove label off node: %w", err) + } + + if err := testutils.VerifyLabelsRemoved(c, nodes.Items[i].Name, labelKeys); err != nil { + return fmt.Errorf("failed to verify label removed from node: %w", err) + } } return nil diff --git a/e2e/rbd.go b/e2e/rbd.go index 5834d2e48ea..e4c320c26d6 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -401,31 +401,16 @@ var _ = Describe("RBD", func() { } } } - err = deleteNodeLabel(c, nodeRegionLabel) - if err != nil { - framework.Failf("failed to delete node label: %v", err) - } - err = deleteNodeLabel(c, nodeZoneLabel) - if err != nil { - framework.Failf("failed to delete node label: %v", err) - } - // Remove the CSI labels that get added - err = deleteNodeLabel(c, nodeCSIRegionLabel) - if err != nil { - framework.Failf("failed to delete node label: %v", err) - } - err = deleteNodeLabel(c, nodeCSIZoneLabel) - if err != nil { - framework.Failf("failed to delete node label: %v", err) - } - // Remove the CRUSH Location labels - err = deleteNodeLabel(c, crushLocationRegionLabel) - if err != nil { - framework.Failf("failed to delete node label: %v", err) - } - err = deleteNodeLabel(c, crushLocationZoneLabel) + err = deleteNodeLabels(c, []string{ + nodeRegionLabel, + nodeZoneLabel, + nodeCSIRegionLabel, + nodeCSIZoneLabel, + crushLocationRegionLabel, + crushLocationZoneLabel, + }) if err != nil { - framework.Failf("failed to delete node label: %v", err) + framework.Failf("failed to delete node labels: %v", err) } }) diff --git a/e2e/upgrade-rbd.go b/e2e/upgrade-rbd.go index 55c73f9c086..e906956e6b7 100644 --- a/e2e/upgrade-rbd.go +++ b/e2e/upgrade-rbd.go @@ -165,13 +165,12 @@ var _ = Describe("RBD Upgrade Testing", func() { } } } - err = deleteNodeLabel(c, nodeRegionLabel) - if err != nil { - framework.Failf("failed to delete node label: %v", err) - } - err = deleteNodeLabel(c, nodeZoneLabel) + err = deleteNodeLabels(c, []string{ + nodeRegionLabel, + nodeZoneLabel, + }) if err != nil { - framework.Failf("failed to delete node label: %v", err) + framework.Failf("failed to delete node labels: %v", err) } })