Check for peer series upgrade in pause and status

Check whether peers have sent series upgrade notifications before
pausing a unit. If notifications have been sent then HA services
will have been shutdown and pausing will fail.

Similarly, if series upgrade notifications have been sent then
do not try and issue crm commands when assessing status.

Change-Id: I4de0ffe5d5e24578db614c2e8640ebd32b8cd469
Closes-Bug: #1877937
This commit is contained in:
Liam Young 2020-05-11 10:56:22 +00:00
parent 5726a41b1e
commit d860f3406c
3 changed files with 10 additions and 2 deletions

View File

@ -615,7 +615,9 @@ def update_nrpe_config():
@hooks.hook('pre-series-upgrade')
def series_upgrade_prepare():
set_unit_upgrading()
if not is_unit_paused_set():
# HA services are shutdown when the unit receives series upgrade
# notifications from peers so cannot pause services.
if not is_unit_paused_set() and not is_waiting_unit_series_upgrade_set():
pause_unit()
notify_peers_of_series_upgrade()

View File

@ -1180,6 +1180,9 @@ def assess_status_helper():
if is_unit_upgrading_set():
return ("blocked",
"Ready for do-release-upgrade. Set complete when finished")
if is_waiting_unit_series_upgrade_set():
return ("blocked",
"HA services shutdown, peers are ready for series upgrade")
if is_unit_paused_set():
return ("maintenance",
"Paused. Use 'resume' action to resume normal service.")

View File

@ -480,14 +480,17 @@ class TestHooks(test_utils.CharmTestCase):
hooks.hanode_relation_changed()
ha_relation_changed.assert_called_once_with()
@mock.patch.object(hooks, 'is_waiting_unit_series_upgrade_set')
@mock.patch.object(hooks, 'set_unit_upgrading')
@mock.patch.object(hooks, 'is_unit_paused_set')
@mock.patch.object(hooks, 'pause_unit')
@mock.patch.object(hooks, 'notify_peers_of_series_upgrade')
def test_series_upgrade_prepare(self, notify_peers_of_series_upgrade,
pause_unit, is_unit_paused_set,
set_unit_upgrading):
set_unit_upgrading,
is_waiting_unit_series_upgrade_set):
is_unit_paused_set.return_value = False
is_waiting_unit_series_upgrade_set.return_value = False
hooks.series_upgrade_prepare()
set_unit_upgrading.assert_called_once_with()
pause_unit.assert_called_once_with()