@@ -198,11 +198,13 @@ func (r *ReconcileMongoDbReplicaSet) Reconcile(ctx context.Context, request reco
198
198
}
199
199
}
200
200
201
+ internalClusterCertHash := enterprisepem .ReadHashFromSecret (ctx , r .SecretClient , rs .Namespace , rsCertsConfig .InternalClusterSecretName , databaseSecretPath , log )
202
+
201
203
rsConfig := construct .ReplicaSetOptions (
202
204
PodEnvVars (newPodVars (conn , projectConfig , rs .Spec .LogLevel )),
203
205
CurrentAgentAuthMechanism (currentAgentAuthMode ),
204
206
CertificateHash (enterprisepem .ReadHashFromSecret (ctx , r .SecretClient , rs .Namespace , rsCertsConfig .CertSecretName , databaseSecretPath , log )),
205
- InternalClusterHash (enterprisepem . ReadHashFromSecret ( ctx , r . SecretClient , rs . Namespace , rsCertsConfig . InternalClusterSecretName , databaseSecretPath , log ) ),
207
+ InternalClusterHash (internalClusterCertHash ),
206
208
PrometheusTLSCertHash (prometheusCertHash ),
207
209
WithVaultConfig (vaultConfig ),
208
210
WithLabels (rs .Labels ),
@@ -233,12 +235,17 @@ func (r *ReconcileMongoDbReplicaSet) Reconcile(ctx context.Context, request reco
233
235
agentCertSecretSelector := rs .GetSecurity ().AgentClientCertificateSecretName (rs .Name )
234
236
agentCertSecretSelector .Name += certs .OperatorGeneratedCertSuffix
235
237
238
+ internalClusterPath := ""
239
+ if internalClusterCertHash != "" {
240
+ internalClusterPath = fmt .Sprintf ("%s%s" , util .InternalClusterAuthMountPath , internalClusterCertHash )
241
+ }
242
+
236
243
// Recovery prevents some deadlocks that can occur during reconciliation, e.g. the setting of an incorrect automation
237
244
// configuration and a subsequent attempt to overwrite it later, the operator would be stuck in Pending phase.
238
245
// See CLOUDP-189433 and CLOUDP-229222 for more details.
239
246
if recovery .ShouldTriggerRecovery (rs .Status .Phase != mdbstatus .PhaseRunning , rs .Status .LastTransition ) {
240
247
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 )
241
- automationConfigStatus := r .updateOmDeploymentRs (ctx , conn , rs .Status .Members , rs , sts , log , caFilePath , agentCertSecretSelector , prometheusCertHash , true ).OnErrorPrepend ("Failed to create/update (Ops Manager reconciliation phase):" )
248
+ automationConfigStatus := r .updateOmDeploymentRs (ctx , conn , rs .Status .Members , rs , sts , log , caFilePath , internalClusterPath , agentCertSecretSelector , prometheusCertHash , true ).OnErrorPrepend ("Failed to create/update (Ops Manager reconciliation phase):" )
242
249
deploymentError := create .DatabaseInKubernetes (ctx , r .client , * rs , sts , rsConfig , log )
243
250
if deploymentError != nil {
244
251
log .Errorf ("Recovery failed because of deployment errors, %w" , deploymentError )
@@ -254,7 +261,7 @@ func (r *ReconcileMongoDbReplicaSet) Reconcile(ctx context.Context, request reco
254
261
}
255
262
status = workflow .RunInGivenOrder (publishAutomationConfigFirst (ctx , r .client , * rs , lastSpec , rsConfig , log ),
256
263
func () workflow.Status {
257
- return r .updateOmDeploymentRs (ctx , conn , rs .Status .Members , rs , sts , log , caFilePath , agentCertSecretSelector , prometheusCertHash , false ).OnErrorPrepend ("Failed to create/update (Ops Manager reconciliation phase):" )
264
+ return r .updateOmDeploymentRs (ctx , conn , rs .Status .Members , rs , sts , log , caFilePath , internalClusterPath , agentCertSecretSelector , prometheusCertHash , false ).OnErrorPrepend ("Failed to create/update (Ops Manager reconciliation phase):" )
258
265
},
259
266
func () workflow.Status {
260
267
workflowStatus := create .HandlePVCResize (ctx , r .client , & sts , log )
@@ -415,7 +422,7 @@ func AddReplicaSetController(ctx context.Context, mgr manager.Manager, imageUrls
415
422
416
423
// updateOmDeploymentRs performs OM registration operation for the replicaset. So the changes will be finally propagated
417
424
// to automation agents in containers
418
- func (r * ReconcileMongoDbReplicaSet ) updateOmDeploymentRs (ctx context.Context , conn om.Connection , membersNumberBefore int , rs * mdbv1.MongoDB , set appsv1.StatefulSet , log * zap.SugaredLogger , caFilePath string , agentCertSecretSelector corev1.SecretKeySelector , prometheusCertHash string , isRecovering bool ) workflow.Status {
425
+ func (r * ReconcileMongoDbReplicaSet ) updateOmDeploymentRs (ctx context.Context , conn om.Connection , membersNumberBefore int , rs * mdbv1.MongoDB , set appsv1.StatefulSet , log * zap.SugaredLogger , caFilePath , internalClusterPath string , agentCertSecretSelector corev1.SecretKeySelector , prometheusCertHash string , isRecovering bool ) workflow.Status {
419
426
log .Debug ("Entering UpdateOMDeployments" )
420
427
// Only "concrete" RS members should be observed
421
428
// - if scaling down, let's observe only members that will remain after scale-down operation
@@ -444,11 +451,6 @@ func (r *ReconcileMongoDbReplicaSet) updateOmDeploymentRs(ctx context.Context, c
444
451
replicaSet := replicaset .BuildFromStatefulSetWithReplicas (r .imageUrls [mcoConstruct .MongodbImageEnv ], r .forceEnterprise , set , rs .GetSpec (), updatedMembers , rs .CalculateFeatureCompatibilityVersion ())
445
452
processNames := replicaSet .GetProcessNames ()
446
453
447
- internalClusterPath := ""
448
- if hash := set .Annotations [util .InternalCertAnnotationKey ]; hash != "" {
449
- internalClusterPath = fmt .Sprintf ("%s%s" , util .InternalClusterAuthMountPath , hash )
450
- }
451
-
452
454
status , additionalReconciliationRequired := r .updateOmAuthentication (ctx , conn , processNames , rs , agentCertSecretSelector , caFilePath , internalClusterPath , isRecovering , log )
453
455
if ! status .IsOK () && ! isRecovering {
454
456
return status
0 commit comments