From d7c46d70d3ef05fb58285be0680f838a8e871d36 Mon Sep 17 00:00:00 2001 From: Yuji Ito Date: Mon, 28 Jun 2021 04:23:38 +0000 Subject: [PATCH] ceph: fix overwriting shared livenessProbe When the Operator set the livenessProbe of the POD, it overwrote the contents of the shared desiredProbe. Therefore, the wrongly configured livenessProbe was applied to other PODs, resulting in a CrashLoop. In this PR, I created another instance to avoid overwriting the desiredProbe. Closes: https://github.com/rook/rook/issues/8196 Signed-off-by: Yuji Ito --- pkg/operator/ceph/config/livenessprobe.go | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pkg/operator/ceph/config/livenessprobe.go b/pkg/operator/ceph/config/livenessprobe.go index 04a458324fde..0c6df3019e8d 100644 --- a/pkg/operator/ceph/config/livenessprobe.go +++ b/pkg/operator/ceph/config/livenessprobe.go @@ -53,6 +53,8 @@ func ConfigureLivenessProbe(daemon rook.KeyType, container v1.Container, healthC } func GetLivenessProbeWithDefaults(desiredProbe, currentProbe *v1.Probe) *v1.Probe { + newProbe := *desiredProbe + // Do not replace the handler with the previous one! // On the first iteration, the handler appears empty and is then replaced by whatever first daemon value comes in // e.g: [env -i sh -c ceph --admin-daemon /run/ceph/ceph-mon.b.asok mon_status] - meaning mon b was the first picked in the list of mons @@ -61,25 +63,25 @@ func GetLivenessProbeWithDefaults(desiredProbe, currentProbe *v1.Probe) *v1.Prob // // Let's always force the default handler, there is no reason to change it anyway since the underlying content is generated based on the daemon's name // so we can not make it generic via the spec - desiredProbe.Handler = currentProbe.Handler + newProbe.Handler = currentProbe.Handler // If the user has not specified thresholds and timeouts, set them to the same values as // in the default liveness probe created by Rook. - if desiredProbe.FailureThreshold == 0 { - desiredProbe.FailureThreshold = currentProbe.FailureThreshold + if newProbe.FailureThreshold == 0 { + newProbe.FailureThreshold = currentProbe.FailureThreshold } - if desiredProbe.PeriodSeconds == 0 { - desiredProbe.PeriodSeconds = currentProbe.PeriodSeconds + if newProbe.PeriodSeconds == 0 { + newProbe.PeriodSeconds = currentProbe.PeriodSeconds } - if desiredProbe.SuccessThreshold == 0 { - desiredProbe.SuccessThreshold = currentProbe.SuccessThreshold + if newProbe.SuccessThreshold == 0 { + newProbe.SuccessThreshold = currentProbe.SuccessThreshold } - if desiredProbe.TimeoutSeconds == 0 { - desiredProbe.TimeoutSeconds = currentProbe.TimeoutSeconds + if newProbe.TimeoutSeconds == 0 { + newProbe.TimeoutSeconds = currentProbe.TimeoutSeconds } - if desiredProbe.InitialDelaySeconds == 0 { - desiredProbe.InitialDelaySeconds = currentProbe.InitialDelaySeconds + if newProbe.InitialDelaySeconds == 0 { + newProbe.InitialDelaySeconds = currentProbe.InitialDelaySeconds } - return desiredProbe + return &newProbe }