From 0a2f680f5ff7056db907b781e257d7c779ebb038 Mon Sep 17 00:00:00 2001 From: Gabriel Cocenza Date: Wed, 13 Dec 2023 11:30:21 -0300 Subject: [PATCH] Check if applications are active/idle before upgrading. - Without status check if the unit is on maintenance it will proceed to upgrade Closes: #199 --- cou/utils/juju_utils.py | 1 + tests/unit/utils/test_juju_utils.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/cou/utils/juju_utils.py b/cou/utils/juju_utils.py index 031934a6a..d15c13bc1 100644 --- a/cou/utils/juju_utils.py +++ b/cou/utils/juju_utils.py @@ -481,6 +481,7 @@ async def _wait_for_idle() -> None: timeout=timeout, idle_period=idle_period, raise_on_blocked=raise_on_blocked, + status="active", ) except (asyncio.exceptions.TimeoutError, JujuAppError, JujuUnitError) as error: # NOTE(rgildein): Catching TimeoutError raised as exception when wait_for_idle diff --git a/tests/unit/utils/test_juju_utils.py b/tests/unit/utils/test_juju_utils.py index e605d774f..93db72cf3 100644 --- a/tests/unit/utils/test_juju_utils.py +++ b/tests/unit/utils/test_juju_utils.py @@ -486,6 +486,7 @@ async def test_coumodel_wait_for_idle(mock_get_supported_apps, mocked_model): timeout=timeout, idle_period=juju_utils.DEFAULT_MODEL_IDLE_PERIOD, raise_on_blocked=False, + status="active", ) mock_get_supported_apps.assert_awaited_once_with() @@ -504,6 +505,7 @@ async def test_coumodel_wait_for_idle_apps(mock_get_supported_apps, mocked_model timeout=timeout, idle_period=juju_utils.DEFAULT_MODEL_IDLE_PERIOD, raise_on_blocked=False, + status="active", ) mock_get_supported_apps.assert_not_awaited() @@ -525,5 +527,6 @@ async def test_coumodel_wait_for_idle_timeout(mock_get_supported_apps, mocked_mo timeout=timeout, idle_period=juju_utils.DEFAULT_MODEL_IDLE_PERIOD, raise_on_blocked=False, + status="active", ) mock_get_supported_apps.assert_not_awaited()