From 161c19601a1a76e96c56aa3dfff6e153c73ba2e0 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 6 Feb 2024 09:10:11 -0500 Subject: [PATCH] container-deploy: Output stderr on failure This stage was failing for me in bib, with this change I now get more useful information from podman's stderr, e.g.: ``` RuntimeError: Failed to mount image (125): time="2024-02-06T14:23:06Z" level=error msg="Unmounting /var/lib/containers/storage/overlay/06456126e7c06cf1b21de024e08e64eddead2b8d03779be213e63aeeea9dec94/merged: invalid argument" Error: creating overlay mount (...snip...) fuse: device not found, try 'modprobe fuse' first fuse-overlayfs: cannot mount: No such file or directory ``` --- stages/org.osbuild.container-deploy | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/stages/org.osbuild.container-deploy b/stages/org.osbuild.container-deploy index 43c2076b..7f419da4 100755 --- a/stages/org.osbuild.container-deploy +++ b/stages/org.osbuild.container-deploy @@ -47,12 +47,16 @@ def mount_container(image_tag): try: result = subprocess.run( ["podman", "image", "mount", image_tag], - capture_output=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, encoding="utf-8", - check=True, + check=False, ) + if result.returncode != 0: + code = result.returncode + msg = result.stderr.strip() + raise RuntimeError(f"Failed to mount image ({code}): {msg}") yield result.stdout.strip() - finally: subprocess.run( ["podman", "image", "umount", image_tag],