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
```
This commit is contained in:
Colin Walters 2024-02-06 09:10:11 -05:00 committed by Michael Vogt
parent 6e12f08a29
commit 161c19601a

View file

@ -47,12 +47,16 @@ def mount_container(image_tag):
try: try:
result = subprocess.run( result = subprocess.run(
["podman", "image", "mount", image_tag], ["podman", "image", "mount", image_tag],
capture_output=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8", 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() yield result.stdout.strip()
finally: finally:
subprocess.run( subprocess.run(
["podman", "image", "umount", image_tag], ["podman", "image", "umount", image_tag],