fix `ansible-test units` to work(ish) under podman (#69462)

* ignore the missing `Networks` key, issue a warning that network disconnection won't function
pull/69469/head
Matt Davis 4 years ago committed by GitHub
parent aa36b02ede
commit 776f4840fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- ansible-test - fixed ``units`` command with ``--docker`` to (mostly) work under podman

@ -350,8 +350,12 @@ def delegate_docker(args, exclude, require, integration_targets):
networks = get_docker_networks(args, test_id) networks = get_docker_networks(args, test_id)
for network in networks: if networks is not None:
docker_network_disconnect(args, test_id, network) for network in networks:
docker_network_disconnect(args, test_id, network)
else:
display.warning('Network disconnection is not supported (this is normal under podman). '
'Tests will not be isolated from the network. Network-related tests may misbehave.')
cmd += ['--requirements-mode', 'skip'] cmd += ['--requirements-mode', 'skip']

@ -78,8 +78,11 @@ def get_docker_networks(args, container_id):
:rtype: list[str] :rtype: list[str]
""" """
results = docker_inspect(args, container_id) results = docker_inspect(args, container_id)
networks = sorted(results[0]['NetworkSettings']['Networks']) # podman doesn't return Networks- just silently return None if it's missing...
return networks networks = results[0]['NetworkSettings'].get('Networks')
if networks is None:
return None
return sorted(networks)
def docker_pull(args, image): def docker_pull(args, image):

Loading…
Cancel
Save