summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdam Miller <admiller@redhat.com>2019-07-29 16:34:45 -0500
committeransibot <ansibot@users.noreply.github.com>2019-07-29 17:34:45 -0400
commite9d7156f533f44e46248aa856d89d5a680e41654 (patch)
treebb4b3d997e71d81e99883b0d5af0763606dcb4a4 /test
parentf7af4875d30d23b2cb5daf8f85162ad20ea768b1 (diff)
downloadansible-e9d7156f533f44e46248aa856d89d5a680e41654.tar.gz
podman-docker docker compat for ansible-test (#59539)
* podman-docker docker compat for ansible-test Signed-off-by: Adam Miller <admiller@redhat.com> * remove reprs, use ex.stderr instead Signed-off-by: Adam Miller <admiller@redhat.com> * remove u''s ... not needed Signed-off-by: Adam Miller <admiller@redhat.com> * Update test/runner/lib/docker_util.py Co-Authored-By: Matt Clay <matt@mystile.com> * Update test/runner/lib/docker_util.py Co-Authored-By: Matt Clay <matt@mystile.com> * make sanity tests happy Signed-off-by: Adam Miller <admiller@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/runner/lib/docker_util.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/runner/lib/docker_util.py b/test/runner/lib/docker_util.py
index b92a7d9d5d..d8332ef7bd 100644
--- a/test/runner/lib/docker_util.py
+++ b/test/runner/lib/docker_util.py
@@ -159,7 +159,13 @@ def docker_images(args, image):
:param image: str
:rtype: list[dict[str, any]]
"""
- stdout, _dummy = docker_command(args, ['images', image, '--format', '{{json .}}'], capture=True, always=True)
+ try:
+ stdout, _dummy = docker_command(args, ['images', image, '--format', '{{json .}}'], capture=True, always=True)
+ except SubprocessError as ex:
+ if 'no such image' in ex.stderr:
+ stdout = '' # podman does not handle this gracefully, exits 125
+ else:
+ raise ex
results = [json.loads(line) for line in stdout.splitlines()]
return results
@@ -169,7 +175,13 @@ def docker_rm(args, container_id):
:type args: EnvironmentConfig
:type container_id: str
"""
- docker_command(args, ['rm', '-f', container_id], capture=True)
+ try:
+ docker_command(args, ['rm', '-f', container_id], capture=True)
+ except SubprocessError as ex:
+ if 'no such container' in ex.stderr:
+ pass # podman does not handle this gracefully, exits 1
+ else:
+ raise ex
def docker_inspect(args, container_id):
@@ -185,6 +197,8 @@ def docker_inspect(args, container_id):
stdout = docker_command(args, ['inspect', container_id], capture=True)[0]
return json.loads(stdout)
except SubprocessError as ex:
+ if 'no such image' in ex.stderr:
+ return [] # podman does not handle this gracefully, exits 125
try:
return json.loads(ex.stdout)
except Exception: