@@ -171,18 +171,23 @@ func (r *ReconcileMongoDbMultiReplicaSet) Reconcile(ctx context.Context, request
171
171
return r .updateStatus (ctx , & mrs , workflow .Failed (err ), log )
172
172
}
173
173
174
+ certSecretName := mrs .Spec .GetSecurity ().MemberCertificateSecretName (mrs .Name )
175
+ internalClusterCertSecretName := mrs .Spec .GetSecurity ().InternalClusterAuthSecretName (mrs .Name )
176
+ certHash := enterprisepem .ReadHashFromSecret (ctx , r .SecretClient , mrs .Namespace , certSecretName , "" , log )
177
+ internalClusterCertHash := enterprisepem .ReadHashFromSecret (ctx , r .SecretClient , mrs .Namespace , internalClusterCertSecretName , "" , log )
178
+
174
179
// If tls is enabled we need to configure the "processes" array in opsManager/Cloud Manager with the
175
- // correct certFilePath , with the new tls design, this path has the certHash in it(so that cert can be rotated
180
+ // correct certPath , with the new tls design, this path has the certHash in it(so that cert can be rotated
176
181
// without pod restart).
177
- certificateFileName := ""
178
- internalClusterPath := ""
182
+ certPath := ""
183
+ internalClusterCertPath := ""
179
184
if mrs .Spec .Security .IsTLSEnabled () {
180
- if hash := firstStatefulSet . Annotations [ util . InternalCertAnnotationKey ]; hash != "" {
181
- internalClusterPath = fmt .Sprintf ("%s%s" , util .InternalClusterAuthMountPath , hash )
185
+ if certHash != "" {
186
+ internalClusterCertPath = fmt .Sprintf ("%s%s" , util .InternalClusterAuthMountPath , certHash )
182
187
}
183
188
184
- if certificateHash := firstStatefulSet . Annotations [ certs . CertHashAnnotationKey ]; certificateHash != "" {
185
- certificateFileName = fmt .Sprintf ("%s/%s" , util .TLSCertMountPath , certificateHash )
189
+ if internalClusterCertHash != "" {
190
+ certPath = fmt .Sprintf ("%s/%s" , util .TLSCertMountPath , internalClusterCertHash )
186
191
}
187
192
}
188
193
@@ -191,7 +196,7 @@ func (r *ReconcileMongoDbMultiReplicaSet) Reconcile(ctx context.Context, request
191
196
// See CLOUDP-189433 and CLOUDP-229222 for more details.
192
197
if recovery .ShouldTriggerRecovery (mrs .Status .Phase != mdbstatus .PhaseRunning , mrs .Status .LastTransition ) {
193
198
log .Warnf ("Triggering Automatic Recovery. The MongoDB resource %s/%s is in %s state since %s" , mrs .Namespace , mrs .Name , mrs .Status .Phase , mrs .Status .LastTransition )
194
- automationConfigError := r .updateOmDeploymentRs (ctx , conn , mrs , true , log )
199
+ automationConfigError := r .updateOmDeploymentRs (ctx , conn , mrs , certPath , internalClusterCertPath , true , log )
195
200
reconcileStatus := r .reconcileMemberResources (ctx , & mrs , log , conn , projectConfig )
196
201
if ! reconcileStatus .IsOK () {
197
202
log .Errorf ("Recovery failed because of reconcile errors, %v" , reconcileStatus )
@@ -203,7 +208,7 @@ func (r *ReconcileMongoDbMultiReplicaSet) Reconcile(ctx context.Context, request
203
208
204
209
status := workflow .RunInGivenOrder (publishAutomationConfigFirst ,
205
210
func () workflow.Status {
206
- if err := r .updateOmDeploymentRs (ctx , conn , mrs , false , log ); err != nil {
211
+ if err := r .updateOmDeploymentRs (ctx , conn , mrs , certPath , internalClusterCertPath , false , log ); err != nil {
207
212
return workflow .Failed (err )
208
213
}
209
214
return workflow .OK ()
@@ -692,7 +697,7 @@ func (r *ReconcileMongoDbMultiReplicaSet) saveLastAchievedSpec(ctx context.Conte
692
697
693
698
// updateOmDeploymentRs performs OM registration operation for the replicaset. So the changes will be finally propagated
694
699
// to automation agents in containers
695
- func (r * ReconcileMongoDbMultiReplicaSet ) updateOmDeploymentRs (ctx context.Context , conn om.Connection , mrs mdbmultiv1.MongoDBMultiCluster , isRecovering bool , log * zap.SugaredLogger ) error {
700
+ func (r * ReconcileMongoDbMultiReplicaSet ) updateOmDeploymentRs (ctx context.Context , conn om.Connection , mrs mdbmultiv1.MongoDBMultiCluster , certPath , internalClusterCertPath string , isRecovering bool , log * zap.SugaredLogger ) error {
696
701
reachableHostnames := make ([]string , 0 )
697
702
698
703
clusterSpecList , err := mrs .GetClusterSpecItems ()
@@ -740,7 +745,7 @@ func (r *ReconcileMongoDbMultiReplicaSet) updateOmDeploymentRs(ctx context.Conte
740
745
}
741
746
log .Debugf ("Existing process Ids: %+v" , processIds )
742
747
743
- processes , err := process .CreateMongodProcessesWithLimitMulti (r .imageUrls [mcoConstruct .MongodbImageEnv ], r .forceEnterprise , mrs , certificateFileName )
748
+ processes , err := process .CreateMongodProcessesWithLimitMulti (r .imageUrls [mcoConstruct .MongodbImageEnv ], r .forceEnterprise , mrs , certPath )
744
749
if err != nil && ! isRecovering {
745
750
return err
746
751
}
@@ -753,7 +758,7 @@ func (r *ReconcileMongoDbMultiReplicaSet) updateOmDeploymentRs(ctx context.Conte
753
758
caFilePath := fmt .Sprintf ("%s/ca-pem" , util .TLSCaMountPath )
754
759
755
760
agentCertSecretName := mrs .GetSecurity ().AgentClientCertificateSecretName (mrs .GetName ())
756
- status , additionalReconciliationRequired := r .updateOmAuthentication (ctx , conn , rs .GetProcessNames (), & mrs , agentCertSecretName , caFilePath , internalClusterPath , isRecovering , log )
761
+ status , additionalReconciliationRequired := r .updateOmAuthentication (ctx , conn , rs .GetProcessNames (), & mrs , agentCertSecretName , caFilePath , internalClusterCertPath , isRecovering , log )
757
762
if ! status .IsOK () && ! isRecovering {
758
763
return xerrors .Errorf ("failed to enable Authentication for MongoDB Multi Replicaset" )
759
764
}
@@ -762,7 +767,7 @@ func (r *ReconcileMongoDbMultiReplicaSet) updateOmDeploymentRs(ctx context.Conte
762
767
763
768
err = conn .ReadUpdateDeployment (
764
769
func (d om.Deployment ) error {
765
- return ReconcileReplicaSetAC (ctx , d , mrs .Spec .DbCommonSpec , lastMongodbConfig , mrs .Name , rs , caFilePath , internalClusterPath , nil , log )
770
+ return ReconcileReplicaSetAC (ctx , d , mrs .Spec .DbCommonSpec , lastMongodbConfig , mrs .Name , rs , caFilePath , internalClusterCertPath , nil , log )
766
771
},
767
772
log ,
768
773
)
0 commit comments