Skip to content

Commit c1dbbf2

Browse files
committed
CSPL-4022 Fix update behaviour
1 parent 10a4fc0 commit c1dbbf2

File tree

6 files changed

+138
-91
lines changed

6 files changed

+138
-91
lines changed

internal/controller/indexercluster_controller.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
corev1 "k8s.io/api/core/v1"
3232
k8serrors "k8s.io/apimachinery/pkg/api/errors"
3333
"k8s.io/apimachinery/pkg/runtime"
34+
"k8s.io/apimachinery/pkg/types"
3435
ctrl "sigs.k8s.io/controller-runtime"
3536
"sigs.k8s.io/controller-runtime/pkg/client"
3637
"sigs.k8s.io/controller-runtime/pkg/controller"
@@ -171,6 +172,34 @@ func (r *IndexerClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
171172
mgr.GetRESTMapper(),
172173
&enterpriseApi.IndexerCluster{},
173174
)).
175+
Watches(&enterpriseApi.BusConfiguration{},
176+
handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []reconcile.Request {
177+
bc, ok := obj.(*enterpriseApi.BusConfiguration)
178+
if !ok {
179+
return nil
180+
}
181+
var list enterpriseApi.IndexerClusterList
182+
if err := r.Client.List(ctx, &list); err != nil {
183+
return nil
184+
}
185+
var reqs []reconcile.Request
186+
for _, ic := range list.Items {
187+
ns := ic.Spec.BusConfigurationRef.Namespace
188+
if ns == "" {
189+
ns = ic.Namespace
190+
}
191+
if ic.Spec.BusConfigurationRef.Name == bc.Name && ns == bc.Namespace {
192+
reqs = append(reqs, reconcile.Request{
193+
NamespacedName: types.NamespacedName{
194+
Name: ic.Name,
195+
Namespace: ic.Namespace,
196+
},
197+
})
198+
}
199+
}
200+
return reqs
201+
}),
202+
).
174203
WithOptions(controller.Options{
175204
MaxConcurrentReconciles: enterpriseApi.TotalWorker,
176205
}).

internal/controller/ingestorcluster_controller.go

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
corev1 "k8s.io/api/core/v1"
2525
k8serrors "k8s.io/apimachinery/pkg/api/errors"
2626
"k8s.io/apimachinery/pkg/runtime"
27+
"k8s.io/apimachinery/pkg/types"
2728
ctrl "sigs.k8s.io/controller-runtime"
2829
"sigs.k8s.io/controller-runtime/pkg/client"
2930
"sigs.k8s.io/controller-runtime/pkg/controller"
@@ -141,11 +142,33 @@ func (r *IngestorClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
141142
&enterpriseApi.IngestorCluster{},
142143
)).
143144
Watches(&enterpriseApi.BusConfiguration{},
144-
handler.EnqueueRequestForOwner(
145-
mgr.GetScheme(),
146-
mgr.GetRESTMapper(),
147-
&enterpriseApi.IngestorCluster{},
148-
)).
145+
handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []reconcile.Request {
146+
bc, ok := obj.(*enterpriseApi.BusConfiguration)
147+
if !ok {
148+
return nil
149+
}
150+
var list enterpriseApi.IngestorClusterList
151+
if err := r.Client.List(ctx, &list); err != nil {
152+
return nil
153+
}
154+
var reqs []reconcile.Request
155+
for _, ic := range list.Items {
156+
ns := ic.Spec.BusConfigurationRef.Namespace
157+
if ns == "" {
158+
ns = ic.Namespace
159+
}
160+
if ic.Spec.BusConfigurationRef.Name == bc.Name && ns == bc.Namespace {
161+
reqs = append(reqs, reconcile.Request{
162+
NamespacedName: types.NamespacedName{
163+
Name: ic.Name,
164+
Namespace: ic.Namespace,
165+
},
166+
})
167+
}
168+
}
169+
return reqs
170+
}),
171+
).
149172
WithOptions(controller.Options{
150173
MaxConcurrentReconciles: enterpriseApi.TotalWorker,
151174
}).

pkg/splunk/enterprise/indexercluster.go

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"context"
2020
"errors"
2121
"fmt"
22+
"reflect"
2223
"regexp"
2324
"sort"
2425
"strconv"
@@ -66,24 +67,8 @@ func ApplyIndexerClusterManager(ctx context.Context, client splcommon.Controller
6667
// Update the CR Status
6768
defer updateCRStatus(ctx, client, cr, &err)
6869

69-
// Bus config
70-
busConfig := enterpriseApi.BusConfiguration{}
71-
if cr.Spec.BusConfigurationRef.Name != "" {
72-
ns := cr.GetNamespace()
73-
if cr.Spec.BusConfigurationRef.Namespace != "" {
74-
ns = cr.Spec.BusConfigurationRef.Namespace
75-
}
76-
err = client.Get(context.Background(), types.NamespacedName{
77-
Name: cr.Spec.BusConfigurationRef.Name,
78-
Namespace: ns,
79-
}, &busConfig)
80-
if err != nil {
81-
return result, err
82-
}
83-
}
84-
8570
// validate and updates defaults for CR
86-
err = validateIndexerClusterSpec(ctx, client, cr, &busConfig)
71+
err = validateIndexerClusterSpec(ctx, client, cr)
8772
if err != nil {
8873
eventPublisher.Warning(ctx, "validateIndexerClusterSpec", fmt.Sprintf("validate indexercluster spec failed %s", err.Error()))
8974
scopedLog.Error(err, "Failed to validate indexercluster spec")
@@ -257,14 +242,36 @@ func ApplyIndexerClusterManager(ctx context.Context, client splcommon.Controller
257242

258243
// no need to requeue if everything is ready
259244
if cr.Status.Phase == enterpriseApi.PhaseReady {
245+
// Bus config
246+
busConfig := enterpriseApi.BusConfiguration{}
260247
if cr.Spec.BusConfigurationRef.Name != "" {
261-
err = mgr.handlePullBusChange(ctx, cr, busConfig, client)
248+
ns := cr.GetNamespace()
249+
if cr.Spec.BusConfigurationRef.Namespace != "" {
250+
ns = cr.Spec.BusConfigurationRef.Namespace
251+
}
252+
err = client.Get(context.Background(), types.NamespacedName{
253+
Name: cr.Spec.BusConfigurationRef.Name,
254+
Namespace: ns,
255+
}, &busConfig)
262256
if err != nil {
263-
scopedLog.Error(err, "Failed to update conf file for Bus/Pipeline config change after pod creation")
264257
return result, err
265258
}
266259
}
267-
cr.Status.BusConfiguration = busConfig.Spec
260+
261+
// If bus config is updated
262+
if cr.Spec.BusConfigurationRef.Name != "" {
263+
if !reflect.DeepEqual(cr.Status.BusConfiguration, busConfig.Spec) {
264+
mgr := newIndexerClusterPodManager(scopedLog, cr, namespaceScopedSecret, splclient.NewSplunkClient)
265+
266+
err = mgr.handlePullBusChange(ctx, cr, busConfig, client)
267+
if err != nil {
268+
scopedLog.Error(err, "Failed to update conf file for Bus/Pipeline config change after pod creation")
269+
return result, err
270+
}
271+
272+
cr.Status.BusConfiguration = busConfig.Spec
273+
}
274+
}
268275

269276
//update MC
270277
//Retrieve monitoring console ref from CM Spec
@@ -345,24 +352,8 @@ func ApplyIndexerCluster(ctx context.Context, client splcommon.ControllerClient,
345352
eventPublisher, _ := newK8EventPublisher(client, cr)
346353
cr.Kind = "IndexerCluster"
347354

348-
// Bus config
349-
busConfig := enterpriseApi.BusConfiguration{}
350-
if cr.Spec.BusConfigurationRef.Name != "" {
351-
ns := cr.GetNamespace()
352-
if cr.Spec.BusConfigurationRef.Namespace != "" {
353-
ns = cr.Spec.BusConfigurationRef.Namespace
354-
}
355-
err := client.Get(context.Background(), types.NamespacedName{
356-
Name: cr.Spec.BusConfigurationRef.Name,
357-
Namespace: ns,
358-
}, &busConfig)
359-
if err != nil {
360-
return result, err
361-
}
362-
}
363-
364355
// validate and updates defaults for CR
365-
err := validateIndexerClusterSpec(ctx, client, cr, &busConfig)
356+
err := validateIndexerClusterSpec(ctx, client, cr)
366357
if err != nil {
367358
return result, err
368359
}
@@ -538,29 +529,37 @@ func ApplyIndexerCluster(ctx context.Context, client splcommon.ControllerClient,
538529

539530
// no need to requeue if everything is ready
540531
if cr.Status.Phase == enterpriseApi.PhaseReady {
532+
// Bus config
533+
busConfig := enterpriseApi.BusConfiguration{}
541534
if cr.Spec.BusConfigurationRef.Name != "" {
542-
busConfig := enterpriseApi.BusConfiguration{}
543535
ns := cr.GetNamespace()
544536
if cr.Spec.BusConfigurationRef.Namespace != "" {
545537
ns = cr.Spec.BusConfigurationRef.Namespace
546538
}
547-
err := client.Get(context.Background(), types.NamespacedName{
539+
err = client.Get(context.Background(), types.NamespacedName{
548540
Name: cr.Spec.BusConfigurationRef.Name,
549541
Namespace: ns,
550542
}, &busConfig)
551543
if err != nil {
552544
return result, err
553545
}
546+
}
554547

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
548+
// If bus config is updated
549+
if cr.Spec.BusConfigurationRef.Name != "" {
550+
if !reflect.DeepEqual(cr.Status.BusConfiguration, busConfig.Spec) {
551+
mgr := newIndexerClusterPodManager(scopedLog, cr, namespaceScopedSecret, splclient.NewSplunkClient)
552+
553+
err = mgr.handlePullBusChange(ctx, cr, busConfig, client)
554+
if err != nil {
555+
scopedLog.Error(err, "Failed to update conf file for Bus/Pipeline config change after pod creation")
556+
return result, err
557+
}
558+
559+
cr.Status.BusConfiguration = busConfig.Spec
559560
}
560561
}
561562

562-
cr.Status.BusConfiguration = busConfig.Spec
563-
564563
//update MC
565564
//Retrieve monitoring console ref from CM Spec
566565
cmMonitoringConsoleConfigRef, err := RetrieveCMSpec(ctx, client, cr)
@@ -1126,7 +1125,7 @@ func getIndexerStatefulSet(ctx context.Context, client splcommon.ControllerClien
11261125
}
11271126

11281127
// validateIndexerClusterSpec checks validity and makes default updates to a IndexerClusterSpec, and returns error if something is wrong.
1129-
func validateIndexerClusterSpec(ctx context.Context, c splcommon.ControllerClient, cr *enterpriseApi.IndexerCluster, busConfig *enterpriseApi.BusConfiguration) error {
1128+
func validateIndexerClusterSpec(ctx context.Context, c splcommon.ControllerClient, cr *enterpriseApi.IndexerCluster) error {
11301129
// We cannot have 0 replicas in IndexerCluster spec, since this refers to number of indexers in an indexer cluster
11311130
if cr.Spec.Replicas == 0 {
11321131
cr.Spec.Replicas = 1

pkg/splunk/enterprise/indexercluster_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ func TestGetIndexerStatefulSet(t *testing.T) {
13881388
cr.Spec.ClusterManagerRef.Name = "manager1"
13891389
test := func(want string) {
13901390
f := func() (interface{}, error) {
1391-
if err := validateIndexerClusterSpec(ctx, c, &cr, &busConfig); err != nil {
1391+
if err := validateIndexerClusterSpec(ctx, c, &cr); err != nil {
13921392
t.Errorf("validateIndexerClusterSpec() returned error: %v", err)
13931393
}
13941394
return getIndexerStatefulSet(ctx, c, &cr)
@@ -1434,7 +1434,7 @@ func TestGetIndexerStatefulSet(t *testing.T) {
14341434
test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-indexer","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000,8088"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-indexer-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"http-hec","containerPort":8088,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"},{"name":"tcp-s2s","containerPort":9997,"protocol":"TCP"},{"name":"user-defined","containerPort":32000,"protocol":"UDP"}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-manager1-cluster-manager-service"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_indexer"},{"name":"SPLUNK_DECLARATIVE_ADMIN_PASSWORD","value":"true"},{"name":"SPLUNK_OPERATOR_K8_LIVENESS_DRIVER_FILE_PATH","value":"/tmp/splunk_operator_k8s/probes/k8_liveness_driver.sh"},{"name":"SPLUNK_GENERAL_TERMS","value":"--accept-sgt-current-at-splunk-com"},{"name":"SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH","value":"true"}],"resources":{"limits":{"cpu":"4","memory":"8Gi"},"requests":{"cpu":"100m","memory":"512Mi"}},"volumeMounts":[{"name":"pvc-etc","mountPath":"/opt/splunk/etc"},{"name":"pvc-var","mountPath":"/opt/splunk/var"},{"name":"splunk-test-probe-configmap","mountPath":"/mnt/probes"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"}],"livenessProbe":{"exec":{"command":["/mnt/probes/livenessProbe.sh"]},"initialDelaySeconds":30,"timeoutSeconds":30,"periodSeconds":30,"failureThreshold":3},"readinessProbe":{"exec":{"command":["/mnt/probes/readinessProbe.sh"]},"initialDelaySeconds":10,"timeoutSeconds":5,"periodSeconds":5,"failureThreshold":3},"startupProbe":{"exec":{"command":["/mnt/probes/startupProbe.sh"]},"initialDelaySeconds":40,"timeoutSeconds":30,"periodSeconds":30,"failureThreshold":12},"imagePullPolicy":"IfNotPresent","securityContext":{"capabilities":{"add":["NET_BIND_SERVICE"],"drop":["ALL"]},"privileged":false,"runAsUser":41812,"runAsNonRoot":true,"allowPrivilegeEscalation":false,"seccompProfile":{"type":"RuntimeDefault"}}}],"serviceAccountName":"defaults","securityContext":{"runAsUser":41812,"runAsNonRoot":true,"fsGroup":41812,"fsGroupChangePolicy":"OnRootMismatch"},"affinity":{"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":100,"podAffinityTerm":{"labelSelector":{"matchExpressions":[{"key":"app.kubernetes.io/instance","operator":"In","values":["splunk-stack1-indexer"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-indexer-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`)
14351435

14361436
cr.Spec.ClusterManagerRef.Namespace = "other"
1437-
if err := validateIndexerClusterSpec(ctx, c, &cr, &busConfig); err == nil {
1437+
if err := validateIndexerClusterSpec(ctx, c, &cr); err == nil {
14381438
t.Errorf("validateIndexerClusterSpec() error expected on multisite IndexerCluster referencing a cluster manager located in a different namespace")
14391439
}
14401440
}

pkg/splunk/enterprise/ingestorcluster.go

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,20 @@ func ApplyIngestorCluster(ctx context.Context, client client.Client, cr *enterpr
5858

5959
cr.Kind = "IngestorCluster"
6060

61-
// Initialize phase
62-
cr.Status.Phase = enterpriseApi.PhaseError
63-
64-
// Update the CR Status
65-
defer updateCRStatus(ctx, client, cr, &err)
66-
67-
// Bus config
68-
busConfig := enterpriseApi.BusConfiguration{}
69-
if cr.Spec.BusConfigurationRef.Name != "" {
70-
ns := cr.GetNamespace()
71-
if cr.Spec.BusConfigurationRef.Namespace != "" {
72-
ns = cr.Spec.BusConfigurationRef.Namespace
73-
}
74-
err = client.Get(context.Background(), types.NamespacedName{
75-
Name: cr.Spec.BusConfigurationRef.Name,
76-
Namespace: ns,
77-
}, &busConfig)
78-
if err != nil {
79-
return result, err
80-
}
81-
}
82-
8361
// Validate and updates defaults for CR
84-
err = validateIngestorClusterSpec(ctx, client, cr, &busConfig)
62+
err = validateIngestorClusterSpec(ctx, client, cr)
8563
if err != nil {
8664
eventPublisher.Warning(ctx, "validateIngestorClusterSpec", fmt.Sprintf("validate ingestor cluster spec failed %s", err.Error()))
8765
scopedLog.Error(err, "Failed to validate ingestor cluster spec")
8866
return result, err
8967
}
9068

69+
// Initialize phase
70+
cr.Status.Phase = enterpriseApi.PhaseError
71+
72+
// Update the CR Status
73+
defer updateCRStatus(ctx, client, cr, &err)
74+
9175
cr.Status.Replicas = cr.Spec.Replicas
9276

9377
// If needed, migrate the app framework status
@@ -111,7 +95,7 @@ func ApplyIngestorCluster(ctx context.Context, client client.Client, cr *enterpr
11195
cr.Status.Selector = fmt.Sprintf("app.kubernetes.io/instance=splunk-%s-ingestor", cr.GetName())
11296

11397
// Create or update general config resources
114-
_, err = ApplySplunkConfig(ctx, client, cr, cr.Spec.CommonSplunkSpec, SplunkIngestor)
98+
namespaceScopedSecret, err := ApplySplunkConfig(ctx, client, cr, cr.Spec.CommonSplunkSpec, SplunkIngestor)
11599
if err != nil {
116100
scopedLog.Error(err, "create or update general config failed", "error", err.Error())
117101
eventPublisher.Warning(ctx, "ApplySplunkConfig", fmt.Sprintf("create or update general config failed with error %s", err.Error()))
@@ -223,22 +207,34 @@ func ApplyIngestorCluster(ctx context.Context, client client.Client, cr *enterpr
223207

224208
// No need to requeue if everything is ready
225209
if cr.Status.Phase == enterpriseApi.PhaseReady {
226-
namespaceScopedSecret, err := ApplySplunkConfig(ctx, client, cr, cr.Spec.CommonSplunkSpec, SplunkIngestor)
227-
if err != nil {
228-
scopedLog.Error(err, "create or update general config failed", "error", err.Error())
229-
eventPublisher.Warning(ctx, "ApplySplunkConfig", fmt.Sprintf("create or update general config failed with error %s", err.Error()))
230-
return result, err
210+
// Bus config
211+
busConfig := enterpriseApi.BusConfiguration{}
212+
if cr.Spec.BusConfigurationRef.Name != "" {
213+
ns := cr.GetNamespace()
214+
if cr.Spec.BusConfigurationRef.Namespace != "" {
215+
ns = cr.Spec.BusConfigurationRef.Namespace
216+
}
217+
err = client.Get(ctx, types.NamespacedName{
218+
Name: cr.Spec.BusConfigurationRef.Name,
219+
Namespace: ns,
220+
}, &busConfig)
221+
if err != nil {
222+
return result, err
223+
}
231224
}
232225

233-
mgr := newIngestorClusterPodManager(scopedLog, cr, namespaceScopedSecret, splclient.NewSplunkClient)
226+
// If bus config is updated
227+
if !reflect.DeepEqual(cr.Status.BusConfiguration, busConfig.Spec) {
228+
mgr := newIngestorClusterPodManager(scopedLog, cr, namespaceScopedSecret, splclient.NewSplunkClient)
234229

235-
err = mgr.handlePushBusChange(ctx, cr, busConfig, client)
236-
if err != nil {
237-
scopedLog.Error(err, "Failed to update conf file for Bus/Pipeline config change after pod creation")
238-
return result, err
239-
}
230+
err = mgr.handlePushBusChange(ctx, cr, busConfig, client)
231+
if err != nil {
232+
scopedLog.Error(err, "Failed to update conf file for Bus/Pipeline config change after pod creation")
233+
return result, err
234+
}
240235

241-
cr.Status.BusConfiguration = busConfig.Spec
236+
cr.Status.BusConfiguration = busConfig.Spec
237+
}
242238

243239
// Upgrade fron automated MC to MC CRD
244240
namespacedName := types.NamespacedName{Namespace: cr.GetNamespace(), Name: GetSplunkStatefulsetName(SplunkMonitoringConsole, cr.GetNamespace())}
@@ -281,7 +277,7 @@ func ApplyIngestorCluster(ctx context.Context, client client.Client, cr *enterpr
281277
}
282278

283279
// validateIngestorClusterSpec checks validity and makes default updates to a IngestorClusterSpec and returns error if something is wrong
284-
func validateIngestorClusterSpec(ctx context.Context, c splcommon.ControllerClient, cr *enterpriseApi.IngestorCluster, busConfig *enterpriseApi.BusConfiguration) error {
280+
func validateIngestorClusterSpec(ctx context.Context, c splcommon.ControllerClient, cr *enterpriseApi.IngestorCluster) error {
285281
// We cannot have 0 replicas in IngestorCluster spec since this refers to number of ingestion pods in an ingestor cluster
286282
if cr.Spec.Replicas < 3 {
287283
cr.Spec.Replicas = 3

pkg/splunk/enterprise/ingestorcluster_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ func TestGetIngestorStatefulSet(t *testing.T) {
357357

358358
test := func(want string) {
359359
f := func() (interface{}, error) {
360-
if err := validateIngestorClusterSpec(ctx, c, &cr, &busConfig); err != nil {
360+
if err := validateIngestorClusterSpec(ctx, c, &cr); err != nil {
361361
t.Errorf("validateIngestorClusterSpec() returned error: %v", err)
362362
}
363363
return getIngestorStatefulSet(ctx, c, &cr)

0 commit comments

Comments
 (0)