summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Hopkins <liamh@google.com>2019-11-12 10:36:11 -0800
committerGitHub <noreply@github.com>2019-11-12 10:36:11 -0800
commitac3db2adb9ca8826d96b222cb22bac74e95c3c49 (patch)
tree7424dfa31fadcfcf4e68fff3b679154d24201dcd
parent880daf9de49873d37aa6723dff4bba81542d1ecd (diff)
downloadgoogle-compute-image-packages-ac3db2adb9ca8826d96b222cb22bac74e95c3c49.tar.gz
Wait on tentative v6 link-local addrs before DHCP (#861)
-rw-r--r--packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py b/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py
index a0be6a0..c20b241 100644
--- a/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py
+++ b/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py
@@ -17,6 +17,7 @@
import os
import subprocess
+import time
def CallDhclient(
@@ -68,6 +69,23 @@ def CallDhclientIpv6(interfaces, logger, dhclient_script=None,
interfaces)
return
+ # Check for a 'tentative' IPv6 address which would prevent `dhclient -6` from
+ # succeeding below. This should only take 1 second, but we try for up to 5.
+ command = ['ip', '-6', '-o', 'a', 's', 'dev', interfaces[0], 'scope',
+ 'link', 'tentative']
+ for i in range(5):
+ output = ''
+ try:
+ output = subprocess.check_output(command)
+ except subprocess.CalledProcessError as e:
+ logger.warning('Could not confirm tentative IPv6 address: %s.', e.output)
+ if output:
+ logger.info('Found tentative ipv6 link address %s, sleeping 1 second.',
+ output.strip())
+ time.sleep(1)
+ else:
+ break
+
if dhclient_script and os.path.exists(dhclient_script):
dhclient_command += ['-sf', dhclient_script]