From 380cfa1b630081c318bd0d7e588638af8ca97872 Mon Sep 17 00:00:00 2001 From: Mikalai Radchuk <509198+m1kola@users.noreply.github.com> Date: Fri, 21 Feb 2025 15:20:17 +0100 Subject: [PATCH] Remove annotations arg from GetMongoDBVersion --- api/v1/mongodbcommunity_types.go | 4 ++-- controllers/construct/mongodbstatefulset.go | 2 +- controllers/replica_set_controller.go | 4 ++-- test/e2e/mongodbtests/mongodbtests.go | 2 +- test/e2e/replica_set_recovery/replica_set_recovery_test.go | 2 +- test/e2e/replica_set_scale/replica_set_scaling_test.go | 2 +- .../e2e/replica_set_scale_down/replica_set_scale_down_test.go | 2 +- test/e2e/statefulset_delete/statefulset_delete_test.go | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/api/v1/mongodbcommunity_types.go b/api/v1/mongodbcommunity_types.go index f1e7f8710..e3455ea21 100644 --- a/api/v1/mongodbcommunity_types.go +++ b/api/v1/mongodbcommunity_types.go @@ -1114,7 +1114,7 @@ func (m *MongoDBCommunity) CurrentArbiters() int { return m.Status.CurrentStatefulSetArbitersReplicas } -func (m *MongoDBCommunity) GetMongoDBVersion(map[string]string) string { +func (m *MongoDBCommunity) GetMongoDBVersion() string { return m.Spec.Version } @@ -1122,7 +1122,7 @@ func (m *MongoDBCommunity) GetMongoDBVersion(map[string]string) string { // Here it's the same as GetMongoDBVersion, but a different name is used in order to make // the usage clearer in enterprise (where it's a method of OpsManager but is used for the AppDB) func (m *MongoDBCommunity) GetMongoDBVersionForAnnotation() string { - return m.GetMongoDBVersion(nil) + return m.GetMongoDBVersion() } func (m *MongoDBCommunity) StatefulSetReplicasThisReconciliation() int { diff --git a/controllers/construct/mongodbstatefulset.go b/controllers/construct/mongodbstatefulset.go index cec2e5be7..08a33939a 100644 --- a/controllers/construct/mongodbstatefulset.go +++ b/controllers/construct/mongodbstatefulset.go @@ -95,7 +95,7 @@ type MongoDBStatefulSetOwner interface { // GetNamespace returns the namespace the resource is defined in. GetNamespace() string // GetMongoDBVersion returns the version of MongoDB to be used for this resource. - GetMongoDBVersion(annotations map[string]string) string + GetMongoDBVersion() string // AutomationConfigSecretName returns the name of the secret which will contain the automation config. AutomationConfigSecretName() string // GetUpdateStrategyType returns the UpdateStrategyType of the statefulset. diff --git a/controllers/replica_set_controller.go b/controllers/replica_set_controller.go index d7f2ee65d..5b3594812 100644 --- a/controllers/replica_set_controller.go +++ b/controllers/replica_set_controller.go @@ -226,7 +226,7 @@ func (r ReplicaSetReconciler) Reconcile(ctx context.Context, request reconcile.R withMongoDBArbiters(mdb.AutomationConfigArbitersThisReconciliation()). withMessage(None, ""). withRunningPhase(). - withVersion(mdb.GetMongoDBVersion(nil))) + withVersion(mdb.GetMongoDBVersion())) if err != nil { r.log.Errorf("Error updating the status of the MongoDB resource: %s", err) return res, err @@ -491,7 +491,7 @@ func (r *ReplicaSetReconciler) createOrUpdateStatefulSet(ctx context.Context, md return fmt.Errorf("error getting StatefulSet: %s", err) } - mongodbImage := getMongoDBImage(r.mongodbRepoUrl, r.mongodbImage, r.mongodbImageType, mdb.GetMongoDBVersion(nil)) + mongodbImage := getMongoDBImage(r.mongodbRepoUrl, r.mongodbImage, r.mongodbImageType, mdb.GetMongoDBVersion()) buildStatefulSetModificationFunction(mdb, mongodbImage, r.agentImage, r.versionUpgradeHookImage, r.readinessProbeImage)(&set) if isArbiter { buildArbitersModificationFunction(mdb)(&set) diff --git a/test/e2e/mongodbtests/mongodbtests.go b/test/e2e/mongodbtests/mongodbtests.go index aad73a450..a7bbf30df 100644 --- a/test/e2e/mongodbtests/mongodbtests.go +++ b/test/e2e/mongodbtests/mongodbtests.go @@ -503,7 +503,7 @@ func BasicFunctionality(ctx context.Context, mdb *mdbv1.MongoDBCommunity, skipSt t.Run("Test Status Was Updated", Status(ctx, mdb, mdbv1.MongoDBCommunityStatus{ MongoURI: mdb.MongoURI(""), Phase: mdbv1.Running, - Version: mdb.GetMongoDBVersion(nil), + Version: mdb.GetMongoDBVersion(), CurrentMongoDBMembers: mdb.Spec.Members, CurrentStatefulSetReplicas: mdb.Spec.Members, })) diff --git a/test/e2e/replica_set_recovery/replica_set_recovery_test.go b/test/e2e/replica_set_recovery/replica_set_recovery_test.go index a6ab6f7a0..91c9426b7 100644 --- a/test/e2e/replica_set_recovery/replica_set_recovery_test.go +++ b/test/e2e/replica_set_recovery/replica_set_recovery_test.go @@ -59,7 +59,7 @@ func TestReplicaSetRecovery(t *testing.T) { t.Run("Test Status Was Updated", mongodbtests.Status(ctx, &mdb, mdbv1.MongoDBCommunityStatus{ MongoURI: mdb.MongoURI(""), Phase: mdbv1.Running, - Version: mdb.GetMongoDBVersion(nil), + Version: mdb.GetMongoDBVersion(), CurrentMongoDBMembers: 3, CurrentStatefulSetReplicas: 3, })) diff --git a/test/e2e/replica_set_scale/replica_set_scaling_test.go b/test/e2e/replica_set_scale/replica_set_scaling_test.go index ee0fe2f19..0361ba9f0 100644 --- a/test/e2e/replica_set_scale/replica_set_scaling_test.go +++ b/test/e2e/replica_set_scale/replica_set_scaling_test.go @@ -54,7 +54,7 @@ func TestReplicaSetScaleUp(t *testing.T) { t.Run("Test Status Was Updated", mongodbtests.Status(ctx, &mdb, mdbv1.MongoDBCommunityStatus{ MongoURI: mdb.MongoURI(""), Phase: mdbv1.Running, - Version: mdb.GetMongoDBVersion(nil), + Version: mdb.GetMongoDBVersion(), CurrentMongoDBMembers: 5, CurrentStatefulSetReplicas: 5, })) diff --git a/test/e2e/replica_set_scale_down/replica_set_scale_down_test.go b/test/e2e/replica_set_scale_down/replica_set_scale_down_test.go index 529738712..fd03fdafc 100644 --- a/test/e2e/replica_set_scale_down/replica_set_scale_down_test.go +++ b/test/e2e/replica_set_scale_down/replica_set_scale_down_test.go @@ -57,7 +57,7 @@ func TestReplicaSetScaleDown(t *testing.T) { t.Run("Test Status Was Updated", mongodbtests.Status(ctx, &mdb, mdbv1.MongoDBCommunityStatus{ MongoURI: mdb.MongoURI(""), Phase: mdbv1.Running, - Version: mdb.GetMongoDBVersion(nil), + Version: mdb.GetMongoDBVersion(), CurrentMongoDBMembers: 1, CurrentStatefulSetReplicas: 1, })) diff --git a/test/e2e/statefulset_delete/statefulset_delete_test.go b/test/e2e/statefulset_delete/statefulset_delete_test.go index 686d50071..3117109e6 100644 --- a/test/e2e/statefulset_delete/statefulset_delete_test.go +++ b/test/e2e/statefulset_delete/statefulset_delete_test.go @@ -42,7 +42,7 @@ func TestStatefulSetDelete(t *testing.T) { t.Run("Test Status Was Updated", mongodbtests.Status(ctx, &mdb, mdbv1.MongoDBCommunityStatus{ MongoURI: mdb.MongoURI(""), Phase: mdbv1.Running, - Version: mdb.GetMongoDBVersion(nil), + Version: mdb.GetMongoDBVersion(), CurrentMongoDBMembers: mdb.DesiredReplicas(), })) })