@@ -19,6 +19,7 @@ import (
1919 "context"
2020 "errors"
2121 "fmt"
22+ "reflect"
2223 "regexp"
2324 "sort"
2425 "strconv"
@@ -90,6 +91,28 @@ func ApplyIndexerClusterManager(ctx context.Context, client splcommon.Controller
9091 return result , err
9192 }
9293
94+ // If bus config is updated
95+ if cr .Spec .BusConfigurationRef .Name != "" {
96+ if ! reflect .DeepEqual (cr .Status .BusConfiguration , busConfig .Spec ) && cr .Status .Phase == enterpriseApi .PhaseReady {
97+ namespaceScopedSecret , err := ApplySplunkConfig (ctx , client , cr , cr .Spec .CommonSplunkSpec , SplunkIngestor )
98+ if err != nil {
99+ scopedLog .Error (err , "create or update general config failed" , "error" , err .Error ())
100+ eventPublisher .Warning (ctx , "ApplySplunkConfig" , fmt .Sprintf ("create or update general config failed with error %s" , err .Error ()))
101+ return result , err
102+ }
103+
104+ mgr := newIndexerClusterPodManager (scopedLog , cr , namespaceScopedSecret , splclient .NewSplunkClient )
105+
106+ err = mgr .handlePullBusChange (ctx , cr , busConfig , client )
107+ if err != nil {
108+ scopedLog .Error (err , "Failed to update conf file for Bus/Pipeline config change after pod creation" )
109+ return result , err
110+ }
111+
112+ cr .Status .BusConfiguration = busConfig .Spec
113+ }
114+ }
115+
93116 // updates status after function completes
94117 cr .Status .ClusterManagerPhase = enterpriseApi .PhaseError
95118 cr .Status .Replicas = cr .Spec .Replicas
@@ -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 )
@@ -367,6 +381,28 @@ func ApplyIndexerCluster(ctx context.Context, client splcommon.ControllerClient,
367381 return result , err
368382 }
369383
384+ // If bus config is updated
385+ if cr .Spec .BusConfigurationRef .Name != "" {
386+ if ! reflect .DeepEqual (cr .Status .BusConfiguration , busConfig .Spec ) && cr .Status .Phase == enterpriseApi .PhaseReady {
387+ namespaceScopedSecret , err := ApplySplunkConfig (ctx , client , cr , cr .Spec .CommonSplunkSpec , SplunkIngestor )
388+ if err != nil {
389+ scopedLog .Error (err , "create or update general config failed" , "error" , err .Error ())
390+ eventPublisher .Warning (ctx , "ApplySplunkConfig" , fmt .Sprintf ("create or update general config failed with error %s" , err .Error ()))
391+ return result , err
392+ }
393+
394+ mgr := newIndexerClusterPodManager (scopedLog , cr , namespaceScopedSecret , splclient .NewSplunkClient )
395+
396+ err = mgr .handlePullBusChange (ctx , cr , busConfig , client )
397+ if err != nil {
398+ scopedLog .Error (err , "Failed to update conf file for Bus/Pipeline config change after pod creation" )
399+ return result , err
400+ }
401+
402+ cr .Status .BusConfiguration = busConfig .Spec
403+ }
404+ }
405+
370406 // updates status after function completes
371407 cr .Status .Phase = enterpriseApi .PhaseError
372408 cr .Status .ClusterMasterPhase = enterpriseApi .PhaseError
@@ -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