From 2cd1be6f95693bd115bf851fb425965ab9a0927c Mon Sep 17 00:00:00 2001 From: Kyle Squizzato Date: Tue, 1 Oct 2024 08:59:10 -0700 Subject: [PATCH] Fix nil panic, add debug to CRD validation Signed-off-by: Kyle Squizzato --- .../clusteridentity/clusteridentity.go | 13 +++++++++---- test/e2e/managedcluster/validate_deployed.go | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test/e2e/managedcluster/clusteridentity/clusteridentity.go b/test/e2e/managedcluster/clusteridentity/clusteridentity.go index 608cf1b4a..c9bbc30a3 100644 --- a/test/e2e/managedcluster/clusteridentity/clusteridentity.go +++ b/test/e2e/managedcluster/clusteridentity/clusteridentity.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "os" + "time" "github.com/Mirantis/hmc/test/e2e/kubeclient" "github.com/Mirantis/hmc/test/e2e/managedcluster" @@ -117,10 +118,14 @@ func (ci *ClusterIdentity) waitForResourceCRD(kc *kubeclient.KubeClient) { ctx := context.Background() client := kc.GetDynamicClient(ci.GroupVersionResource) - Eventually(func() bool { - _, err := client.List(ctx, metav1.ListOptions{}) - return err == nil - }, "1m", "5s").Should(BeTrue(), "failed to list %s", ci.GroupVersionResource.String()) + Eventually(func() error { + if _, err := client.List(ctx, metav1.ListOptions{}); err != nil { + _, _ = fmt.Fprintf(GinkgoWriter, "failed to list %s resources: %v, retrying...\n", ci.GroupVersionResource.Resource, err) + return err + } + _, _ = fmt.Fprintf(GinkgoWriter, "CRD available\n") + return nil + }).WithTimeout(time.Minute).WithPolling(5 * time.Second).Should(Succeed()) } // createSecret creates a secret affiliated with a ClusterIdentity. diff --git a/test/e2e/managedcluster/validate_deployed.go b/test/e2e/managedcluster/validate_deployed.go index a59cb935c..b2b0c6201 100644 --- a/test/e2e/managedcluster/validate_deployed.go +++ b/test/e2e/managedcluster/validate_deployed.go @@ -191,7 +191,7 @@ func validateCSIDriver(ctx context.Context, kc *kubeclient.KubeClient, clusterNa return fmt.Errorf("failed to get test PVC: %w", err) } - if !strings.Contains(*pvc.Spec.StorageClassName, "csi") { + if pvc.Spec.StorageClassName != nil && !strings.Contains(*pvc.Spec.StorageClassName, "csi") { Fail(fmt.Sprintf("%s PersistentVolumeClaim does not have a CSI driver storageClass", pvcName)) }