From 6f799052eba345c19d4225a7d67b5160d7321abd Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Wed, 22 Oct 2025 15:37:08 -0600 Subject: [PATCH] mon: trap the sigterm in the mon canary The mon canary should quickly shut down after the pod is deleted, since it has no purpose to continue running. Since the sleep does not catch the SIGTERM as pid 1, use a bash trap to exit quickly. Signed-off-by: Travis Nielsen (cherry picked from commit 48b70500fac0914c39bf9809bf2db644363d690e) --- pkg/operator/ceph/cluster/mon/mon.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/operator/ceph/cluster/mon/mon.go b/pkg/operator/ceph/cluster/mon/mon.go index 2e16a3f73..0bc561f7a 100644 --- a/pkg/operator/ceph/cluster/mon/mon.go +++ b/pkg/operator/ceph/cluster/mon/mon.go @@ -703,8 +703,15 @@ func scheduleMonitor(c *Cluster, mon *monConfig) (*apps.Deployment, error) { // to modify the storage by instead running an innocuous command. d.Spec.Template.Spec.InitContainers = []corev1.Container{} d.Spec.Template.Spec.Containers[0].Image = c.rookImage - d.Spec.Template.Spec.Containers[0].Command = []string{"sleep"} // sleep responds to signals so we don't need to wrap it - d.Spec.Template.Spec.Containers[0].Args = []string{"3600"} + // As PID 1, sleep will not capture the SIGTERM signal, so use a bash + // trap to exit cleanly and quickly when the pod is deleted. + d.Spec.Template.Spec.Containers[0].Command = []string{ + "/bin/bash", + "-c", + `trap 'exit' SIGTERM + while true; do sleep 1; done`, + } + // remove the startup and liveness probes on the canary pod d.Spec.Template.Spec.Containers[0].StartupProbe = nil d.Spec.Template.Spec.Containers[0].LivenessProbe = nil