Skip to content

Commit 29b92d2

Browse files
committed
lib/resourcemerge/core: Clear livenessProbe and readinessProbe if nil in required
We claimed: if we have no required, then we don't care what someone else has set since this code landed in d9f6718 (lib: add lib for applying objects, 2018-08-14, #7). But we do care in situations like [1], where a 4.3 -> 4.2 downgrade leaves 4.3 readiness probes in place for a 4.2 operator which has no /readyz. With this commit we still have a few other types where we claim to not care: $ git grep -hB1 'someone else has set' | grep func func ensureSecurityContextPtr(modified *bool, existing **corev1.SecurityContext, required *corev1.SecurityContext) { func ensureCapabilitiesPtr(modified *bool, existing **corev1.Capabilities, required *corev1.Capabilities) { func ensureAffinityPtr(modified *bool, existing **corev1.Affinity, required *corev1.Affinity) { func ensurePodSecurityContextPtr(modified *bool, existing **corev1.PodSecurityContext, required *corev1.PodSecurityContext) { func ensureSELinuxOptionsPtr(modified *bool, existing **corev1.SELinuxOptions, required *corev1.SELinuxOptions) { func setBoolPtr(modified *bool, existing **bool, required *bool) { func setInt64Ptr(modified *bool, existing **int64, required *int64) { but I'm leaving them alone until we have a clearer picture about whether we care about those specific properties or not. [1]: https://bugzilla.redhat.com/show_bug.cgi?id=1791863#c1
1 parent a45fa12 commit 29b92d2

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)