diff --git a/cou/apps/base.py b/cou/apps/base.py index 9148e59e..ddb0da63 100644 --- a/cou/apps/base.py +++ b/cou/apps/base.py @@ -645,15 +645,19 @@ def _set_action_managed_upgrade(self, enable: bool) -> UpgradeStep: ) return UpgradeStep() - if self.config["action-managed-upgrade"].get("value") == enable: + amu_config = self.config["action-managed-upgrade"].get("value") + if amu_config == enable: logger.debug( "%s application already has action-managed-upgrade set to %s", self.name, enable ) return UpgradeStep() return UpgradeStep( - f"Change charm config of '{self.name}' 'action-managed-upgrade' to '{enable}'", - coro=self.model.set_application_config(self.name, {"action-managed-upgrade": enable}), + f"Change charm config of '{self.name}' 'action-managed-upgrade' " + f"from '{amu_config}' to '{enable}'", + coro=self.model.set_application_config( + self.name, {"action-managed-upgrade": str(enable)} + ), ) def _get_pause_unit_step(self, unit: Unit, dependent: bool = False) -> UnitUpgradeStep: diff --git a/tests/mocked_plans/sample_plans/base.yaml b/tests/mocked_plans/sample_plans/base.yaml index 0dce9bb7..88f5624f 100644 --- a/tests/mocked_plans/sample_plans/base.yaml +++ b/tests/mocked_plans/sample_plans/base.yaml @@ -7,7 +7,7 @@ plan: | Upgrade software packages of 'keystone' from the current APT repositories Upgrade software packages on unit 'keystone/0' Refresh 'keystone' to the latest revision of 'ussuri/stable' - Change charm config of 'keystone' 'action-managed-upgrade' to 'False' + Change charm config of 'keystone' 'action-managed-upgrade' from 'True' to 'False' Upgrade 'keystone' to the new channel: 'victoria/stable' Change charm config of 'keystone' 'openstack-origin' to 'cloud:focal-victoria' Wait for up to 2400s for model 'base' to reach the idle state @@ -22,7 +22,7 @@ plan: | Upgrade software packages of 'nova-compute' from the current APT repositories Upgrade software packages on unit 'nova-compute/0' Refresh 'nova-compute' to the latest revision of 'ussuri/stable' - Change charm config of 'nova-compute' 'action-managed-upgrade' to 'True' + Change charm config of 'nova-compute' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'nova-compute' to the new channel: 'victoria/stable' Change charm config of 'nova-compute' 'source' to 'cloud:focal-victoria' Upgrade plan for units: nova-compute/0 diff --git a/tests/unit/apps/test_base.py b/tests/unit/apps/test_base.py index a8389f9a..e1f3da78 100644 --- a/tests/unit/apps/test_base.py +++ b/tests/unit/apps/test_base.py @@ -94,14 +94,14 @@ def test_application_get_latest_os_version_failed(mock_find_compatible_versions, ( {"action-managed-upgrade": {"value": False}}, True, - "Change charm config of 'my_app' 'action-managed-upgrade' to 'True'", + "Change charm config of 'my_app' 'action-managed-upgrade' from 'False' to 'True'", ), ({"action-managed-upgrade": {"value": False}}, False, None), ({"action-managed-upgrade": {"value": True}}, True, None), ( {"action-managed-upgrade": {"value": True}}, False, - "Change charm config of 'my_app' 'action-managed-upgrade' to 'False'", + "Change charm config of 'my_app' 'action-managed-upgrade' from 'True' to 'False'", ), ], ) @@ -113,7 +113,7 @@ def test_set_action_managed_upgrade(charm_config, enable, exp_description, model # Note (rgildein): we need to set exp_step here, since we need to use model fixture exp_step = UpgradeStep( description=exp_description, - coro=model.set_application_config(app_name, {"action-managed-upgrade": enable}), + coro=model.set_application_config(app_name, {"action-managed-upgrade": str(enable)}), ) else: exp_step = UpgradeStep() diff --git a/tests/unit/apps/test_core.py b/tests/unit/apps/test_core.py index 05df3af0..bb5f0c2f 100644 --- a/tests/unit/apps/test_core.py +++ b/tests/unit/apps/test_core.py @@ -212,9 +212,10 @@ def test_upgrade_plan_ussuri_to_victoria(model): coro=model.upgrade_charm(app.name, "ussuri/stable"), ), UpgradeStep( - description=f"Change charm config of '{app.name}' 'action-managed-upgrade' to 'False'", + description=f"Change charm config of '{app.name}' 'action-managed-upgrade' " + "from 'True' to 'False'", parallel=False, - coro=model.set_application_config(app.name, {"action-managed-upgrade": False}), + coro=model.set_application_config(app.name, {"action-managed-upgrade": str(False)}), ), UpgradeStep( description=f"Upgrade '{app.name}' to the new channel: 'victoria/stable'", @@ -296,9 +297,10 @@ def test_upgrade_plan_ussuri_to_victoria_ch_migration(model): coro=model.upgrade_charm(app.name, "ussuri/stable", switch="ch:keystone"), ), UpgradeStep( - description=f"Change charm config of '{app.name}' 'action-managed-upgrade' to 'False'", + description=f"Change charm config of '{app.name}' 'action-managed-upgrade' " + "from 'True' to 'False'", parallel=False, - coro=model.set_application_config(app.name, {"action-managed-upgrade": False}), + coro=model.set_application_config(app.name, {"action-managed-upgrade": str(False)}), ), UpgradeStep( description=f"Upgrade '{app.name}' to the new channel: 'victoria/stable'", @@ -379,9 +381,10 @@ def test_upgrade_plan_channel_on_next_os_release(model): upgrade_steps = [ upgrade_packages, UpgradeStep( - description=f"Change charm config of '{app.name}' 'action-managed-upgrade' to 'False'", + description=f"Change charm config of '{app.name}' 'action-managed-upgrade' " + "from 'True' to 'False'", parallel=False, - coro=model.set_application_config(app.name, {"action-managed-upgrade": False}), + coro=model.set_application_config(app.name, {"action-managed-upgrade": str(False)}), ), UpgradeStep( description=f"Change charm config of '{app.name}' " @@ -461,9 +464,10 @@ def test_upgrade_plan_origin_already_on_next_openstack_release(model): coro=model.upgrade_charm(app.name, "ussuri/stable"), ), UpgradeStep( - description=f"Change charm config of '{app.name}' 'action-managed-upgrade' to 'False'", + description=f"Change charm config of '{app.name}' 'action-managed-upgrade' " + "from 'True' to 'False'", parallel=False, - coro=model.set_application_config(app.name, {"action-managed-upgrade": False}), + coro=model.set_application_config(app.name, {"action-managed-upgrade": str(False)}), ), UpgradeStep( description=f"Upgrade '{app.name}' to the new channel: 'victoria/stable'", @@ -787,7 +791,7 @@ def test_nova_compute_upgrade_plan(model): Upgrade software packages on unit 'nova-compute/1' Upgrade software packages on unit 'nova-compute/2' Refresh 'nova-compute' to the latest revision of 'ussuri/stable' - Change charm config of 'nova-compute' 'action-managed-upgrade' to 'True' + Change charm config of 'nova-compute' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'nova-compute' to the new channel: 'victoria/stable' Change charm config of 'nova-compute' 'source' to 'cloud:focal-victoria' Upgrade plan for units: nova-compute/0, nova-compute/1, nova-compute/2 @@ -852,7 +856,7 @@ def test_nova_compute_upgrade_plan_single_unit(model): Upgrade software packages of 'nova-compute' from the current APT repositories Upgrade software packages on unit 'nova-compute/0' Refresh 'nova-compute' to the latest revision of 'ussuri/stable' - Change charm config of 'nova-compute' 'action-managed-upgrade' to 'True' + Change charm config of 'nova-compute' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'nova-compute' to the new channel: 'victoria/stable' Change charm config of 'nova-compute' 'source' to 'cloud:focal-victoria' Upgrade plan for units: nova-compute/0 @@ -954,7 +958,7 @@ def test_cinder_upgrade_plan_single_unit(model): Upgrade software packages of 'cinder' from the current APT repositories Upgrade software packages on unit 'cinder/0' Refresh 'cinder' to the latest revision of 'ussuri/stable' - Change charm config of 'cinder' 'action-managed-upgrade' to 'True' + Change charm config of 'cinder' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'cinder' to the new channel: 'victoria/stable' Change charm config of 'cinder' 'openstack-origin' to 'cloud:focal-victoria' Upgrade plan for units: cinder/0 diff --git a/tests/unit/steps/test_hypervisor.py b/tests/unit/steps/test_hypervisor.py index f9fbcc93..8ce73073 100644 --- a/tests/unit/steps/test_hypervisor.py +++ b/tests/unit/steps/test_hypervisor.py @@ -400,7 +400,7 @@ def test_hypervisor_upgrade_plan(model): Upgrade software packages of 'nova-compute' from the current APT repositories Upgrade software packages on unit 'nova-compute/0' Refresh 'nova-compute' to the latest revision of 'ussuri/stable' - Change charm config of 'cinder' 'action-managed-upgrade' to 'True' + Change charm config of 'cinder' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'cinder' to the new channel: 'victoria/stable' Change charm config of 'cinder' 'openstack-origin' to 'cloud:focal-victoria' Upgrade plan for units: cinder/0 @@ -408,7 +408,7 @@ def test_hypervisor_upgrade_plan(model): Pause the unit: 'cinder/0' Upgrade the unit: 'cinder/0' Resume the unit: 'cinder/0' - Change charm config of 'nova-compute' 'action-managed-upgrade' to 'True' + Change charm config of 'nova-compute' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'nova-compute' to the new channel: 'victoria/stable' Change charm config of 'nova-compute' 'source' to 'cloud:focal-victoria' Upgrade plan for units: nova-compute/0 @@ -427,7 +427,7 @@ def test_hypervisor_upgrade_plan(model): Upgrade software packages of 'nova-compute' from the current APT repositories Upgrade software packages on unit 'nova-compute/1' Refresh 'nova-compute' to the latest revision of 'ussuri/stable' - Change charm config of 'nova-compute' 'action-managed-upgrade' to 'True' + Change charm config of 'nova-compute' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'nova-compute' to the new channel: 'victoria/stable' Change charm config of 'nova-compute' 'source' to 'cloud:focal-victoria' Upgrade plan for units: nova-compute/1 @@ -444,7 +444,7 @@ def test_hypervisor_upgrade_plan(model): Upgrade software packages of 'nova-compute' from the current APT repositories Upgrade software packages on unit 'nova-compute/2' Refresh 'nova-compute' to the latest revision of 'ussuri/stable' - Change charm config of 'nova-compute' 'action-managed-upgrade' to 'True' + Change charm config of 'nova-compute' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'nova-compute' to the new channel: 'victoria/stable' Change charm config of 'nova-compute' 'source' to 'cloud:focal-victoria' Upgrade plan for units: nova-compute/2 @@ -527,7 +527,7 @@ def test_hypervisor_upgrade_plan_single_machine(model): Upgrade software packages of 'nova-compute' from the current APT repositories Upgrade software packages on unit 'nova-compute/0' Refresh 'nova-compute' to the latest revision of 'ussuri/stable' - Change charm config of 'cinder' 'action-managed-upgrade' to 'True' + Change charm config of 'cinder' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'cinder' to the new channel: 'victoria/stable' Change charm config of 'cinder' 'openstack-origin' to 'cloud:focal-victoria' Upgrade plan for units: cinder/0 @@ -535,7 +535,7 @@ def test_hypervisor_upgrade_plan_single_machine(model): Pause the unit: 'cinder/0' Upgrade the unit: 'cinder/0' Resume the unit: 'cinder/0' - Change charm config of 'nova-compute' 'action-managed-upgrade' to 'True' + Change charm config of 'nova-compute' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'nova-compute' to the new channel: 'victoria/stable' Change charm config of 'nova-compute' 'source' to 'cloud:focal-victoria' Upgrade plan for units: nova-compute/0 diff --git a/tests/unit/steps/test_plan.py b/tests/unit/steps/test_plan.py index 945f3d63..d9b4faec 100644 --- a/tests/unit/steps/test_plan.py +++ b/tests/unit/steps/test_plan.py @@ -152,7 +152,7 @@ async def test_generate_plan(mock_filter_hypervisors, model, cli_args): Upgrade software packages of 'keystone' from the current APT repositories Upgrade software packages on unit 'keystone/0' Refresh 'keystone' to the latest revision of 'ussuri/stable' - Change charm config of 'keystone' 'action-managed-upgrade' to 'False' + Change charm config of 'keystone' 'action-managed-upgrade' from 'True' to 'False' Upgrade 'keystone' to the new channel: 'victoria/stable' Change charm config of 'keystone' 'openstack-origin' to 'cloud:focal-victoria' Wait for up to 2400s for model 'test_model' to reach the idle state @@ -167,7 +167,7 @@ async def test_generate_plan(mock_filter_hypervisors, model, cli_args): Upgrade software packages of 'nova-compute' from the current APT repositories Upgrade software packages on unit 'nova-compute/0' Refresh 'nova-compute' to the latest revision of 'ussuri/stable' - Change charm config of 'nova-compute' 'action-managed-upgrade' to 'True' + Change charm config of 'nova-compute' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'nova-compute' to the new channel: 'victoria/stable' Change charm config of 'nova-compute' 'source' to 'cloud:focal-victoria' Upgrade plan for units: nova-compute/0 @@ -192,7 +192,7 @@ async def test_generate_plan(mock_filter_hypervisors, model, cli_args): Data Plane subordinate(s) upgrade plan Upgrade plan for 'ovn-chassis' to 'victoria' Refresh 'ovn-chassis' to the latest revision of '22.03/stable' - """ + """ # noqa: E501 line too long ) cli_args.upgrade_group = None cli_args.force = False @@ -323,7 +323,7 @@ async def test_generate_plan_with_warning_messages(mock_filter_hypervisors, mode Upgrade software packages of 'nova-compute' from the current APT repositories Upgrade software packages on unit 'nova-compute/0' Refresh 'nova-compute' to the latest revision of 'ussuri/stable' - Change charm config of 'nova-compute' 'action-managed-upgrade' to 'True' + Change charm config of 'nova-compute' 'action-managed-upgrade' from 'False' to 'True' Upgrade 'nova-compute' to the new channel: 'victoria/stable' Change charm config of 'nova-compute' 'source' to 'cloud:focal-victoria' Upgrade plan for units: nova-compute/0 @@ -348,7 +348,7 @@ async def test_generate_plan_with_warning_messages(mock_filter_hypervisors, mode Data Plane subordinate(s) upgrade plan Upgrade plan for 'ovn-chassis' to 'victoria' Refresh 'ovn-chassis' to the latest revision of '22.03/stable' - """ + """ # noqa: E501 line too long ) cli_args.upgrade_group = None cli_args.force = False