From 180f0f660fc034c610cf33d797e7a38514c4558c Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Tue, 4 Jan 2022 16:11:53 +0530 Subject: [PATCH] e2e: make recreateCSIRBDPods() function to a generic one This commit make recreateCSIRBDPods function to be a general one so that it can be consumed by more clients. Updates https://github.com/ceph/ceph-csi/issues/2509 Signed-off-by: Humble Chirammal --- e2e/migration.go | 2 +- e2e/pod.go | 19 +++++++++++++++++++ e2e/rbd_helper.go | 19 ------------------- e2e/utils.go | 2 ++ 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/e2e/migration.go b/e2e/migration.go index 114718b98c1..169a7602abb 100644 --- a/e2e/migration.go +++ b/e2e/migration.go @@ -62,7 +62,7 @@ func generateClusterIDConfigMapForMigration(f *framework.Framework, c kubernetes return fmt.Errorf("failed to create configmap: %w", err) } // restart csi pods for the configmap to take effect. - err = recreateCSIRBDPods(f) + err = recreateCSIPods(f, rbdPodLabels, rbdDaemonsetName, rbdDeploymentName) if err != nil { return fmt.Errorf("failed to recreate rbd csi pods: %w", err) } diff --git a/e2e/pod.go b/e2e/pod.go index 6e76881ecc5..8100483b408 100644 --- a/e2e/pod.go +++ b/e2e/pod.go @@ -395,3 +395,22 @@ func getKernelVersionFromDaemonset(f *framework.Framework, ns, dsn, cn string) ( return kernelRelease, nil } + +// recreateCSIPods delete the daemonset and deployment pods based on the selectors passed in. +func recreateCSIPods(f *framework.Framework, podLabels, daemonsetName, deploymentName string) error { + err := deletePodWithLabel(podLabels, cephCSINamespace, false) + if err != nil { + return fmt.Errorf("failed to delete pods with labels (%s): %w", podLabels, err) + } + // wait for csi pods to come up + err = waitForDaemonSets(daemonsetName, cephCSINamespace, f.ClientSet, deployTimeout) + if err != nil { + return fmt.Errorf("timeout waiting for daemonset pods: %w", err) + } + err = waitForDeploymentComplete(f.ClientSet, deploymentName, cephCSINamespace, deployTimeout) + if err != nil { + return fmt.Errorf("timeout waiting for deployment to be in running state: %w", err) + } + + return nil +} diff --git a/e2e/rbd_helper.go b/e2e/rbd_helper.go index 1d909e7f772..95184a50913 100644 --- a/e2e/rbd_helper.go +++ b/e2e/rbd_helper.go @@ -1013,22 +1013,3 @@ func waitToRemoveImagesFromTrash(f *framework.Framework, poolName string, t int) return err } - -func recreateCSIRBDPods(f *framework.Framework) error { - err := deletePodWithLabel("app in (ceph-csi-rbd, csi-rbdplugin, csi-rbdplugin-provisioner)", - cephCSINamespace, false) - if err != nil { - return fmt.Errorf("failed to delete pods with labels: %w", err) - } - // wait for csi pods to come up - err = waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout) - if err != nil { - return fmt.Errorf("timeout waiting for daemonset pods: %w", err) - } - err = waitForDeploymentComplete(f.ClientSet, rbdDeploymentName, cephCSINamespace, deployTimeout) - if err != nil { - return fmt.Errorf("timeout waiting for deployment to be in running state: %w", err) - } - - return nil -} diff --git a/e2e/utils.go b/e2e/utils.go index b2f00b1f813..69c40176439 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -60,6 +60,8 @@ const ( appLabel = "write-data-in-pod" noError = "" + // labels/selector used to list/delete rbd pods. + rbdPodLabels = "app in (ceph-csi-rbd, csi-rbdplugin, csi-rbdplugin-provisioner)" ) var (