Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman-docker docker compat for ansible-test #59539

Merged
merged 6 commits into from
Jul 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions test/runner/lib/docker_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand All @@ -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:
Expand Down