summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceAzure.py
diff options
context:
space:
mode:
authorasakkurr <asakkurr@microsoft.com>2018-10-31 20:19:15 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2018-10-31 20:19:15 +0000
commit907395104bb5850d221924365102cc5ab0eca2f1 (patch)
tree0ce9d2eca6abde46bc75acb62e970ab52c751217 /cloudinit/sources/DataSourceAzure.py
parentd74d3f0ff5c8d453f626b113f4e6065322f822fa (diff)
downloadvyos-cloud-init-907395104bb5850d221924365102cc5ab0eca2f1.tar.gz
vyos-cloud-init-907395104bb5850d221924365102cc5ab0eca2f1.zip
azure: report ready to fabric after reprovision and reduce logging
When reusing a preprovisioned VM, report ready to Azure fabric as soon as we get the reprovision data and the goal state so that we are not delayed by the cloud-init stage switch, saving 2-3 seconds. Also reduce logging when polling IMDS for reprovision data. LP: #1799594
Diffstat (limited to 'cloudinit/sources/DataSourceAzure.py')
-rw-r--r--cloudinit/sources/DataSourceAzure.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index d0358e96..8642915e 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -267,6 +267,7 @@ class DataSourceAzure(sources.DataSource):
dsname = 'Azure'
_negotiated = False
_metadata_imds = sources.UNSET
+ lease_info = None
def __init__(self, sys_cfg, distro, paths):
sources.DataSource.__init__(self, sys_cfg, distro, paths)
@@ -406,8 +407,10 @@ class DataSourceAzure(sources.DataSource):
LOG.warning("%s was not mountable", cdev)
continue
+ should_report_ready_after_reprovision = False
if reprovision or self._should_reprovision(ret):
ret = self._reprovision()
+ should_report_ready_after_reprovision = True
imds_md = get_metadata_from_imds(
self.fallback_interface, retries=3)
(md, userdata_raw, cfg, files) = ret
@@ -434,6 +437,11 @@ class DataSourceAzure(sources.DataSource):
crawled_data['metadata']['random_seed'] = seed
crawled_data['metadata']['instance-id'] = util.read_dmi_data(
'system-uuid')
+
+ if should_report_ready_after_reprovision:
+ LOG.info("Reporting ready to Azure after getting ReprovisionData")
+ self._report_ready(lease=self.lease_info)
+
return crawled_data
def _is_platform_viable(self):
@@ -522,6 +530,7 @@ class DataSourceAzure(sources.DataSource):
while True:
try:
with EphemeralDHCPv4() as lease:
+ self.lease_info = lease
if report_ready:
path = REPORTED_READY_MARKER_FILE
LOG.info(
@@ -531,13 +540,13 @@ class DataSourceAzure(sources.DataSource):
self._report_ready(lease=lease)
report_ready = False
return readurl(url, timeout=1, headers=headers,
- exception_cb=exc_cb, infinite=True).contents
+ exception_cb=exc_cb, infinite=True,
+ log_req_resp=False).contents
except UrlError:
pass
def _report_ready(self, lease):
- """Tells the fabric provisioning has completed
- before we go into our polling loop."""
+ """Tells the fabric provisioning has completed """
try:
get_metadata_from_fabric(None, lease['unknown-245'])
except Exception: