Skip to content

Commit a5f94c0

Browse files
committed
CSPL-4360 Fix errors with failing validation on status
1 parent e4e083a commit a5f94c0

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

pkg/splunk/enterprise/indexercluster.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ func ApplyIndexerClusterManager(ctx context.Context, client splcommon.Controller
7777

7878
// updates status after function completes
7979
cr.Status.ClusterManagerPhase = enterpriseApi.PhaseError
80-
if cr.Status.Replicas < cr.Spec.Replicas {
81-
cr.Status.Bus = &enterpriseApi.BusSpec{}
82-
cr.Status.LargeMessageStore = &enterpriseApi.LargeMessageStoreSpec{}
83-
}
8480
cr.Status.Replicas = cr.Spec.Replicas
8581
cr.Status.Selector = fmt.Sprintf("app.kubernetes.io/instance=splunk-%s-indexer", cr.GetName())
8682
if cr.Status.Peers == nil {
@@ -296,7 +292,7 @@ func ApplyIndexerClusterManager(ctx context.Context, client splcommon.Controller
296292

297293
// If bus is updated
298294
if cr.Spec.BusRef.Name != "" {
299-
if !reflect.DeepEqual(cr.Status.Bus, bus.Spec) || !reflect.DeepEqual(cr.Status.LargeMessageStore, lms.Spec) {
295+
if cr.Status.Bus == nil || cr.Status.LargeMessageStore == nil || !reflect.DeepEqual(cr.Status.Bus, bus.Spec) || !reflect.DeepEqual(cr.Status.LargeMessageStore, lms.Spec) {
300296
mgr := newIndexerClusterPodManager(scopedLog, cr, namespaceScopedSecret, splclient.NewSplunkClient)
301297
err = mgr.handlePullBusChange(ctx, cr, busCopy, lmsCopy, client)
302298
if err != nil {
@@ -407,10 +403,6 @@ func ApplyIndexerCluster(ctx context.Context, client splcommon.ControllerClient,
407403
// updates status after function completes
408404
cr.Status.Phase = enterpriseApi.PhaseError
409405
cr.Status.ClusterMasterPhase = enterpriseApi.PhaseError
410-
if cr.Status.Replicas < cr.Spec.Replicas {
411-
cr.Status.Bus = &enterpriseApi.BusSpec{}
412-
cr.Status.LargeMessageStore = &enterpriseApi.LargeMessageStoreSpec{}
413-
}
414406
cr.Status.Replicas = cr.Spec.Replicas
415407
cr.Status.Selector = fmt.Sprintf("app.kubernetes.io/instance=splunk-%s-indexer", cr.GetName())
416408
if cr.Status.Peers == nil {
@@ -629,7 +621,7 @@ func ApplyIndexerCluster(ctx context.Context, client splcommon.ControllerClient,
629621

630622
// If bus is updated
631623
if cr.Spec.BusRef.Name != "" {
632-
if !reflect.DeepEqual(cr.Status.Bus, bus.Spec) || !reflect.DeepEqual(cr.Status.LargeMessageStore, lms.Spec) {
624+
if cr.Status.Bus == nil || cr.Status.LargeMessageStore == nil || !reflect.DeepEqual(cr.Status.Bus, bus.Spec) || !reflect.DeepEqual(cr.Status.LargeMessageStore, lms.Spec) {
633625
mgr := newIndexerClusterPodManager(scopedLog, cr, namespaceScopedSecret, splclient.NewSplunkClient)
634626
err = mgr.handlePullBusChange(ctx, cr, busCopy, lmsCopy, client)
635627
if err != nil {

pkg/splunk/enterprise/ingestorcluster.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ func ApplyIngestorCluster(ctx context.Context, client client.Client, cr *enterpr
7272
// Update the CR Status
7373
defer updateCRStatus(ctx, client, cr, &err)
7474

75-
if cr.Status.Replicas < cr.Spec.Replicas {
76-
cr.Status.Bus = &enterpriseApi.BusSpec{}
77-
cr.Status.LargeMessageStore = &enterpriseApi.LargeMessageStoreSpec{}
78-
}
7975
cr.Status.Replicas = cr.Spec.Replicas
8076

8177
// If needed, migrate the app framework status
@@ -260,7 +256,7 @@ func ApplyIngestorCluster(ctx context.Context, client client.Client, cr *enterpr
260256
}
261257

262258
// If bus is updated
263-
if !reflect.DeepEqual(cr.Status.Bus, bus.Spec) || !reflect.DeepEqual(cr.Status.LargeMessageStore, lms.Spec) {
259+
if cr.Status.Bus == nil || cr.Status.LargeMessageStore == nil || !reflect.DeepEqual(cr.Status.Bus, bus.Spec) || !reflect.DeepEqual(cr.Status.LargeMessageStore, lms.Spec) {
264260
mgr := newIngestorClusterPodManager(scopedLog, cr, namespaceScopedSecret, splclient.NewSplunkClient, client)
265261
err = mgr.handlePushBusChange(ctx, cr, busCopy, lmsCopy, client)
266262
if err != nil {

0 commit comments

Comments
 (0)