From 2aac8ce4754b5847ee3b037392dbcd9b75e2c38c Mon Sep 17 00:00:00 2001 From: Henrik Wachowitz Date: Mon, 9 Dec 2024 16:21:59 +0100 Subject: [PATCH] use podman create, init and rm instead of run and kill --- contrib/vcloud/podman_containerized_tool.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/contrib/vcloud/podman_containerized_tool.py b/contrib/vcloud/podman_containerized_tool.py index 77969afc7..74d1a12f7 100644 --- a/contrib/vcloud/podman_containerized_tool.py +++ b/contrib/vcloud/podman_containerized_tool.py @@ -59,9 +59,9 @@ def _init_container( # Create a container that does nothing but keeps running command = ( - ["podman", "run", "--entrypoint", "tail", "--rm", "-d"] + ["podman", "create", "--entrypoint", '[""]', "--rm"] + volumes - + [image, "-F", "/dev/null"] + + [image, "/bin/sh"] ) logging.debug( @@ -71,15 +71,26 @@ def _init_container( res = subprocess.run( command, stdout=subprocess.PIPE, + stderr=subprocess.DEVNULL, + stdin=subprocess.DEVNULL, + check=True, ) - - res.check_returncode() container_id = res.stdout.decode().strip() + subprocess.run( + ["podman", "init", container_id], + check=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + stdin=subprocess.DEVNULL, + ) + container_pid = ( subprocess.run( ["podman", "inspect", "--format", "{{.State.Pid}}", container_id], stdout=subprocess.PIPE, + stderr=subprocess.DEVNULL, + stdin=subprocess.DEVNULL, ) .stdout.decode() .strip() @@ -161,7 +172,7 @@ def close(self): return try: subprocess.run( - ["podman", "kill", "--signal", "SIGKILL", self.container_id], + ["podman", "rm", self.container_id], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE,