Skip to content

Commit

Permalink
Merge branch 'dev/data-plane' into nova-compute-helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcocenza committed Feb 6, 2024
2 parents 76c57f0 + 12dedbe commit 86335ae
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 96 deletions.
25 changes: 11 additions & 14 deletions cou/apps/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,31 +139,28 @@ class CephMonApplication(OpenStackAuxiliaryApplication):
wait_timeout = 30 * 60 # 30 min
wait_for_model = True

def pre_upgrade_plan(self, target: OpenStackRelease) -> list[PreUpgradeStep]:
"""Pre Upgrade planning.
def pre_upgrade_steps(self, target: OpenStackRelease) -> list[PreUpgradeStep]:
"""Pre Upgrade steps planning.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:return: Plan that will add pre upgrade as sub steps.
:return: List of pre upgrade steps.
:rtype: list[PreUpgradeStep]
"""
return super().pre_upgrade_plan(target) + [self._get_change_require_osd_release_plan()]
return super().pre_upgrade_steps(target) + [self._get_change_require_osd_release_step()]

def _get_change_require_osd_release_plan(self, parallel: bool = False) -> PreUpgradeStep:
"""Get plan to set correct value for require-osd-release option on ceph-mon.
def _get_change_require_osd_release_step(self) -> PreUpgradeStep:
"""Get the step to set correct value for require-osd-release option on ceph-mon.
This step is needed as a workaround for LP#1929254. Reference:
https://docs.openstack.org/charm-guide/latest/project/issues/upgrade-issues.html#ceph-require-osd-release
:param parallel: Parallel running, defaults to False
:type parallel: bool, optional
:return: Plan to check and set correct value for require-osd-release
:return: Step to check and set correct value for require-osd-release
:rtype: PreUpgradeStep
"""
ceph_mon_unit, *_ = self.units
return PreUpgradeStep(
description="Ensure require-osd-release option matches with ceph-osd version",
parallel=parallel,
coro=set_require_osd_release_option(ceph_mon_unit.name, self.model),
)

Expand All @@ -172,17 +169,17 @@ def _get_change_require_osd_release_plan(self, parallel: bool = False) -> PreUpg
class OvnPrincipalApplication(OpenStackAuxiliaryApplication):
"""Ovn principal application class."""

def pre_upgrade_plan(self, target: OpenStackRelease) -> list[PreUpgradeStep]:
"""Pre Upgrade planning.
def pre_upgrade_steps(self, target: OpenStackRelease) -> list[PreUpgradeStep]:
"""Pre Upgrade steps planning.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:return: Plan that will add pre upgrade as sub steps.
:return: List of pre upgrade steps.
:rtype: list[PreUpgradeStep]
"""
for unit in self.units:
validate_ovn_support(unit.workload_version)
return super().pre_upgrade_plan(target)
return super().pre_upgrade_steps(target)


@AppFactory.register_application(["mysql-innodb-cluster"])
Expand Down
8 changes: 4 additions & 4 deletions cou/apps/auxiliary_subordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ def current_os_release(self) -> OpenStackRelease:
class OvnSubordinateApplication(OpenStackAuxiliarySubordinateApplication):
"""Ovn subordinate application class."""

def pre_upgrade_plan(self, target: OpenStackRelease) -> list[PreUpgradeStep]:
"""Pre Upgrade planning.
def pre_upgrade_steps(self, target: OpenStackRelease) -> list[PreUpgradeStep]:
"""Pre Upgrade steps planning.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:return: Plan that will add pre upgrade as sub steps.
:return: List of pre upgrade steps.
:rtype: list[PreUpgradeStep]
"""
validate_ovn_support(self.status.workload_version)
return super().pre_upgrade_plan(target)
return super().pre_upgrade_steps(target)
98 changes: 36 additions & 62 deletions cou/apps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,26 +434,26 @@ async def _check_upgrade(self, target: OpenStackRelease) -> None:
f"Cannot upgrade units '{units_not_upgraded_string}' to {target}."
)

def pre_upgrade_plan(self, target: OpenStackRelease) -> list[PreUpgradeStep]:
"""Pre Upgrade planning.
def pre_upgrade_steps(self, target: OpenStackRelease) -> list[PreUpgradeStep]:
"""Pre Upgrade steps planning.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:return: Plan that will add pre upgrade as sub steps.
:return: List of pre upgrade steps.
:rtype: list[PreUpgradeStep]
"""
return [
self._get_upgrade_current_release_packages_plan(),
self._get_refresh_charm_plan(target),
self._get_upgrade_current_release_packages_step(),
self._get_refresh_charm_step(target),
]

def upgrade_plan(self, target: OpenStackRelease) -> list[UpgradeStep]:
"""Upgrade planning.
def upgrade_steps(self, target: OpenStackRelease) -> list[UpgradeStep]:
"""Upgrade steps planning.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:raises HaltUpgradePlanGeneration: When the application halt the upgrade plan generation.
:return: Plan that will add upgrade as sub steps.
:return: List of upgrade steps.
:rtype: list[UpgradeStep]
"""
if self.current_os_release >= target and self.apt_source_codename >= target:
Expand All @@ -465,24 +465,24 @@ def upgrade_plan(self, target: OpenStackRelease) -> list[UpgradeStep]:
raise HaltUpgradePlanGeneration(msg)

return [
self._get_disable_action_managed_plan(),
self._get_upgrade_charm_plan(target),
self._get_workload_upgrade_plan(target),
self._get_disable_action_managed_step(),
self._get_upgrade_charm_step(target),
self._get_workload_upgrade_step(target),
]

def post_upgrade_plan(self, target: OpenStackRelease) -> list[PostUpgradeStep]:
"""Post Upgrade planning.
def post_upgrade_steps(self, target: OpenStackRelease) -> list[PostUpgradeStep]:
"""Post Upgrade steps planning.
Wait until the application reaches the idle state and then check the target workload.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:return: Plan that will add post upgrade as sub steps.
:return: List of post upgrade steps.
:rtype: list[PostUpgradeStep]
"""
return [
self._get_wait_step(),
self._get_reached_expected_target_plan(target),
self._get_reached_expected_target_step(target),
]

def generate_upgrade_plan(self, target: OpenStackRelease) -> ApplicationUpgradePlan:
Expand All @@ -497,44 +497,37 @@ def generate_upgrade_plan(self, target: OpenStackRelease) -> ApplicationUpgradeP
description=f"Upgrade plan for '{self.name}' to {target}",
)
all_steps = (
self.pre_upgrade_plan(target)
+ self.upgrade_plan(target)
+ self.post_upgrade_plan(target)
self.pre_upgrade_steps(target)
+ self.upgrade_steps(target)
+ self.post_upgrade_steps(target)
)
for step in all_steps:
if step:
upgrade_steps.add_step(step)
return upgrade_steps

def _get_upgrade_current_release_packages_plan(self, parallel: bool = False) -> PreUpgradeStep:
"""Get Plan for upgrading software packages to the latest of the current release.
def _get_upgrade_current_release_packages_step(self) -> PreUpgradeStep:
"""Get step for upgrading software packages to the latest of the current release.
:param parallel: Parallel running, defaults to False
:type parallel: bool, optional
:return: Plan for upgrading software packages to the latest of the current release.
:return: Step for upgrading software packages to the latest of the current release.
:rtype: PreUpgradeStep
"""
return PreUpgradeStep(
description=(
f"Upgrade software packages of '{self.name}' from the current APT repositories"
),
parallel=parallel,
coro=upgrade_packages(self.status.units.keys(), self.model, self.packages_to_hold),
)

def _get_refresh_charm_plan(
self, target: OpenStackRelease, parallel: bool = False
) -> PreUpgradeStep:
"""Get plan for refreshing the current channel.
def _get_refresh_charm_step(self, target: OpenStackRelease) -> PreUpgradeStep:
"""Get step for refreshing the current channel.
This function also identifies if charm comes from charmstore and in that case,
makes the migration.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:param parallel: Parallel running, defaults to False
:type parallel: bool, optional
:raises ApplicationError: When application has unexpected channel.
:return: Plan for refreshing the charm.
:return: Step for refreshing the charm.
:rtype: PreUpgradeStep
"""
if not self.can_upgrade_current_channel:
Expand Down Expand Up @@ -577,48 +570,39 @@ def _get_refresh_charm_plan(

return PreUpgradeStep(
description=description,
parallel=parallel,
coro=self.model.upgrade_charm(self.name, channel, switch=switch),
)

def _get_upgrade_charm_plan(
self, target: OpenStackRelease, parallel: bool = False
) -> UpgradeStep:
"""Get plan for upgrading the charm.
def _get_upgrade_charm_step(self, target: OpenStackRelease) -> UpgradeStep:
"""Get step for upgrading the charm.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:param parallel: Parallel running, defaults to False
:type parallel: bool, optional
:return: Plan for upgrading the charm.
:return: Step for upgrading the charm.
:rtype: UpgradeStep
"""
if self.channel != self.target_channel(target):
return UpgradeStep(
description=(
f"Upgrade '{self.name}' to the new channel: '{self.target_channel(target)}'"
),
parallel=parallel,
coro=self.model.upgrade_charm(self.name, self.target_channel(target)),
)
return UpgradeStep()

def _get_disable_action_managed_plan(self, parallel: bool = False) -> UpgradeStep:
"""Get plan to disable action-managed-upgrade.
def _get_disable_action_managed_step(self) -> UpgradeStep:
"""Get step to disable action-managed-upgrade.
This is used to upgrade as "all-in-one" strategy.
:param parallel: Parallel running, defaults to False
:type parallel: bool, optional
:return: Plan to disable action-managed-upgrade
:return: Step to disable action-managed-upgrade
:rtype: UpgradeStep
"""
if self.config.get("action-managed-upgrade", {}).get("value", False):
return UpgradeStep(
description=(
f"Change charm config of '{self.name}' 'action-managed-upgrade' to False."
),
parallel=parallel,
coro=self.model.set_application_config(
self.name, {"action-managed-upgrade": False}
),
Expand Down Expand Up @@ -672,16 +656,12 @@ def _get_resume_unit_step(self, unit: ApplicationUnit) -> UnitUpgradeStep:
),
)

def _get_workload_upgrade_plan(
self, target: OpenStackRelease, parallel: bool = False
) -> UpgradeStep:
"""Get workload upgrade plan by changing openstack-origin or source.
def _get_workload_upgrade_step(self, target: OpenStackRelease) -> UpgradeStep:
"""Get workload upgrade step by changing openstack-origin or source.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:param parallel: Parallel running, defaults to False
:type parallel: bool, optional
:return: Workload upgrade plan
:return: Workload upgrade step
:rtype: UpgradeStep
"""
if self.os_origin != self.new_origin(target) and self.origin_setting:
Expand All @@ -690,7 +670,6 @@ def _get_workload_upgrade_plan(
f"Change charm config of '{self.name}' "
f"'{self.origin_setting}' to '{self.new_origin(target)}'"
),
parallel=parallel,
coro=self.model.set_application_config(
self.name, {self.origin_setting: self.new_origin(target)}
),
Expand All @@ -703,21 +682,16 @@ def _get_workload_upgrade_plan(
)
return UpgradeStep()

def _get_reached_expected_target_plan(
self, target: OpenStackRelease, parallel: bool = False
) -> PostUpgradeStep:
"""Get plan to check if application workload has been upgraded.
def _get_reached_expected_target_step(self, target: OpenStackRelease) -> PostUpgradeStep:
"""Get post upgrade step to check if application workload has been upgraded.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:param parallel: Parallel running, defaults to False
:type parallel: bool, optional
:return: Plan to check if application workload has been upgraded
:return: Post Upgrade step to check if application workload has been upgraded.
:rtype: PostUpgradeStep
"""
return PostUpgradeStep(
description=f"Check if the workload of '{self.name}' has been upgraded",
parallel=parallel,
coro=self._check_upgrade(target),
)

Expand Down
9 changes: 5 additions & 4 deletions cou/apps/channel_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,17 @@ def is_versionless(self) -> bool:
"""
return not all(unit.workload_version for unit in self.status.units.values())

def post_upgrade_plan(self, target: OpenStackRelease) -> list[PostUpgradeStep]:
"""Post Upgrade planning.
def post_upgrade_steps(self, target: OpenStackRelease) -> list[PostUpgradeStep]:
"""Post Upgrade steps planning.
Wait until the application reaches the idle state and then check the target workload.
In case the application is versionless, there are no post upgrade steps to run.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:return: Plan that will add post upgrade as sub steps.
:return: List of post upgrade steps.
:rtype: list[PostUpgradeStep]
"""
if self.is_versionless:
return []
return super().post_upgrade_plan(target)
return super().post_upgrade_steps(target)
23 changes: 11 additions & 12 deletions cou/apps/subordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,32 @@
class SubordinateBaseClass(OpenStackApplication):
"""Subordinate base class."""

def pre_upgrade_plan(self, target: OpenStackRelease) -> list[PreUpgradeStep]:
"""Pre Upgrade planning.
def pre_upgrade_steps(self, target: OpenStackRelease) -> list[PreUpgradeStep]:
"""Pre Upgrade steps planning.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:return: Plan that will add pre upgrade as sub steps.
:return: List of pre upgrade steps.
:rtype: list[PreUpgradeStep]
"""
return [self._get_refresh_charm_plan(target)]
return [self._get_refresh_charm_step(target)]

def upgrade_plan(self, target: OpenStackRelease) -> list[UpgradeStep]:
"""Upgrade planning.
def upgrade_steps(self, target: OpenStackRelease) -> list[UpgradeStep]:
"""Upgrade steps planning.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:raises HaltUpgradePlanGeneration: When the application halt the upgrade plan generation.
:return: Plan that will add upgrade as sub steps.
:return: List of upgrade steps.
:rtype: list[UpgradeStep]
"""
return [self._get_upgrade_charm_plan(target)]
return [self._get_upgrade_charm_step(target)]

def post_upgrade_plan(self, target: OpenStackRelease) -> list[PostUpgradeStep]:
"""Post Upgrade planning.
def post_upgrade_steps(self, target: OpenStackRelease) -> list[PostUpgradeStep]:
"""Post Upgrade steps planning.
:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:return: Plan that will add post upgrade as sub steps.
:return: List of post upgrade steps.
:rtype: list[PostUpgradeStep]
"""
return []
Expand Down

0 comments on commit 86335ae

Please sign in to comment.