Skip to content

Commit

Permalink
Merge branch 'main' into auxiliary-channel-codename-BSENG-2411
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcocenza authored Apr 24, 2024
2 parents dcfd5b4 + 19ce5f8 commit 85b295d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cou/apps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Base application class."""
from __future__ import annotations

import asyncio
import logging
import os
from collections import defaultdict
Expand Down Expand Up @@ -350,6 +351,11 @@ async def _verify_workload_upgrade(self, target: OpenStackRelease, units: list[U
:type units: list[Unit]
:raises ApplicationError: When the workload version of the charm doesn't upgrade.
"""
# NOTE (gabrielcocenza) force the update-status hook on units
# to update the workload version
tasks = [self.model.run_on_unit(unit.name, "hooks/update-status") for unit in units]
await asyncio.gather(*tasks)

status = await self.model.get_status()
app_status = status.applications.get(self.name)
units_not_upgraded = []
Expand All @@ -363,7 +369,9 @@ async def _verify_workload_upgrade(self, target: OpenStackRelease, units: list[U

if units_not_upgraded:
raise ApplicationError(
f"Cannot upgrade units '{', '.join(units_not_upgraded)}' to {target}."
f"Unit(s) '{', '.join(units_not_upgraded)}' did not complete the upgrade to "
f"{target}. Some local processes may still be executing; you may try re-running "
"COU in a few minutes."
)

def upgrade_plan_sanity_checks(
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/apps/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ async def test_application_verify_workload_upgrade(model):
async def test_application_verify_workload_upgrade_fail(model):
"""Test Kyestone application check unsuccessful upgrade."""
target = OpenStackRelease("victoria")
exp_msg = "Cannot upgrade units 'keystone/0' to victoria."
exp_msg = (
r"Unit\(s\) 'keystone/0' did not complete the upgrade to victoria. Some local processes "
r"may still be executing; you may try re-running COU in a few minutes."
)
machines = {"0": MagicMock(spec_set=Machine)}
app = Keystone(
name="keystone",
Expand Down

0 comments on commit 85b295d

Please sign in to comment.