diff options
author | Chris Patterson <cpatterson@microsoft.com> | 2022-01-04 13:28:59 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-04 12:28:59 -0600 |
commit | 2fd80c633d09717b4d669848b814848748e91470 (patch) | |
tree | 5783d23fff3afb132a52d59b3ebd4858b1bb0c2c /cloudinit | |
parent | 137c9b0e56bf2a9d4651aeb4ceb210d85a630923 (diff) | |
download | vyos-cloud-init-2fd80c633d09717b4d669848b814848748e91470.tar.gz vyos-cloud-init-2fd80c633d09717b4d669848b814848748e91470.zip |
sources/azure: do not persist failed_desired_api_version flag (#1159)
If get_imds_data_with_api_fallback() falls back to the minimum required
API version, it is effectively pinned to the old API version forever.
Remove the failed_desired_api_version property to prevent persistence of
the flag between calls and/or reboots.
The continued presence of this flag in obj.pkl should be harmless.
Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
Diffstat (limited to 'cloudinit')
-rwxr-xr-x | cloudinit/sources/DataSourceAzure.py | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py index a8b403e8..f5630840 100755 --- a/cloudinit/sources/DataSourceAzure.py +++ b/cloudinit/sources/DataSourceAzure.py @@ -297,13 +297,10 @@ class DataSourceAzure(sources.DataSource): self.dhclient_lease_file = self.ds_cfg.get("dhclient_lease_file") self._network_config = None self._ephemeral_dhcp_ctx = None - self.failed_desired_api_version = False self.iso_dev = None def _unpickle(self, ci_pkl_version: int) -> None: super()._unpickle(ci_pkl_version) - if not hasattr(self, "failed_desired_api_version"): - self.failed_desired_api_version = False if not hasattr(self, "iso_dev"): self.iso_dev = None @@ -647,29 +644,24 @@ class DataSourceAzure(sources.DataSource): this fault tolerant and fall back to a good known minimum api version. """ - - if not self.failed_desired_api_version: - for _ in range(retries): - try: - LOG.info("Attempting IMDS api-version: %s", IMDS_VER_WANT) - return get_metadata_from_imds( - fallback_nic=fallback_nic, - retries=0, - md_type=md_type, - api_version=IMDS_VER_WANT, - exc_cb=exc_cb, - ) - except UrlError as err: - LOG.info( - "UrlError with IMDS api-version: %s", IMDS_VER_WANT + for _ in range(retries): + try: + LOG.info("Attempting IMDS api-version: %s", IMDS_VER_WANT) + return get_metadata_from_imds( + fallback_nic=fallback_nic, + retries=0, + md_type=md_type, + api_version=IMDS_VER_WANT, + exc_cb=exc_cb, + ) + except UrlError as err: + LOG.info("UrlError with IMDS api-version: %s", IMDS_VER_WANT) + if err.code == 400: + log_msg = "Fall back to IMDS api-version: {}".format( + IMDS_VER_MIN ) - if err.code == 400: - log_msg = "Fall back to IMDS api-version: {}".format( - IMDS_VER_MIN - ) - report_diagnostic_event(log_msg, logger_func=LOG.info) - self.failed_desired_api_version = True - break + report_diagnostic_event(log_msg, logger_func=LOG.info) + break LOG.info("Using IMDS api-version: %s", IMDS_VER_MIN) return get_metadata_from_imds( |