From e082fbf398dbff50fb4732b3d4d14a52b529a072 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 6 Oct 2021 19:16:28 -0700 Subject: [PATCH] [calc] work around the docker bridge network issue (#4433) What is the motivation for this PR? There is a docker bridge network issue that would randomly cause "docker inspect bridge" to not show 'Gateway' IP. Reference: moby/moby#26799 How did you do it? We could use the 'Subnet' entry for the test purpose. How did you verify/test it? Run test against device exhibiting the docker bridge network issue. --- tests/cacl/test_cacl_application.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/cacl/test_cacl_application.py b/tests/cacl/test_cacl_application.py index 03d99c4e5da..392727cfad8 100644 --- a/tests/cacl/test_cacl_application.py +++ b/tests/cacl/test_cacl_application.py @@ -21,8 +21,21 @@ def docker_network(duthost): ipam_info = json.loads(output['stdout'])[0]['IPAM'] docker_network = {} - docker_network['bridge'] = {'IPv4Address' : ipam_info['Config'][0]['Gateway'], - 'IPv6Address' : ipam_info['Config'][1]['Gateway'] } + """ + FIXME: Work around dockerd issue. The Gateway entry might be missing. In that case, use 'Subnet' instead. + Sample output when docker hit the issue (Note that the IPv6 gateway is missing): + "Config": [ + { + "Subnet": "240.127.1.1/24", + "Gateway": "240.127.1.1" + }, + { + "Subnet": "fd00::/80" + } + ] + """ + docker_network['bridge'] = {'IPv4Address' : ipam_info['Config'][0].get('Gateway', ipam_info['Config'][0].get('Subnet')), + 'IPv6Address' : ipam_info['Config'][1].get('Gateway', ipam_info['Config'][1].get('Subnet')) } docker_network['container'] = {} for k,v in docker_containers_info.items():