From 40402255b2659f730c09d737220fcaf690027106 Mon Sep 17 00:00:00 2001 From: raaizik <132667934+raaizik@users.noreply.github.com> Date: Sun, 12 May 2024 16:11:54 +0300 Subject: [PATCH] e2e test failure fix Signed-off-by: raaizik <132667934+raaizik@users.noreply.github.com> --- .../storagecluster/initialization_reconciler_test.go | 12 ++++-------- controllers/storagecluster/odfinfoconfig.go | 12 ++++++------ .../storagecluster/storagecluster_controller_test.go | 2 +- pkg/deploy-manager/config.go | 3 +++ pkg/deploy-manager/storagecluster.go | 8 ++++++++ 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/controllers/storagecluster/initialization_reconciler_test.go b/controllers/storagecluster/initialization_reconciler_test.go index ed7e6e15e9..9f00120c78 100644 --- a/controllers/storagecluster/initialization_reconciler_test.go +++ b/controllers/storagecluster/initialization_reconciler_test.go @@ -355,21 +355,17 @@ func createFakeInitializationStorageClusterReconciler(t *testing.T, obj ...runti Phase: cephv1.ConditionType(util.PhaseReady), }, } - verOdf, err := semver.Make(getSemVer(ocsversion.Version, 1, true)) + verOcs, err := semver.Make(getSemVer(ocsversion.Version, 1, true)) if err != nil { - verOdf = semver.Version{ - Major: 0, - Minor: 0, - Patch: 0, - } + panic(err) } csv := &opv1a1.ClusterServiceVersion{ ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("odf-operator-%s", sc.Name), + Name: fmt.Sprintf("ocs-operator-%s", sc.Name), Namespace: sc.Namespace, }, Spec: opv1a1.ClusterServiceVersionSpec{ - Version: oprverion.OperatorVersion{Version: verOdf}, + Version: oprverion.OperatorVersion{Version: verOcs}, }, } diff --git a/controllers/storagecluster/odfinfoconfig.go b/controllers/storagecluster/odfinfoconfig.go index 4dd83d9e9c..a9b74c485b 100644 --- a/controllers/storagecluster/odfinfoconfig.go +++ b/controllers/storagecluster/odfinfoconfig.go @@ -44,7 +44,7 @@ const ( odfDeploymentTypeInternal = "internal" rookCephMonSecretName = "rook-ceph-mon" fsidKey = "fsid" - odfOperatorNamePrefix = "odf-operator" + ocsOperatorNamePrefix = "ocs-operator" odfInfoConfigMapName = "odf-info" odfInfoMapKind = "ConfigMap" ) @@ -98,7 +98,7 @@ func (obj *odfInfoConfig) ensureCreated(r *StorageClusterReconciler, storageClus } func (obj *odfInfoConfig) getOdfInfoKeyName(storageCluster *ocsv1.StorageCluster) string { - return fmt.Sprintf("%s/%s.%s", storageCluster.Namespace, storageCluster.Name, odfInfoKeySuffix) + return fmt.Sprintf("%s_%s.%s", storageCluster.Namespace, storageCluster.Name, odfInfoKeySuffix) } // ensureDeleted is dummy func for the odfInfoConfig @@ -136,7 +136,7 @@ func (obj *odfInfoConfig) ensureDeleted(r *StorageClusterReconciler, storageClus } func getOdfInfoData(r *StorageClusterReconciler, storageCluster *ocsv1.StorageCluster) (string, error) { - odfVersion, err := getOdfVersion(r, storageCluster) + odfVersion, err := getOcsVersion(r, storageCluster) if err != nil { return "", err } @@ -216,7 +216,7 @@ func getStorageSystemName(storageCluster *ocsv1.StorageCluster) (string, error) } -func getOdfVersion(r *StorageClusterReconciler, storageCluster *ocsv1.StorageCluster) (string, error) { +func getOcsVersion(r *StorageClusterReconciler, storageCluster *ocsv1.StorageCluster) (string, error) { var csvs operatorsv1alpha1.ClusterServiceVersionList err := r.Client.List(r.ctx, &csvs, client.InNamespace(storageCluster.Namespace)) if err != nil { @@ -224,10 +224,10 @@ func getOdfVersion(r *StorageClusterReconciler, storageCluster *ocsv1.StorageClu } csv := util.Find(csvs.Items, func(csv *operatorsv1alpha1.ClusterServiceVersion) bool { - return strings.HasPrefix(csv.Name, odfOperatorNamePrefix) + return strings.HasPrefix(csv.Name, ocsOperatorNamePrefix) }) if csv == nil { - return "", fmt.Errorf("failed to find csv with prefix %q", odfOperatorNamePrefix) + return "", fmt.Errorf("failed to find csv with prefix %q", ocsOperatorNamePrefix) } return csv.Spec.Version.String(), nil } diff --git a/controllers/storagecluster/storagecluster_controller_test.go b/controllers/storagecluster/storagecluster_controller_test.go index f206f75684..b85df13765 100644 --- a/controllers/storagecluster/storagecluster_controller_test.go +++ b/controllers/storagecluster/storagecluster_controller_test.go @@ -1133,7 +1133,7 @@ func createFakeStorageClusterReconciler(t *testing.T, obj ...runtime.Object) Sto } csv := &opv1a1.ClusterServiceVersion{ ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("odf-operator-%s", sc.Name), + Name: fmt.Sprintf("ocs-operator-%s", sc.Name), Namespace: namespace, }, Spec: opv1a1.ClusterServiceVersionSpec{ diff --git a/pkg/deploy-manager/config.go b/pkg/deploy-manager/config.go index fc1bda5816..e804dacadb 100644 --- a/pkg/deploy-manager/config.go +++ b/pkg/deploy-manager/config.go @@ -24,6 +24,9 @@ var InstallNamespace string // DefaultStorageClusterName is the name of the storage cluster the test suite installs const DefaultStorageClusterName = "test-storagecluster" +// DefaultStorageClusterStorageSystemName is the name of the storage system owned by default storage cluster +const DefaultStorageClusterStorageSystemName = "test-storage-system" + // DefaultStorageClassRBD is the name of the ceph rbd storage class the test suite installs const DefaultStorageClassRBD = DefaultStorageClusterName + "-ceph-rbd" diff --git a/pkg/deploy-manager/storagecluster.go b/pkg/deploy-manager/storagecluster.go index f922e3485b..758ec689f4 100644 --- a/pkg/deploy-manager/storagecluster.go +++ b/pkg/deploy-manager/storagecluster.go @@ -80,6 +80,14 @@ func (t *DeployManager) DefaultStorageCluster() (*ocsv1.StorageCluster, error) { ObjectMeta: metav1.ObjectMeta{ Name: DefaultStorageClusterName, Namespace: InstallNamespace, + OwnerReferences: []metav1.OwnerReference{ + { + Name: DefaultStorageClusterStorageSystemName, + Kind: "StorageSystem", + APIVersion: "v1", + UID: types.UID(DefaultStorageClusterStorageSystemName), + }, + }, }, Spec: ocsv1.StorageClusterSpec{ ManageNodes: false,