Ensure that upgrading non-leader first can handle pause arguments
This commit is contained in:
@@ -107,11 +107,15 @@ def run_post_upgrade_functions(post_upgrade_functions):
|
||||
cl_utils.get_class(func)()
|
||||
|
||||
|
||||
def series_upgrade_non_leaders_first(application, from_series="trusty",
|
||||
to_series="xenial",
|
||||
origin='openstack-origin',
|
||||
completed_machines=[],
|
||||
post_upgrade_functions=None):
|
||||
def series_upgrade_non_leaders_first(
|
||||
application, from_series="trusty",
|
||||
to_series="xenial",
|
||||
origin='openstack-origin',
|
||||
completed_machines=[],
|
||||
post_upgrade_functions=None,
|
||||
pause_non_leader_primary=False,
|
||||
pause_non_leader_subordinate=False
|
||||
):
|
||||
"""Series upgrade non leaders first.
|
||||
|
||||
Wrap all the functionality to handle series upgrade for charms
|
||||
@@ -129,6 +133,14 @@ def series_upgrade_non_leaders_first(application, from_series="trusty",
|
||||
:param completed_machines: List of completed machines which do no longer
|
||||
require series upgrade.
|
||||
:type completed_machines: list
|
||||
:param pause_non_leader_primary: Whether the non-leader applications should
|
||||
be paused
|
||||
:type pause_non_leader_primary: bool
|
||||
:param pause_non_leader_subordinate: Whether the non-leader subordinate
|
||||
hacluster applications should be
|
||||
paused
|
||||
:type pause_non_leader_subordinate: bool
|
||||
:param from_series: The series from which to upgrade
|
||||
:returns: None
|
||||
:rtype: None
|
||||
"""
|
||||
@@ -141,6 +153,23 @@ def series_upgrade_non_leaders_first(application, from_series="trusty",
|
||||
else:
|
||||
non_leaders.append(unit)
|
||||
|
||||
# Pause the non-leaders
|
||||
for unit in non_leaders:
|
||||
if pause_non_leader_subordinate:
|
||||
if status["units"][unit].get("subordinates"):
|
||||
for subordinate in status["units"][unit]["subordinates"]:
|
||||
_app = subordinate.split('/')[0]
|
||||
if _app in SUBORDINATE_PAUSE_RESUME_BLACKLIST:
|
||||
logging.info("Skipping pausing {} - blacklisted"
|
||||
.format(subordinate))
|
||||
else:
|
||||
logging.info("Pausing {}".format(subordinate))
|
||||
model.run_action(
|
||||
subordinate, "pause", action_params={})
|
||||
if pause_non_leader_primary:
|
||||
logging.info("Pausing {}".format(unit))
|
||||
model.run_action(unit, "pause", action_params={})
|
||||
|
||||
# Series upgrade the non-leaders first
|
||||
for unit in non_leaders:
|
||||
machine = status["units"][unit]["machine"]
|
||||
@@ -173,12 +202,16 @@ def series_upgrade_non_leaders_first(application, from_series="trusty",
|
||||
model.block_until_all_units_idle()
|
||||
|
||||
|
||||
async def async_series_upgrade_non_leaders_first(application,
|
||||
from_series="trusty",
|
||||
to_series="xenial",
|
||||
origin='openstack-origin',
|
||||
completed_machines=[],
|
||||
post_upgrade_functions=None):
|
||||
async def async_series_upgrade_non_leaders_first(
|
||||
application,
|
||||
from_series="trusty",
|
||||
to_series="xenial",
|
||||
origin='openstack-origin',
|
||||
completed_machines=[],
|
||||
post_upgrade_functions=None,
|
||||
pause_non_leader_primary=False,
|
||||
pause_non_leader_subordinate=False
|
||||
):
|
||||
"""Series upgrade non leaders first.
|
||||
|
||||
Wrap all the functionality to handle series upgrade for charms
|
||||
@@ -196,6 +229,14 @@ async def async_series_upgrade_non_leaders_first(application,
|
||||
:param completed_machines: List of completed machines which do no longer
|
||||
require series upgrade.
|
||||
:type completed_machines: list
|
||||
:param pause_non_leader_primary: Whether the non-leader applications should
|
||||
be paused
|
||||
:type pause_non_leader_primary: bool
|
||||
:param pause_non_leader_subordinate: Whether the non-leader subordinate
|
||||
hacluster applications should be
|
||||
paused
|
||||
:type pause_non_leader_subordinate: bool
|
||||
:param from_series: The series from which to upgrade
|
||||
:returns: None
|
||||
:rtype: None
|
||||
"""
|
||||
@@ -208,6 +249,23 @@ async def async_series_upgrade_non_leaders_first(application,
|
||||
else:
|
||||
non_leaders.append(unit)
|
||||
|
||||
# Pause the non-leaders
|
||||
for unit in non_leaders:
|
||||
if pause_non_leader_subordinate:
|
||||
if status["units"][unit].get("subordinates"):
|
||||
for subordinate in status["units"][unit]["subordinates"]:
|
||||
_app = subordinate.split('/')[0]
|
||||
if _app in SUBORDINATE_PAUSE_RESUME_BLACKLIST:
|
||||
logging.info("Skipping pausing {} - blacklisted"
|
||||
.format(subordinate))
|
||||
else:
|
||||
logging.info("Pausing {}".format(subordinate))
|
||||
await model.async_run_action(
|
||||
subordinate, "pause", action_params={})
|
||||
if pause_non_leader_primary:
|
||||
logging.info("Pausing {}".format(unit))
|
||||
await model.async_run_action(unit, "pause", action_params={})
|
||||
|
||||
# Series upgrade the non-leaders first
|
||||
for unit in non_leaders:
|
||||
machine = status["units"][unit]["machine"]
|
||||
|
||||
Reference in New Issue
Block a user