diff options
author | James Falcon <james.falcon@canonical.com> | 2021-10-19 14:58:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-19 13:58:56 -0600 |
commit | 150fd30ef81cea5c2b0aff5127e33a5db786aa09 (patch) | |
tree | aa81b4d150335464760d6db6b14c195030913ae3 | |
parent | ee296ced9c0a61b1484d850b807c601bcd670ec1 (diff) | |
download | vyos-cloud-init-150fd30ef81cea5c2b0aff5127e33a5db786aa09.tar.gz vyos-cloud-init-150fd30ef81cea5c2b0aff5127e33a5db786aa09.zip |
Update Azure _unpickle (SC-500) (#1067)
When self.failed_desired_api_version was added to DataSourceAzure, the
attribute was never added to the _unpickle method using the upgrade
framework. This commit adds the attribute.
LP: #1946644
-rwxr-xr-x | cloudinit/sources/DataSourceAzure.py | 4 | ||||
-rw-r--r-- | tests/integration_tests/test_upgrade.py | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py index f8641dfd..26c407ef 100755 --- a/cloudinit/sources/DataSourceAzure.py +++ b/cloudinit/sources/DataSourceAzure.py @@ -363,7 +363,9 @@ class DataSourceAzure(sources.DataSource): def _unpickle(self, ci_pkl_version: int) -> None: super()._unpickle(ci_pkl_version) - if "iso_dev" not in self.__dict__: + if not hasattr(self, "failed_desired_api_version"): + self.failed_desired_api_version = False + if not hasattr(self, "iso_dev"): self.iso_dev = None def __str__(self): diff --git a/tests/integration_tests/test_upgrade.py b/tests/integration_tests/test_upgrade.py index e90a5f9d..0ba4754c 100644 --- a/tests/integration_tests/test_upgrade.py +++ b/tests/integration_tests/test_upgrade.py @@ -84,11 +84,8 @@ def test_clean_boot_of_upgraded_package(session_cloud: IntegrationCloud): 'There were errors/warnings/tracebacks pre-upgrade. ' 'Any failures may be due to pre-upgrade problem') - # Upgrade and reboot + # Upgrade instance.install_new_cloud_init(source, take_snapshot=False) - instance.execute('hostname something-else') - instance.restart() - assert instance.execute('cloud-init status --wait --long').ok # 'cloud-init init' helps us understand if our pickling upgrade paths # have broken across re-constitution of a cached datasource. Some @@ -96,6 +93,11 @@ def test_clean_boot_of_upgraded_package(session_cloud: IntegrationCloud): # it here to ensure we get a dirty run. assert instance.execute('cloud-init init').ok + # Reboot + instance.execute('hostname something-else') + instance.restart() + assert instance.execute('cloud-init status --wait --long').ok + # get post values post_hostname = instance.execute('hostname') post_cloud_id = instance.execute('cloud-id') |