From 205a8d8c9d8d7001f54fddbbcd5317a87cd8c5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 23 Sep 2021 15:31:17 +0200 Subject: [PATCH] ceph: add signal handling for log collector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The log collector was not responding to SIGINT or SIGTERM correctly since the parent bash process did not have the job control functionality enabled. Now any signal received on bash will exit the container immediately. Signed-off-by: Sébastien Han (cherry picked from commit a649f641009b38b6b7434a513e97b577ddfcd0b6) --- pkg/operator/ceph/controller/spec.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/operator/ceph/controller/spec.go b/pkg/operator/ceph/controller/spec.go index e5baa2f1c30b..d37d1996d02c 100644 --- a/pkg/operator/ceph/controller/spec.go +++ b/pkg/operator/ceph/controller/spec.go @@ -67,8 +67,6 @@ var logger = capnslog.NewPackageLogger("github.com/rook/rook", "ceph-spec") var ( cronLogRotate = ` -set -xe - CEPH_CLIENT_ID=%s PERIODICITY=%s LOG_ROTATE_CEPH_FILE=/etc/logrotate.d/ceph @@ -625,13 +623,18 @@ func LogCollectorContainer(daemonID, ns string, c cephv1.ClusterSpec) *v1.Contai Name: logCollector, Command: []string{ "/bin/bash", - "-c", + "-x", // Print commands and their arguments as they are executed + "-e", // Exit immediately if a command exits with a non-zero status. + "-m", // Terminal job control, allows job to be terminated by SIGTERM + "-c", // Command to run fmt.Sprintf(cronLogRotate, daemonID, c.LogCollector.Periodicity), }, Image: c.CephVersion.Image, VolumeMounts: DaemonVolumeMounts(config.NewDatalessDaemonDataPathMap(ns, c.DataDirHostPath), ""), SecurityContext: PodSecurityContext(), Resources: cephv1.GetLogCollectorResources(c.Resources), + // We need a TTY for the bash job control (enabled by -m) + TTY: true, } }