Skip to content

Commit b89aa75

Browse files
Merge pull request #298 from wking/remove-probes-when-manifest-has-none
Bug 1791863: lib/resourcemerge/core: Clear livenessProbe and readinessProbe if nil in required
2 parents a45fa12 + 29b92d2 commit b89aa75

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/resourcemerge/core.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,8 @@ func ensureContainer(modified *bool, existing *corev1.Container, required corev1
138138
ensureVolumeMount(modified, existingCurr, required)
139139
}
140140

141-
if required.LivenessProbe != nil {
142-
ensureProbePtr(modified, &existing.LivenessProbe, required.LivenessProbe)
143-
}
144-
if required.ReadinessProbe != nil {
145-
ensureProbePtr(modified, &existing.ReadinessProbe, required.ReadinessProbe)
146-
}
141+
ensureProbePtr(modified, &existing.LivenessProbe, required.LivenessProbe)
142+
ensureProbePtr(modified, &existing.ReadinessProbe, required.ReadinessProbe)
147143

148144
// our security context should always win
149145
ensureSecurityContextPtr(modified, &existing.SecurityContext, required.SecurityContext)
@@ -170,11 +166,10 @@ func ensureEnvFromSource(modified *bool, existing *[]corev1.EnvFromSource, requi
170166
}
171167

172168
func ensureProbePtr(modified *bool, existing **corev1.Probe, required *corev1.Probe) {
173-
// if we have no required, then we don't care what someone else has set
174-
if required == nil {
169+
if *existing == nil && required == nil {
175170
return
176171
}
177-
if *existing == nil {
172+
if *existing == nil || required == nil {
178173
*modified = true
179174
*existing = required
180175
return

0 commit comments

Comments
 (0)