From c21596cd9993527cd8f56768b4d6b7f0eab4d7d3 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Wed, 16 Mar 2022 01:24:35 +0000 Subject: [PATCH] containers/composer: forward SIGTERM to children In docker compose and openshift SIGTERM is used to tell containers to shut down gracefully. Forward the signal to the processes we spawned. --- containers/osbuild-composer/entrypoint.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/containers/osbuild-composer/entrypoint.py b/containers/osbuild-composer/entrypoint.py index 19622f410..6a973bd2b 100644 --- a/containers/osbuild-composer/entrypoint.py +++ b/containers/osbuild-composer/entrypoint.py @@ -10,6 +10,7 @@ import argparse import contextlib import os import pathlib +import signal import socket import subprocess import sys @@ -302,6 +303,13 @@ class Cli(contextlib.AbstractContextManager): res = 0 sockets = self._prepare_sockets() + def handler(signum, frame): + proc_composer.terminate() + proc_worker.terminate() + proc_dnf_json.terminate() + + signal.signal(signal.SIGTERM, handler) + liveness = pathlib.Path('/run/live') liveness.touch()