[stable-2.9] Fix ansible-test docker container IP detection. (#74390)

(cherry picked from commit 14ff5e213c)

Co-authored-by: Matt Clay <matt@mystile.com>
This commit is contained in:
Matt Clay
2021-04-26 08:07:35 -07:00
committed by GitHub
parent 4b23ac77e1
commit dfe3a4d345
2 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1,2 @@
bugfixes:
- ansible-test - Fix docker container IP address detection. The ``bridge`` network is no longer assumed to be the default.

View File

@ -106,7 +106,13 @@ def get_docker_container_ip(args, container_id):
networks = network_settings.get('Networks')
if networks:
network_name = get_docker_preferred_network_name(args) or 'bridge'
network_name = get_docker_preferred_network_name(args)
if not network_name:
# Sort networks and use the first available.
# This assumes all containers will have access to the same networks.
network_name = sorted(networks.keys()).pop(0)
ipaddress = networks[network_name]['IPAddress']
else:
# podman doesn't provide Networks, fall back to using IPAddress