2023-08-12 14:25:01 +00:00
|
|
|
from collections.abc import Iterator
|
2023-08-07 09:17:56 +00:00
|
|
|
|
|
|
|
from .. import Operator
|
2023-08-12 13:49:35 +00:00
|
|
|
from . import CheckResult, Fail
|
2023-08-07 09:17:56 +00:00
|
|
|
|
|
|
|
|
2023-08-12 13:49:35 +00:00
|
|
|
def check_upgrade(operator: Operator) -> Iterator[CheckResult]:
|
2023-08-08 08:06:11 +00:00
|
|
|
"""Validate upgrade graphs for all channels"""
|
2023-08-18 10:44:43 +00:00
|
|
|
all_channels: set[str] = set(operator.channels)
|
|
|
|
if operator.default_channel is not None:
|
|
|
|
all_channels.add(operator.default_channel)
|
2023-08-07 09:17:56 +00:00
|
|
|
for channel in sorted(all_channels):
|
|
|
|
try:
|
|
|
|
channel_bundles = operator.channel_bundles(channel)
|
|
|
|
channel_head = operator.head(channel)
|
|
|
|
graph = operator.update_graph(channel)
|
|
|
|
dangling_bundles = {
|
|
|
|
x for x in channel_bundles if x not in graph and x != channel_head
|
|
|
|
}
|
|
|
|
if dangling_bundles:
|
2023-08-12 13:49:35 +00:00
|
|
|
yield Fail(
|
2023-08-15 07:02:11 +00:00
|
|
|
f"Channel {channel} has dangling bundles: {dangling_bundles}"
|
2023-08-12 13:49:35 +00:00
|
|
|
)
|
2023-08-18 16:33:07 +00:00
|
|
|
except Exception as exc: # pylint: disable=broad-exception-caught
|
2023-08-15 07:02:11 +00:00
|
|
|
yield Fail(str(exc))
|