From 09f1ccc64ca07f27666e4b949cca032148d5d13a Mon Sep 17 00:00:00 2001 From: "SPEARS, DUSTIN (ds443n)" Date: Tue, 5 Nov 2024 16:16:48 -0500 Subject: [PATCH] Update ceph-osd to be able to use tini Sometimes the pod fails to terminate correctly, leaving zombie processes. Add option to use tini to handle processes correctly. Additionally update log-tail script to handle sigterm and sigint. Change-Id: I96af2f3bef5f6c48858f1248ba85abdf7740279c --- ceph-osd/Chart.yaml | 2 +- ceph-osd/templates/bin/osd/_log-tail.sh.tpl | 14 +++++++++++--- ceph-osd/templates/daemonset-osd.yaml | 14 ++++++++++---- ceph-osd/values.yaml | 5 +++++ releasenotes/notes/ceph-osd.yaml | 1 + 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ceph-osd/Chart.yaml b/ceph-osd/Chart.yaml index d03d42b85..8b1687ea9 100644 --- a/ceph-osd/Chart.yaml +++ b/ceph-osd/Chart.yaml @@ -15,6 +15,6 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Ceph OSD name: ceph-osd -version: 0.1.52 +version: 0.1.53 home: https://github.com/ceph/ceph ... diff --git a/ceph-osd/templates/bin/osd/_log-tail.sh.tpl b/ceph-osd/templates/bin/osd/_log-tail.sh.tpl index a6b3edd10..301259142 100644 --- a/ceph-osd/templates/bin/osd/_log-tail.sh.tpl +++ b/ceph-osd/templates/bin/osd/_log-tail.sh.tpl @@ -18,14 +18,20 @@ wait_for_file "${osd_id_file}" "${WAIT_FOR_OSD_ID_TIMEOUT}" log_file="/var/log/ceph/${DAEMON_NAME}.$(cat "${osd_id_file}").log" wait_for_file "${log_file}" "${WAIT_FOR_OSD_ID_TIMEOUT}" +trap "exit" SIGTERM SIGINT +keep_running=true + function tail_file () { - while true; do - tail --retry -f "${log_file}" + while $keep_running; do + tail --retry -f "${log_file}" & + tail_pid=$! + wait $tail_pid + sleep 1 done } function truncate_log () { - while true; do + while $keep_running; do sleep ${TRUNCATE_PERIOD} if [[ -f ${log_file} ]] ; then truncate -s "${TRUNCATE_SIZE}" "${log_file}" @@ -37,3 +43,5 @@ tail_file & truncate_log & wait -n +keep_running=false +wait diff --git a/ceph-osd/templates/daemonset-osd.yaml b/ceph-osd/templates/daemonset-osd.yaml index 3ba2ce7e9..47f801418 100644 --- a/ceph-osd/templates/daemonset-osd.yaml +++ b/ceph-osd/templates/daemonset-osd.yaml @@ -315,8 +315,11 @@ spec: value: {{ .Values.logging.truncate.period | quote }} - name: WAIT_FOR_OSD_ID_TIMEOUT value: {{ .Values.logging.osd_id.timeout | quote }} - command: - - /tmp/log-tail.sh + {{- if .Values.conf.tini.log_runner.enabled }} + command: ["/usr/local/bin/tini", "--", "/tmp/log-tail.sh"] + {{- else }} + command: ["/tmp/log-tail.sh"] + {{- end }} volumeMounts: - name: pod-tmp mountPath: /tmp @@ -357,8 +360,11 @@ spec: value: {{ tuple "ceph_mon" "internal" "mon" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }} - name: MON_PORT_V2 value: {{ tuple "ceph_mon" "internal" "mon_msgr2" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }} - command: - - /tmp/osd-start.sh + {{- if .Values.conf.tini.ceph_osd_default.enabled }} + command: ["/usr/local/bin/tini", "--", "/tmp/osd-start.sh"] + {{- else }} + command: ["/tmp/osd-start.sh"] + {{- end }} lifecycle: preStop: exec: diff --git a/ceph-osd/values.yaml b/ceph-osd/values.yaml index 27df42d1a..8d6c8e86e 100644 --- a/ceph-osd/values.yaml +++ b/ceph-osd/values.yaml @@ -179,6 +179,11 @@ jobs: startingDeadlineSecs: 60 conf: + tini: + log_runner: + enabled: false + ceph_osd_default: + enabled: false ceph: global: # auth diff --git a/releasenotes/notes/ceph-osd.yaml b/releasenotes/notes/ceph-osd.yaml index a90aa5730..f7c077829 100644 --- a/releasenotes/notes/ceph-osd.yaml +++ b/releasenotes/notes/ceph-osd.yaml @@ -53,4 +53,5 @@ ceph-osd: - 0.1.50 Allow lvcreate to wipe existing LV metadata - 0.1.51 Update Ceph images to patched 18.2.2 and restore debian-reef repo - 0.1.52 Use quay.io/airshipit/kubernetes-entrypoint:latest-ubuntu_focal by default + - 0.1.53 Update ceph-daemon to be able to use tini init system ...