summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceAzure.py
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2018-11-15 22:55:42 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2018-11-15 22:55:42 +0000
commit8f812a15fde01173c0dd5b7e1a77b61031fd93e4 (patch)
tree58d27750db0ca4278d645a0c25d1a5dd210d0ae4 /cloudinit/sources/DataSourceAzure.py
parenta3812a4ab4eeb2aa185eb4a2de186cc60ddd7c03 (diff)
downloadvyos-cloud-init-8f812a15fde01173c0dd5b7e1a77b61031fd93e4.tar.gz
vyos-cloud-init-8f812a15fde01173c0dd5b7e1a77b61031fd93e4.zip
azure: _poll_imds only retry on 404. Fail on Timeout
Upon URL timeout, _poll_imds is expected to re-dhcp to get updated IP configuration. We don't want to indefinitely retry because the instance likely has invalid IP configuration. LP: #1803598
Diffstat (limited to 'cloudinit/sources/DataSourceAzure.py')
-rw-r--r--cloudinit/sources/DataSourceAzure.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index 9e8a1a8b..2a3e5677 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -526,6 +526,13 @@ class DataSourceAzure(sources.DataSource):
report_ready = bool(not os.path.isfile(REPORTED_READY_MARKER_FILE))
LOG.debug("Start polling IMDS")
+ def exc_cb(msg, exception):
+ if isinstance(exception, UrlError) and exception.code == 404:
+ return True
+ # If we get an exception while trying to call IMDS, we
+ # call DHCP and setup the ephemeral network to acquire the new IP.
+ return False
+
while True:
try:
# Save our EphemeralDHCPv4 context so we avoid repeated dhcp
@@ -540,7 +547,7 @@ class DataSourceAzure(sources.DataSource):
self._report_ready(lease=lease)
report_ready = False
return readurl(url, timeout=1, headers=headers,
- exception_cb=retry_on_url_exc, infinite=True,
+ exception_cb=exc_cb, infinite=True,
log_req_resp=False).contents
except UrlError:
# Teardown our EphemeralDHCPv4 context on failure as we retry