Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pkg/splunk/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package controller

import (
"reflect"
"strings"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -166,6 +167,22 @@ func MergePodSpecUpdates(current *corev1.PodSpec, revised *corev1.PodSpec, name
current.Containers[idx].Resources = revised.Containers[idx].Resources
result = true
}

// check Env
// Skip this check for the Monitoring Console
// This is temporary until the MC has it's own CR to control the MC pod env.
skipForMC := false
if strings.Contains(name, "monitoring-console") {
scopedLog.Info("Ignoring Pod Container Envs differences for MC pods", "name", name)
skipForMC = true
}
if !skipForMC && splcommon.CompareEnvs(current.Containers[idx].Env, revised.Containers[idx].Env) {
scopedLog.Info("Pod Container Envs differ",
"current", current.Containers[idx].Env,
"revised", revised.Containers[idx].Env)
current.Containers[idx].Env = revised.Containers[idx].Env
result = true
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/splunk/controller/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ func TestMergePodUpdates(t *testing.T) {
matcher = func() bool { return reflect.DeepEqual(current.Spec.Containers, revised.Spec.Containers) }
podUpdateTester("Container Resources")

// check pod env update
current.Spec.Containers[0].Env = append(current.Spec.Containers[0].Env, corev1.EnvVar{
Name: "SPLUNK_DEFAULTS_URL",
Value: "defaults1.yaml",
})
revised.Spec.Containers[0].Env = append(revised.Spec.Containers[0].Env, corev1.EnvVar{
Name: "SPLUNK_DEFAULTS_URL",
Value: "defaults2.yaml",
})
matcher = func() bool { return reflect.DeepEqual(current.Spec.Containers[0].Env, revised.Spec.Containers[0].Env) }
podUpdateTester("Pod Env changed")

// check container removed
revised.Spec.Containers = []corev1.Container{}
matcher = func() bool { return reflect.DeepEqual(current.Spec.Containers, revised.Spec.Containers) }
Expand Down