@@ -19,6 +19,7 @@ import (
1919 "context"
2020 "errors"
2121 "fmt"
22+ "reflect"
2223 "regexp"
2324 "sort"
2425 "strconv"
@@ -104,6 +105,28 @@ func ApplyIndexerClusterManager(ctx context.Context, client splcommon.Controller
104105 cr .Status .IdxcPasswordChangedSecrets = make (map [string ]bool )
105106 }
106107
108+ // If bus config is updated
109+ if cr .Spec .BusConfigurationRef .Name != "" {
110+ if ! reflect .DeepEqual (cr .Status .BusConfiguration , busConfig .Spec ) && cr .Status .Phase == enterpriseApi .PhaseReady {
111+ namespaceScopedSecret , err := ApplySplunkConfig (ctx , client , cr , cr .Spec .CommonSplunkSpec , SplunkIngestor )
112+ if err != nil {
113+ scopedLog .Error (err , "create or update general config failed" , "error" , err .Error ())
114+ eventPublisher .Warning (ctx , "ApplySplunkConfig" , fmt .Sprintf ("create or update general config failed with error %s" , err .Error ()))
115+ return result , err
116+ }
117+
118+ mgr := newIndexerClusterPodManager (scopedLog , cr , namespaceScopedSecret , splclient .NewSplunkClient )
119+
120+ err = mgr .handlePullBusChange (ctx , cr , busConfig , client )
121+ if err != nil {
122+ scopedLog .Error (err , "Failed to update conf file for Bus/Pipeline config change after pod creation" )
123+ return result , err
124+ }
125+
126+ cr .Status .BusConfiguration = busConfig .Spec
127+ }
128+ }
129+
107130 // create or update general config resources
108131 namespaceScopedSecret , err := ApplySplunkConfig (ctx , client , cr , cr .Spec .CommonSplunkSpec , SplunkIndexer )
109132 if err != nil {
@@ -257,15 +280,6 @@ func ApplyIndexerClusterManager(ctx context.Context, client splcommon.Controller
257280
258281 // no need to requeue if everything is ready
259282 if cr .Status .Phase == enterpriseApi .PhaseReady {
260- if cr .Spec .BusConfigurationRef .Name != "" {
261- err = mgr .handlePullBusChange (ctx , cr , busConfig , client )
262- if err != nil {
263- scopedLog .Error (err , "Failed to update conf file for Bus/Pipeline config change after pod creation" )
264- return result , err
265- }
266- }
267- cr .Status .BusConfiguration = busConfig .Spec
268-
269283 //update MC
270284 //Retrieve monitoring console ref from CM Spec
271285 cmMonitoringConsoleConfigRef , err := RetrieveCMSpec (ctx , client , cr )
@@ -382,6 +396,28 @@ func ApplyIndexerCluster(ctx context.Context, client splcommon.ControllerClient,
382396 cr .Status .IdxcPasswordChangedSecrets = make (map [string ]bool )
383397 }
384398
399+ // If bus config is updated
400+ if cr .Spec .BusConfigurationRef .Name != "" {
401+ if ! reflect .DeepEqual (cr .Status .BusConfiguration , busConfig .Spec ) && cr .Status .Phase == enterpriseApi .PhaseReady {
402+ namespaceScopedSecret , err := ApplySplunkConfig (ctx , client , cr , cr .Spec .CommonSplunkSpec , SplunkIngestor )
403+ if err != nil {
404+ scopedLog .Error (err , "create or update general config failed" , "error" , err .Error ())
405+ eventPublisher .Warning (ctx , "ApplySplunkConfig" , fmt .Sprintf ("create or update general config failed with error %s" , err .Error ()))
406+ return result , err
407+ }
408+
409+ mgr := newIndexerClusterPodManager (scopedLog , cr , namespaceScopedSecret , splclient .NewSplunkClient )
410+
411+ err = mgr .handlePullBusChange (ctx , cr , busConfig , client )
412+ if err != nil {
413+ scopedLog .Error (err , "Failed to update conf file for Bus/Pipeline config change after pod creation" )
414+ return result , err
415+ }
416+
417+ cr .Status .BusConfiguration = busConfig .Spec
418+ }
419+ }
420+
385421 // Update the CR Status
386422 defer updateCRStatus (ctx , client , cr , & err )
387423
@@ -538,29 +574,6 @@ func ApplyIndexerCluster(ctx context.Context, client splcommon.ControllerClient,
538574
539575 // no need to requeue if everything is ready
540576 if cr .Status .Phase == enterpriseApi .PhaseReady {
541- if cr .Spec .BusConfigurationRef .Name != "" {
542- busConfig := enterpriseApi.BusConfiguration {}
543- ns := cr .GetNamespace ()
544- if cr .Spec .BusConfigurationRef .Namespace != "" {
545- ns = cr .Spec .BusConfigurationRef .Namespace
546- }
547- err := client .Get (context .Background (), types.NamespacedName {
548- Name : cr .Spec .BusConfigurationRef .Name ,
549- Namespace : ns ,
550- }, & busConfig )
551- if err != nil {
552- return result , err
553- }
554-
555- err = mgr .handlePullBusChange (ctx , cr , busConfig , client )
556- if err != nil {
557- scopedLog .Error (err , "Failed to update conf file for Bus/Pipeline config change after pod creation" )
558- return result , err
559- }
560- }
561-
562- cr .Status .BusConfiguration = busConfig .Spec
563-
564577 //update MC
565578 //Retrieve monitoring console ref from CM Spec
566579 cmMonitoringConsoleConfigRef , err := RetrieveCMSpec (ctx , client , cr )
0 commit comments