diff options
author | James Falcon <therealfalcon@gmail.com> | 2021-09-24 10:53:41 -0500 |
---|---|---|
committer | James Falcon <therealfalcon@gmail.com> | 2021-09-24 10:53:41 -0500 |
commit | 24b0234598a2ba8e961a2440a28146e53259943a (patch) | |
tree | 00636424534fdc5fd411218c345c38d14c6083aa | |
parent | c484729b3495e16d32d12b834b76737babc58b01 (diff) | |
download | cloud-init-git-24b0234598a2ba8e961a2440a28146e53259943a.tar.gz |
Revert "cherry pick 28e56d99"
This reverts commit 182b7ca9817352d5f2f433ffb9d4ec6ee95cdafa.
-rw-r--r-- | debian/patches/cpick-28e56d99-Azure-Retry-dhcp-on-timeouts-when-polling | 73 | ||||
-rw-r--r-- | debian/patches/series | 1 |
2 files changed, 0 insertions, 74 deletions
diff --git a/debian/patches/cpick-28e56d99-Azure-Retry-dhcp-on-timeouts-when-polling b/debian/patches/cpick-28e56d99-Azure-Retry-dhcp-on-timeouts-when-polling deleted file mode 100644 index db914b45..00000000 --- a/debian/patches/cpick-28e56d99-Azure-Retry-dhcp-on-timeouts-when-polling +++ /dev/null @@ -1,73 +0,0 @@ -From 28e56d993fc40feab139f149dacc10cae51a3fe0 Mon Sep 17 00:00:00 2001 -From: aswinrajamannar <39812128+aswinrajamannar@users.noreply.github.com> -Date: Tue, 24 Aug 2021 13:45:41 -0700 -Subject: [PATCH] Azure: Retry dhcp on timeouts when polling reprovisiondata - (#998) - -In the nic attach path, we skip doing dhcp since we already did it -when bringing the interface up. However when polling for -reprovisiondata, it is possible for the request to timeout due to -platform issues. In those cases we still need to do dhcp and try again -since we tear down the context. We can only skip the first dhcp -attempt. ---- - cloudinit/sources/DataSourceAzure.py | 4 +++ - tests/unittests/test_datasource/test_azure.py | 34 +++++++++++++++++++ - 2 files changed, 38 insertions(+) - ---- a/cloudinit/sources/DataSourceAzure.py -+++ b/cloudinit/sources/DataSourceAzure.py -@@ -1317,6 +1317,10 @@ class DataSourceAzure(sources.DataSource - except UrlError: - # Teardown our EphemeralDHCPv4 context on failure as we retry - self._ephemeral_dhcp_ctx.clean_network() -+ -+ # Also reset this flag which determines if we should do dhcp -+ # during retries. -+ is_ephemeral_ctx_present = False - finally: - if nl_sock: - nl_sock.close() ---- a/tests/unittests/test_datasource/test_azure.py -+++ b/tests/unittests/test_datasource/test_azure.py -@@ -3055,6 +3055,40 @@ class TestPreprovisioningPollIMDS(CiTest - self.assertEqual(0, m_dhcp.call_count) - self.assertEqual(0, m_media_switch.call_count) - -+ @mock.patch('os.path.isfile') -+ @mock.patch(MOCKPATH + 'EphemeralDHCPv4') -+ def test_poll_imds_does_dhcp_on_retries_if_ctx_present( -+ self, m_ephemeral_dhcpv4, m_isfile, report_ready_func, m_request, -+ m_media_switch, m_dhcp, m_net): -+ """The poll_imds function should reuse the dhcp ctx if it is already -+ present. This happens when we wait for nic to be hot-attached before -+ polling for reprovisiondata. Note that if this ctx is set when -+ _poll_imds is called, then it is not expected to be waiting for -+ media_disconnect_connect either.""" -+ -+ tries = 0 -+ -+ def fake_timeout_once(**kwargs): -+ nonlocal tries -+ tries += 1 -+ if tries == 1: -+ raise requests.Timeout('Fake connection timeout') -+ return mock.MagicMock(status_code=200, text="good", content="good") -+ -+ m_request.side_effect = fake_timeout_once -+ report_file = self.tmp_path('report_marker', self.tmp) -+ m_isfile.return_value = True -+ dsa = dsaz.DataSourceAzure({}, distro=None, paths=self.paths) -+ with mock.patch(MOCKPATH + 'REPORTED_READY_MARKER_FILE', report_file),\ -+ mock.patch.object(dsa, '_ephemeral_dhcp_ctx') as m_dhcp_ctx: -+ m_dhcp_ctx.obtain_lease.return_value = "Dummy lease" -+ dsa._ephemeral_dhcp_ctx = m_dhcp_ctx -+ dsa._poll_imds() -+ self.assertEqual(1, m_dhcp_ctx.clean_network.call_count) -+ self.assertEqual(1, m_ephemeral_dhcpv4.call_count) -+ self.assertEqual(0, m_media_switch.call_count) -+ self.assertEqual(2, m_request.call_count) -+ - def test_does_not_poll_imds_report_ready_when_marker_file_exists( - self, m_report_ready, m_request, m_media_switch, m_dhcp, m_net): - """poll_imds should not call report ready when the reported ready diff --git a/debian/patches/series b/debian/patches/series index 1bf0cbdf..b71d6b73 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,4 +1,3 @@ openstack-no-network-config.patch ec2-dont-apply-full-imds-network-config.patch renderer-do-not-prefer-netplan.patch -cpick-28e56d99-Azure-Retry-dhcp-on-timeouts-when-polling |