From e66005ab073f9eafef3c0f4d2c296960f9cf6abe Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 17 Sep 2026 17:45:28 +0200 Subject: [PATCH] fix(update): move a role's images as one release or not at all Seven roles pin several images at one shared version, because those images are one product: the four Jitsi components, six GitLab CNG images, eight BigBlueButton services, three Penpot, plus Mastodon, Funkwhale and Nextcloud Talk. The bump job walks entries one by one and takes each image's own newest tag, so a run landing between upstream's first and last push raises the components already there and leaves the rest behind. What deploys afterwards is a mixed set, and for Jitsi a mixed set breaks video. The window is real rather than theoretical. Measured on Docker Hub, 'stable-9457' exists for jitsi/prosody, jitsi/jicofo and jitsi/jvb but not for jitsi/web, one build out of sixty. Candidates are now grouped by role and current version, and the group is held to the newest tag the intersection of all their tag lists still offers. A group with nothing newer in common yields no update at all rather than a partial one. A lone entry passes through untouched, so nothing changes for the large majority. The key is deliberately the role and the version, not the image namespace. A namespace rule does not survive the data: prom/* carries four components at four different versions, opentalk/* three, and minio, taigaio and markoshust each two. Grouping by namespace would hold back pins that are correctly independent. Five of the seven roles have carried this exposure all along; the channel grammar in the previous commit added the sixth by making Jitsi orderable at all. This closes all of them. Co-Authored-By: Claude Opus 5 (1M context) --- .../update/test_docker_release_groups.py | 113 ++++++++++++++++++ utils/update/docker.py | 49 +++++++- 2 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 tests/unit/python/utils/update/test_docker_release_groups.py diff --git a/tests/unit/python/utils/update/test_docker_release_groups.py b/tests/unit/python/utils/update/test_docker_release_groups.py new file mode 100644 index 0000000000..11fd767a6a --- /dev/null +++ b/tests/unit/python/utils/update/test_docker_release_groups.py @@ -0,0 +1,113 @@ +"""Several images of one role at one version move together or not at all. + +Upstream does not push a release group atomically. Measured on Docker Hub: +``jitsi/prosody``, ``jitsi/jicofo`` and ``jitsi/jvb`` all publish +``stable-9457`` while ``jitsi/web`` does not, so a bump run landing in that +window would raise three components and leave the fourth behind. +""" + +from __future__ import annotations + +import unittest +from pathlib import Path + +from utils.update.docker import ( + DockerImageVersionEntry, + DockerImageVersionUpdate, + _held_to_release_groups, +) + +JITSI = ("web", "prosody", "jicofo", "jvb") + + +def _entry(role: str, service: str, image: str, version: str): + return DockerImageVersionEntry( + role=role, + service=service, + image=image, + version=version, + config_path=Path("meta/services.yml"), + ) + + +def _jitsi_updates(version: str, latest: str): + return [ + DockerImageVersionUpdate( + entry=_entry("web-app-jitsi", name, f"jitsi/{name}", version), + latest=latest, + ) + for name in JITSI + ] + + +class TestReleaseGroupsMoveTogether(unittest.TestCase): + def test_a_partial_publish_holds_the_whole_group_back(self): + tags = { + "jitsi/web": ["stable-9400", "stable-9646"], + "jitsi/prosody": ["stable-9400", "stable-9646", "stable-9700"], + "jitsi/jicofo": ["stable-9400", "stable-9646", "stable-9700"], + "jitsi/jvb": ["stable-9400", "stable-9646", "stable-9700"], + } + updates = _jitsi_updates("stable-9400", "stable-9700") + + held = _held_to_release_groups(updates, tags) + + self.assertEqual({update.latest for update in held}, {"stable-9646"}) + self.assertEqual(len(held), 4) + + def test_a_group_all_publish_moves_to_the_head(self): + tags = { + f"jitsi/{name}": ["stable-9400", "stable-9700"] for name in JITSI + } + updates = _jitsi_updates("stable-9400", "stable-9700") + + held = _held_to_release_groups(updates, tags) + + self.assertEqual({update.latest for update in held}, {"stable-9700"}) + + def test_a_group_with_nothing_in_common_is_dropped(self): + tags = { + "jitsi/web": ["stable-9400", "stable-9701"], + "jitsi/prosody": ["stable-9400", "stable-9702"], + "jitsi/jicofo": ["stable-9400", "stable-9703"], + "jitsi/jvb": ["stable-9400", "stable-9704"], + } + updates = _jitsi_updates("stable-9400", "stable-9704") + + self.assertEqual(_held_to_release_groups(updates, tags), []) + + def test_a_lone_entry_is_untouched(self): + update = DockerImageVersionUpdate( + entry=_entry("web-app-fider", "fider", "getfider/fider", "v0.35.0"), + latest="v0.36.0", + ) + + held = _held_to_release_groups([update], {"getfider/fider": ["v0.36.0"]}) + + self.assertEqual(held, [update]) + + def test_two_roles_on_one_version_are_not_one_group(self): + tags = { + "jitsi/web": ["stable-9400", "stable-9700"], + "other/thing": ["stable-9400"], + } + updates = [ + DockerImageVersionUpdate( + entry=_entry("web-app-jitsi", "web", "jitsi/web", "stable-9400"), + latest="stable-9700", + ), + DockerImageVersionUpdate( + entry=_entry("web-app-other", "thing", "other/thing", "stable-9400"), + latest="stable-9400", + ), + ] + + held = _held_to_release_groups(updates, tags) + + self.assertEqual( + [update.latest for update in held], ["stable-9700", "stable-9400"] + ) + + +if __name__ == "__main__": + unittest.main() diff --git a/utils/update/docker.py b/utils/update/docker.py index 0c96b20cd4..53bf9561f8 100644 --- a/utils/update/docker.py +++ b/utils/update/docker.py @@ -19,6 +19,7 @@ import re import time import urllib.error import urllib.request +from collections import defaultdict from dataclasses import dataclass from typing import TYPE_CHECKING from urllib.parse import quote, urlencode @@ -342,7 +343,53 @@ def find_outdated_updates(repo_root: Path) -> list[DockerImageVersionUpdate]: if latest and version_key(entry.version) < version_key(latest): updates.append(DockerImageVersionUpdate(entry=entry, latest=latest)) - return updates + return _held_to_release_groups(updates, image_tags) + + +def _held_to_release_groups( + updates: list[DockerImageVersionUpdate], image_tags: dict[str, list[str]] +) -> list[DockerImageVersionUpdate]: + """Hold every member of a release group to the newest tag all of them + publish. + + Several images of one role that currently sit on the same version are one + product released together (the four Jitsi components, the six GitLab CNG + images). Upstream does not push them atomically, so a run that lands in the + window between the first and the last push would raise the ones already + there and leave the rest behind, deploying a mixed set. + + Args: + updates: the per-entry candidates, before grouping. + image_tags: every tag fetched per image, keyed as in the caller. + + Returns: + The updates, each group lowered to its common newest tag, and dropped + entirely where the group shares no newer tag at all. + """ + groups: dict[tuple[str, str], list[DockerImageVersionUpdate]] = defaultdict(list) + for update in updates: + groups[(update.entry.role, update.entry.version)].append(update) + + held: list[DockerImageVersionUpdate] = [] + for group in groups.values(): + if len(group) == 1: + held.extend(group) + continue + shared = set.intersection( + *(set(image_tags.get(update.entry.image, [])) for update in group) + ) + current = group[0].entry.version + common = latest_semver( + sorted(shared), version_depth(current), version_flavor(current) + ) + if not common or version_key(current) >= version_key(common): + continue + held.extend( + DockerImageVersionUpdate(entry=update.entry, latest=common) + for update in group + ) + + return held def update_config_versions(config_path: Path, service_versions: dict[str, str]) -> bool: