Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Swift application class #345

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions cou/apps/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from cou.apps.base import LONG_IDLE_TIMEOUT, OpenStackApplication
from cou.apps.factory import AppFactory
from cou.exceptions import ApplicationNotSupported
from cou.steps import UnitUpgradeStep, UpgradeStep
from cou.utils.juju_utils import Unit
from cou.utils.nova_compute import verify_empty_hypervisor
Expand Down Expand Up @@ -145,3 +146,29 @@ def _get_disable_scheduler_step(self, unit: Unit) -> UnitUpgradeStep:
unit_name=unit.name, action_name="disable", raise_on_failure=True
),
)


@AppFactory.register_application(["swift-proxy", "swift-storage"])
class Swift(OpenStackApplication):
"""Swift application.

Swift applications, including swift-proxy and swift-storage, are considered as
valid OpenStack components, but not currently supported by COU for upgrade.
"""

def upgrade_plan_sanity_checks(
self, target: OpenStackRelease, units: Optional[list[Unit]]
) -> None:
"""Run sanity checks before generating upgrade plan.

:param target: OpenStack release as target to upgrade.
:type target: OpenStackRelease
:param units: Units to generate upgrade plan, defaults to None
:type units: Optional[list[Unit]], optional
:raises ApplicationNotSupported: When application is known but not currently
supported by COU.
"""
raise ApplicationNotSupported(
f"'{self.name}' application is not currently supported by COU. Please manually "
"upgrade it."
)
4 changes: 4 additions & 0 deletions cou/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,7 @@ def __init__(self, message: str, exit_code: int) -> None:
"""
self.exit_code = exit_code
super().__init__(message)


class ApplicationNotSupported(COUException):
"""COU exception when the application is known but not supported by COU."""
2 changes: 1 addition & 1 deletion cou/steps/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
)
from cou.apps.base import OpenStackApplication
from cou.apps.channel_based import ChannelBasedApplication # noqa: F401
from cou.apps.core import Keystone, Octavia # noqa: F401
from cou.apps.core import Keystone, Octavia, Swift # noqa: F401
from cou.apps.subordinate import SubordinateApplication, SubordinateBase # noqa: F401
from cou.commands import CONTROL_PLANE, DATA_PLANE, HYPERVISORS, CLIargs
from cou.exceptions import (
Expand Down
2 changes: 1 addition & 1 deletion cou/utils/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"mysql": ["mysql-innodb-cluster", "mysql-router"],
}

DATA_PLANE_CHARMS = ["nova-compute", "ceph-osd"]
DATA_PLANE_CHARMS = ["nova-compute", "ceph-osd", "swift-proxy", "swift-storage"]

# https://docs.openstack.org/charm-guide/latest/admin/upgrades/openstack.html#list-the-upgrade-order
UPGRADE_ORDER = [
Expand Down
42 changes: 40 additions & 2 deletions tests/unit/apps/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
from juju.client._definitions import ApplicationStatus, UnitStatus

from cou.apps.base import OpenStackApplication
from cou.apps.core import Keystone, NovaCompute
from cou.exceptions import ApplicationError, HaltUpgradePlanGeneration
from cou.apps.core import Keystone, NovaCompute, Swift
from cou.exceptions import (
ApplicationError,
ApplicationNotSupported,
HaltUpgradePlanGeneration,
)
from cou.steps import (
ApplicationUpgradePlan,
PostUpgradeStep,
Expand Down Expand Up @@ -1032,3 +1036,37 @@ def test_cinder_upgrade_plan_single_unit(model):
plan = cinder.generate_upgrade_plan(target, False, [units["cinder/0"]])

assert str(plan) == exp_plan


agileshaw marked this conversation as resolved.
Show resolved Hide resolved
def test_swift_application_not_supported(model):
"""Test Swift application raising ApplicationNotSupported error."""
target = OpenStackRelease("victoria")
machines = {"0": MagicMock(spec_set=Machine)}
app = Swift(
name="swift-proxy",
can_upgrade_to="ussuri/stable",
charm="swift-proxy",
channel="ussuri/stable",
config={},
machines=machines,
model=model,
origin="ch",
series="focal",
subordinate_to=[],
units={
"swift-proxy/0": Unit(
name="swift-proxy/0",
workload_version="2.25.0",
machine=machines["0"],
)
},
workload_version="2.25.0",
)

exp_error = (
"'swift-proxy' application is not currently supported by COU. Please manually "
"upgrade it."
)

with pytest.raises(ApplicationNotSupported, match=exp_error):
app.generate_upgrade_plan(target, False)
Loading