@@ -248,38 +248,11 @@ func (r *CommonServiceReconciler) ReconcileMasterCR(ctx context.Context, instanc
248248 return ctrl.Result {}, statusErr
249249 }
250250
251- // Apply new configs to CommonService CR
252- cs := util .NewUnstructured ("operator.ibm.com" , "CommonService" , "v3" )
253- if statusErr = r .Bootstrap .Client .Get (ctx , types.NamespacedName {Name : instance .Name , Namespace : instance .Namespace }, cs ); statusErr != nil {
254- klog .Errorf ("Fail to reconcile %s/%s: %v" , instance .Namespace , instance .Name , statusErr )
255- return ctrl.Result {}, statusErr
256- }
257- // Set "Pending" condition and "Updating" for phase when config CS CR
258- instance .SetPendingCondition (constant .MasterCR , apiv3 .ConditionTypeReconciling , corev1 .ConditionTrue , apiv3 .ConditionReasonConfig , apiv3 .ConditionMessageConfig )
259- instance .Status .Phase = apiv3 .CRUpdating
260- newConfigs , serviceControllerMapping , statusErr := r .getNewConfigs (cs )
261- if statusErr != nil {
262- klog .Errorf ("Fail to reconcile %s/%s: %v" , instance .Namespace , instance .Name , statusErr )
263- instance .SetErrorCondition (constant .MasterCR , apiv3 .ConditionTypeError , corev1 .ConditionTrue , apiv3 .ConditionReasonError , statusErr .Error ())
264- instance .Status .Phase = apiv3 .CRFailed
265- }
266-
267- if statusErr = r .Client .Status ().Update (ctx , instance ); statusErr != nil {
268- klog .Errorf ("Fail to update %s/%s: %v" , instance .Namespace , instance .Name , statusErr )
269- return ctrl.Result {}, statusErr
270- }
251+ // OperandConfig already created with complete configuration
252+ // in InitResources, no need for second updateOperandConfig call
253+ klog .Info ("OperandConfig created with complete configuration" )
271254
272255 var isEqual bool
273- if isEqual , statusErr = r .updateOperandConfig (ctx , newConfigs , serviceControllerMapping ); statusErr != nil {
274- if statusErr := r .updatePhase (ctx , instance , apiv3 .CRFailed ); statusErr != nil {
275- klog .Error (statusErr )
276- }
277- klog .Errorf ("Fail to reconcile %s/%s: %v" , instance .Namespace , instance .Name , statusErr )
278- return ctrl.Result {}, statusErr
279- } else if isEqual {
280- r .Recorder .Event (instance , corev1 .EventTypeNormal , "Noeffect" , fmt .Sprintf ("No update, resource sizings in the OperandConfig %s/%s are larger than the profile from CommonService CR %s/%s" , r .Bootstrap .CSData .OperatorNs , "common-service" , instance .Namespace , instance .Name ))
281- }
282-
283256 if isEqual , statusErr = r .updateOperatorConfig (ctx , instance .Spec .OperatorConfigs ); statusErr != nil {
284257 if statusErr := r .updatePhase (ctx , instance , apiv3 .CRFailed ); statusErr != nil {
285258 klog .Error (statusErr )
@@ -371,11 +344,6 @@ func (r *CommonServiceReconciler) ReconcileGeneralCR(ctx context.Context, instan
371344 return ctrl.Result {}, err
372345 }
373346
374- cs := util .NewUnstructured ("operator.ibm.com" , "CommonService" , "v3" )
375- if err := r .Bootstrap .Client .Get (ctx , types.NamespacedName {Name : instance .Name , Namespace : instance .Namespace }, cs ); err != nil {
376- klog .Errorf ("Fail to reconcile %s/%s: %v" , instance .Namespace , instance .Name , err )
377- return ctrl.Result {}, err
378- }
379347 // Generate Issuer and Certificate CR
380348 if err := r .Bootstrap .DeployCertManagerCR (); err != nil {
381349 klog .Errorf ("Failed to deploy cert manager CRs: %v" , err )
@@ -386,7 +354,8 @@ func (r *CommonServiceReconciler) ReconcileGeneralCR(ctx context.Context, instan
386354 return ctrl.Result {}, err
387355 }
388356
389- newConfigs , serviceControllerMapping , err := r .getNewConfigs (cs )
357+ // Extract configurations using new extractor for subsequent updates
358+ newConfigs , serviceControllerMapping , err := ExtractCommonServiceConfigs (instance , r .Bootstrap .CSData .ServicesNs )
390359 if err != nil {
391360 if err := r .updatePhase (ctx , instance , apiv3 .CRFailed ); err != nil {
392361 klog .Error (err )
@@ -395,6 +364,7 @@ func (r *CommonServiceReconciler) ReconcileGeneralCR(ctx context.Context, instan
395364 return ctrl.Result {}, err
396365 }
397366
367+ // Update OperandConfig (single update for subsequent reconciliations)
398368 isEqual , err := r .updateOperandConfig (ctx , newConfigs , serviceControllerMapping )
399369 if err != nil {
400370 if err := r .updatePhase (ctx , instance , apiv3 .CRFailed ); err != nil {
@@ -557,6 +527,10 @@ func isNonNoopOperandReconcile(operandRegistry *odlm.OperandRegistry) bool {
557527}
558528
559529func (r * CommonServiceReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
530+ // Set up configuration merger for single-stage OperandConfig creation
531+ // This injects the merge logic into bootstrap without creating import cycles
532+ bootstrap .SetConfigMerger (CreateMergerFunc (r ))
533+ klog .Info ("Configuration merger initialized for single-stage OperandConfig creation" )
560534
561535 controller := ctrl .NewControllerManagedBy (mgr ).
562536 // AnnotationChangedPredicate is intended to be used in conjunction with the GenerationChangedPredicate
0 commit comments