From b235c171bac080444d81ac7eddf6668f84e8117b Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 14 Apr 2022 10:39:49 +0200 Subject: [PATCH] e2e: retry creation of the RBD StorageClass On occasion the creation of the StorageClass can fail due to an etcdserver timeout. If that happens, the creation can be attempted after a delay. This has already been done for CephFS StorageClasses, but was missed for RBD. See-also: ceph/ceph-csi@8a0377ef02 Signed-off-by: Niels de Vos --- e2e/rbd_helper.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/e2e/rbd_helper.go b/e2e/rbd_helper.go index 52bcdc176..2fd762e0f 100644 --- a/e2e/rbd_helper.go +++ b/e2e/rbd_helper.go @@ -167,9 +167,22 @@ func createRBDStorageClass( sc.MountOptions = append(sc.MountOptions, mOpt...) } sc.ReclaimPolicy = &policy - _, err = c.StorageV1().StorageClasses().Create(context.TODO(), &sc, metav1.CreateOptions{}) - return err + timeout := time.Duration(deployTimeout) * time.Minute + + return wait.PollImmediate(poll, timeout, func() (bool, error) { + _, err = c.StorageV1().StorageClasses().Create(context.TODO(), &sc, metav1.CreateOptions{}) + if err != nil { + e2elog.Logf("error creating StorageClass %q: %v", sc.Name, err) + if isRetryableAPIError(err) { + return false, nil + } + + return false, fmt.Errorf("failed to create StorageClass %q: %w", sc.Name, err) + } + + return true, nil + }) } func createRadosNamespace(f *framework.Framework) error {