[stable-2.10] Fix ansible-test docker container IP detection.. (#74389)

(cherry picked from commit 14ff5e213c)

Co-authored-by: Matt Clay <matt@mystile.com>
This commit is contained in:
Matt Clay 2021-04-26 08:21:32 -07:00 committed by GitHub
parent 0d25d392aa
commit cb4209489f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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

@ -110,7 +110,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