@@ -79,8 +79,8 @@ type ReconcileMongoDbReplicaSet struct {
7979}
8080
8181type ReplicaSetDeploymentState struct {
82- LastAchievedSpec * mdbv1.MongoDbSpec `json:"lastAchievedSpec"`
83- MemberCountBefore int `json:"memberCountBefore"`
82+ LastAchievedSpec * mdbv1.MongoDbSpec `json:"lastAchievedSpec"`
83+ LastReconcileMemberCount int `json:"memberCountBefore"`
8484}
8585
8686var _ reconcile.Reconciler = & ReconcileMongoDbReplicaSet {}
@@ -125,8 +125,8 @@ func (r *ReplicaSetReconcilerHelper) readState() (*ReplicaSetDeploymentState, er
125125 memberCountBefore := r .resource .Status .Members
126126
127127 return & ReplicaSetDeploymentState {
128- LastAchievedSpec : lastAchievedSpec ,
129- MemberCountBefore : memberCountBefore ,
128+ LastAchievedSpec : lastAchievedSpec ,
129+ LastReconcileMemberCount : memberCountBefore ,
130130 }, nil
131131}
132132
@@ -277,7 +277,7 @@ func (r *ReplicaSetReconcilerHelper) Reconcile(ctx context.Context) (reconcile.R
277277 }
278278
279279 // Check if we need to prepare for scale-down
280- if scale .ReplicasThisReconciliation (rs ) < r .deploymentState .MemberCountBefore {
280+ if scale .ReplicasThisReconciliation (rs ) < r .deploymentState .LastReconcileMemberCount {
281281 if err := replicaset .PrepareScaleDownFromMongoDB (conn , rs , log ); err != nil {
282282 return r .updateStatus (ctx , workflow .Failed (xerrors .Errorf ("failed to prepare Replica Set for scaling down using Ops Manager: %w" , err )))
283283 }
@@ -300,7 +300,7 @@ func (r *ReplicaSetReconcilerHelper) Reconcile(ctx context.Context) (reconcile.R
300300 // See CLOUDP-189433 and CLOUDP-229222 for more details.
301301 if recovery .ShouldTriggerRecovery (rs .Status .Phase != mdbstatus .PhaseRunning , rs .Status .LastTransition ) {
302302 log .Warnf ("Triggering Automatic Recovery. The MongoDB resource %s/%s is in %s state since %s" , rs .Namespace , rs .Name , rs .Status .Phase , rs .Status .LastTransition )
303- automationConfigStatus := r .updateOmDeploymentRs (ctx , conn , r .deploymentState .MemberCountBefore , tlsCertPath , internalClusterCertPath , deploymentOpts , shouldMirrorKeyfileForMongot , true ).OnErrorPrepend ("failed to create/update (Ops Manager reconciliation phase):" )
303+ automationConfigStatus := r .updateOmDeploymentRs (ctx , conn , r .deploymentState .LastReconcileMemberCount , tlsCertPath , internalClusterCertPath , deploymentOpts , shouldMirrorKeyfileForMongot , true ).OnErrorPrepend ("failed to create/update (Ops Manager reconciliation phase):" )
304304 reconcileStatus := r .reconcileMemberResources (ctx , conn , projectConfig , deploymentOpts )
305305 if ! reconcileStatus .IsOK () {
306306 log .Errorf ("Recovery failed because of reconcile errors, %v" , reconcileStatus )
@@ -314,7 +314,7 @@ func (r *ReplicaSetReconcilerHelper) Reconcile(ctx context.Context) (reconcile.R
314314 publishAutomationConfigFirst := publishAutomationConfigFirstRS (ctx , reconciler .client , * rs , r .deploymentState .LastAchievedSpec , deploymentOpts .currentAgentAuthMode , projectConfig .SSLMMSCAConfigMap , log )
315315 status := workflow .RunInGivenOrder (publishAutomationConfigFirst ,
316316 func () workflow.Status {
317- return r .updateOmDeploymentRs (ctx , conn , r .deploymentState .MemberCountBefore , tlsCertPath , internalClusterCertPath , deploymentOpts , shouldMirrorKeyfileForMongot , false ).OnErrorPrepend ("failed to create/update (Ops Manager reconciliation phase):" )
317+ return r .updateOmDeploymentRs (ctx , conn , r .deploymentState .LastReconcileMemberCount , tlsCertPath , internalClusterCertPath , deploymentOpts , shouldMirrorKeyfileForMongot , false ).OnErrorPrepend ("failed to create/update (Ops Manager reconciliation phase):" )
318318 },
319319 func () workflow.Status {
320320 return r .reconcileMemberResources (ctx , conn , projectConfig , deploymentOpts )
0 commit comments