[Cloud-init-dev] [Merge] ~vtqanh/cloud-init:adjustIMDSTimeout into cloud-init:master

2019-05-07 Thread Anh Vo (MSFT)
Anh Vo (MSFT) has proposed merging ~vtqanh/cloud-init:adjustIMDSTimeout into 
cloud-init:master.

Commit message:
DataSourceAzure: Adjust timeout for polling IMDS

If the IMDS primary server is not available, falling back to the
secondary server takes about 1s. The net result is that the
expected E2E time is slightly more than 1s. This change increases
the timeout to 2s to prevent the infinite loop of timeouts.

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~vtqanh/cloud-init/+git/cloud-init/+merge/367082
-- 
Your team cloud-init commiters is requested to review the proposed merge of 
~vtqanh/cloud-init:adjustIMDSTimeout into cloud-init:master.
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index 6416525..b7440c1 100755
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -57,7 +57,12 @@ AZURE_CHASSIS_ASSET_TAG = '7783-7084-3265-9085-8269-3286-77'
 REPROVISION_MARKER_FILE = "/var/lib/cloud/data/poll_imds"
 REPORTED_READY_MARKER_FILE = "/var/lib/cloud/data/reported_ready"
 AGENT_SEED_DIR = '/var/lib/waagent'
+
+# In the event where the IMDS primary server is not
+# available, it takes 1s to fallback to the secondary one
+IMDS_TIMEOUT_IN_SECONDS = 2
 IMDS_URL = "http://169.254.169.254/metadata/;
+
 PLATFORM_ENTROPY_SOURCE = "/sys/firmware/acpi/tables/OEM0"
 
 # List of static scripts and network config artifacts created by
@@ -582,9 +587,9 @@ class DataSourceAzure(sources.DataSource):
 return
 self._ephemeral_dhcp_ctx.clean_network()
 else:
-return readurl(url, timeout=1, headers=headers,
-   exception_cb=exc_cb, infinite=True,
-   log_req_resp=False).contents
+return readurl(url, timeout=IMDS_TIMEOUT_IN_SECONDS,
+   headers=headers, exception_cb=exc_cb,
+   infinite=True, log_req_resp=False).contents
 except UrlError:
 # Teardown our EphemeralDHCPv4 context on failure as we retry
 self._ephemeral_dhcp_ctx.clean_network()
@@ -1291,8 +1296,8 @@ def _get_metadata_from_imds(retries):
 headers = {"Metadata": "true"}
 try:
 response = readurl(
-url, timeout=1, headers=headers, retries=retries,
-exception_cb=retry_on_url_exc)
+url, timeout=IMDS_TIMEOUT_IN_SECONDS, headers=headers,
+retries=retries, exception_cb=retry_on_url_exc)
 except Exception as e:
 LOG.debug('Ignoring IMDS instance metadata: %s', e)
 return {}
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
index ab77c03..427ab7e 100644
--- a/tests/unittests/test_datasource/test_azure.py
+++ b/tests/unittests/test_datasource/test_azure.py
@@ -163,7 +163,8 @@ class TestGetMetadataFromIMDS(HttprettyTestCase):
 
 m_readurl.assert_called_with(
 self.network_md_url, exception_cb=mock.ANY,
-headers={'Metadata': 'true'}, retries=2, timeout=1)
+headers={'Metadata': 'true'}, retries=2,
+timeout=dsaz.IMDS_TIMEOUT_IN_SECONDS)
 
 @mock.patch('cloudinit.url_helper.time.sleep')
 @mock.patch(MOCKPATH + 'net.is_up')
@@ -1791,7 +1792,8 @@ class TestAzureDataSourcePreprovisioning(CiTestCase):
 headers={'Metadata': 'true',
  'User-Agent':
  'Cloud-Init/%s' % vs()
- }, method='GET', timeout=1,
+ }, method='GET',
+timeout=dsaz.IMDS_TIMEOUT_IN_SECONDS,
 url=full_url)])
 self.assertEqual(m_dhcp.call_count, 2)
 m_net.assert_any_call(
@@ -1828,7 +1830,9 @@ class TestAzureDataSourcePreprovisioning(CiTestCase):
 headers={'Metadata': 'true',
  'User-Agent':
  'Cloud-Init/%s' % vs()},
-method='GET', timeout=1, url=full_url)])
+method='GET',
+timeout=dsaz.IMDS_TIMEOUT_IN_SECONDS,
+url=full_url)])
 self.assertEqual(m_dhcp.call_count, 2)
 m_net.assert_any_call(
 broadcast='192.168.2.255', interface='eth9', ip='192.168.2.9',
___
Mailing list: https://launchpad.net/~cloud-init-dev
Post to : cloud-init-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~cloud-init-dev
More help   : https://help.launchpad.net/ListHelp


[Cloud-init-dev] [Merge] ~daniel-thewatkins/cloud-init/+git/cloud-init:warn into cloud-init:master

2019-05-07 Thread Dan Watkins
Dan Watkins has proposed merging 
~daniel-thewatkins/cloud-init/+git/cloud-init:warn into cloud-init:master.

Requested reviews:
  cloud-init commiters (cloud-init-dev)
Related bugs:
  Bug #1508442 in cloud-init: "LOG.warn is deprecated"
  https://bugs.launchpad.net/cloud-init/+bug/1508442

For more details, see:
https://code.launchpad.net/~daniel-thewatkins/cloud-init/+git/cloud-init/+merge/367054
-- 
Your team cloud-init commiters is requested to review the proposed merge of 
~daniel-thewatkins/cloud-init/+git/cloud-init:warn into cloud-init:master.
diff --git a/cloudinit/sources/DataSourceCloudStack.py b/cloudinit/sources/DataSourceCloudStack.py
index d4b758f..f185dc7 100644
--- a/cloudinit/sources/DataSourceCloudStack.py
+++ b/cloudinit/sources/DataSourceCloudStack.py
@@ -95,7 +95,7 @@ class DataSourceCloudStack(sources.DataSource):
 start_time = time.time()
 url = uhelp.wait_for_url(
 urls=urls, max_wait=url_params.max_wait_seconds,
-timeout=url_params.timeout_seconds, status_cb=LOG.warn)
+timeout=url_params.timeout_seconds, status_cb=LOG.warning)
 
 if url:
 LOG.debug("Using metadata source: '%s'", url)
diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py
index ac28f1d..5c017bf 100644
--- a/cloudinit/sources/DataSourceEc2.py
+++ b/cloudinit/sources/DataSourceEc2.py
@@ -208,7 +208,7 @@ class DataSourceEc2(sources.DataSource):
 start_time = time.time()
 url = uhelp.wait_for_url(
 urls=urls, max_wait=url_params.max_wait_seconds,
-timeout=url_params.timeout_seconds, status_cb=LOG.warn)
+timeout=url_params.timeout_seconds, status_cb=LOG.warning)
 
 if url:
 self.metadata_address = url2base[url]
___
Mailing list: https://launchpad.net/~cloud-init-dev
Post to : cloud-init-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~cloud-init-dev
More help   : https://help.launchpad.net/ListHelp