From 8ca7a3582020b5774672abbfe4b6685c9f18617c Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Mon, 2 Aug 2021 16:34:12 +0530 Subject: [PATCH] e2e: use retryKubectlFile() for creating & deleting secrets Signed-off-by: Rakshith R --- e2e/rbd.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/e2e/rbd.go b/e2e/rbd.go index 8bd81081c..8e2560259 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -815,11 +815,7 @@ var _ = Describe("RBD", func() { namespace := cephCSINamespace // create user Secret - secret, err := getSecret(vaultExamplePath + "user-secret.yaml") - if err != nil { - e2elog.Failf("failed to load user Secret: %v", err) - } - _, err = c.CoreV1().Secrets(namespace).Create(context.TODO(), &secret, metav1.CreateOptions{}) + err = retryKubectlFile(namespace, kubectlCreate, vaultExamplePath+"user-secret.yaml", deployTimeout) if err != nil { e2elog.Failf("failed to create user Secret: %v", err) } @@ -832,7 +828,11 @@ var _ = Describe("RBD", func() { validateRBDImageCount(f, 0, defaultRBDPool) // delete user secret - err = c.CoreV1().Secrets(namespace).Delete(context.TODO(), secret.Name, metav1.DeleteOptions{}) + err = retryKubectlFile(namespace, + kubectlDelete, + vaultExamplePath+"user-secret.yaml", + deployTimeout, + "--ignore-not-found=true") if err != nil { e2elog.Failf("failed to delete user Secret: %v", err) } @@ -867,11 +867,7 @@ var _ = Describe("RBD", func() { namespace := f.UniqueName // create user Secret - secret, err := getSecret(vaultExamplePath + "user-secret.yaml") - if err != nil { - e2elog.Failf("failed to load user Secret: %v", err) - } - _, err = c.CoreV1().Secrets(namespace).Create(context.TODO(), &secret, metav1.CreateOptions{}) + err = retryKubectlFile(namespace, kubectlCreate, vaultExamplePath+"user-secret.yaml", deployTimeout) if err != nil { e2elog.Failf("failed to create user Secret: %v", err) } @@ -884,7 +880,12 @@ var _ = Describe("RBD", func() { validateRBDImageCount(f, 0, defaultRBDPool) // delete user secret - err = c.CoreV1().Secrets(namespace).Delete(context.TODO(), secret.Name, metav1.DeleteOptions{}) + err = retryKubectlFile( + namespace, + kubectlDelete, + vaultExamplePath+"user-secret.yaml", + deployTimeout, + "--ignore-not-found=true") if err != nil { e2elog.Failf("failed to delete user Secret: %v", err) }