summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-10-25 16:30:56 +0200
committerChristian Breunig <christian@breunig.cc>2025-10-25 16:38:54 +0200
commit133a6ce5649d94dfeac9aa07ac410e6a3d7ccf6a (patch)
tree0482d851bd532278bbb5188b9dcfe4e9709e4c21 /src
parentd316d808669994c4528b67a651fe0559a4b3dc77 (diff)
downloadvyos-1x-133a6ce5649d94dfeac9aa07ac410e6a3d7ccf6a.tar.gz
vyos-1x-133a6ce5649d94dfeac9aa07ac410e6a3d7ccf6a.zip
T7957: filter stderr when deleting container images
The call to rc_cmd('podman inspect ...') determines whether a container image scheduled for deletion has any ancestor containers still using it. Previously, if the podman command wrote output to stderr, rc_cmd() would return that error message alongside or instead of the ancestor container ID. This caused subsequent podman calls to fail, as the error string was incorrectly treated as a valid command argument. This change ensures only valid ancestor IDs are returned. This is a fix for commit a99ca6d11b5 ("op-mode: T7403: add option for forcefully remove a container image")
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/container.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/op_mode/container.py b/src/op_mode/container.py
index 3dd665051..a34901cb4 100755
--- a/src/op_mode/container.py
+++ b/src/op_mode/container.py
@@ -120,11 +120,11 @@ def delete_image(name: str, force: typing.Optional[bool] = False):
for image in name:
# convert the truncated image ID to a full image ID
- rc, ancestor = rc_cmd(f'podman inspect {image} --format "{{{{.Id}}}}"')
+ rc, ancestor = rc_cmd(f'podman inspect {image} --format "{{{{.Id}}}}"', stderr=None)
if rc != 0:
raise vyos.opmode.InternalError(ancestor)
# check if the image ID is an ancestor of any running container
- rc, in_use = rc_cmd(f'podman ps --filter ancestor={ancestor} -q')
+ rc, in_use = rc_cmd(f'podman ps --filter ancestor={ancestor} -q', stderr=None)
if rc != 0:
raise vyos.opmode.InternalError(in_use)