From 778c18fb2342dd4e29acd82c64daf790d95ad751 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 15 Oct 2026 03:21:17 +0200 Subject: [PATCH 1/3] perf(constructor): carry the applications SPOT into the bootstrap roles The constructor parked no applications carrier between the merge block and the token store, so every lookup in the svc-swarm-node, svc-storage, svc-registry and svc-virt bootstrap rendered the SPOT cold, 25 to 30 s each on a loaded host. A carrier there was unsafe: in swarm, svc-storage-nfs-server mounts the NFS export over the controller's DIR_VAR_LIB, so the tokens file the render reads can appear in the middle of that section, and the cache key did not notice. merged_applications_cache_key now includes the tokens file's path, mtime and size, as the users cache key already did, so a carrier rejects itself once the tokens change. A carrier parked after the add_host tasks then serves the bootstrap roles. It is parked only in swarm mode: in compose the section runs in about a second, so a carrier there would add a render without saving one. In a swarm drill of web-app-prometheus up to the known NFS probe-write failure, "Resolve the NFS server backend flavor" went from 29.6 s to 0.07 s, "Probe-mount the NFS export" from 26.4 s to 0.4 s, "Mount cluster-shared infinito state on controller" from 23.7 s to 0.5 s and "Ensure Docker-In-Docker DNS works" from 30.0 s to 3.6 s; the run to that point took 768 s instead of 1735 s. Closes #925 Co-Authored-By: Claude Opus 5.5 (1M context) --- plugins/action/applications_carrier.py | 14 ++++++-------- tasks/stages/01_constructor.yml | 4 ++++ .../python/utils/cache/test_applications.py | 18 ++++++++++++++++++ utils/cache/carrier.py | 18 ++++++++++++++---- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/plugins/action/applications_carrier.py b/plugins/action/applications_carrier.py index f7711ed295..ce05759532 100644 --- a/plugins/action/applications_carrier.py +++ b/plugins/action/applications_carrier.py @@ -10,14 +10,12 @@ instead of rendering:: - name: 🧊 Render the applications SPOT once and carry it into every task's worker applications_carrier: {} -``tasks/stages/01_constructor.yml`` parks two of them. The stage-wide one -sits after the token store so the embedded user records already carry the -loaded tokens, and after the ``add_host`` tasks because 114 roles gate -services on ``group_names`` and the payload bakes those in. The -merge block opens an earlier, block-scoped one and drops it again at the -block's end, because ``merged_applications_cache_key`` reads neither -``group_names`` nor the token file: a carrier left standing across either -would be served unchanged where a fresh render belongs:: +``tasks/stages/01_constructor.yml`` parks three of them: a block-scoped one +for the merge block, which it drops again at the block's end, one after the +``add_host`` tasks for the swarm bootstrap roles, parked only when +``DEPLOYMENT_MODE`` is ``swarm``, and the stage-wide one after the token store. ``merged_applications_cache_key`` reads ``group_names`` and the +tokens file's path, mtime and size, so a carrier whose groups or tokens no +longer match is rejected and the reader renders afresh:: - name: 🧊 Drop the merge-block carrier so later stages re-render applications_carrier: diff --git a/tasks/stages/01_constructor.yml b/tasks/stages/01_constructor.yml index 5f6b5c33e5..72f8b564fc 100644 --- a/tasks/stages/01_constructor.yml +++ b/tasks/stages/01_constructor.yml @@ -161,6 +161,10 @@ run_once: true changed_when: false +- name: 🧊 Render the applications SPOT once for the bootstrap section + applications_carrier: {} + when: DEPLOYMENT_MODE == 'swarm' + - name: "🥾 Bootstrap svc-swarm-node" ansible.builtin.include_role: name: svc-swarm-node diff --git a/tests/unit/python/utils/cache/test_applications.py b/tests/unit/python/utils/cache/test_applications.py index b62eff677a..fc2324d2f6 100644 --- a/tests/unit/python/utils/cache/test_applications.py +++ b/tests/unit/python/utils/cache/test_applications.py @@ -389,6 +389,24 @@ class TestGetMergedApplicationsCarrierFact(unittest.TestCase): merged["web-app-foo"]["services"]["foo"]["image"], "override" ) + def test_a_changed_tokens_file_rejects_the_carrier(self): + with tempfile.TemporaryDirectory() as tmp: + roles = _seed_minimal_roles(Path(tmp)) + tokens = Path(tmp) / "tokens.yml" + tokens.write_text("{}\n", encoding="utf-8") + variables = self._variables() + variables["FILE_TOKENS"] = str(tokens) + key = merged_applications_cache_key(variables, roles_dir=roles) + variables[APPLICATIONS_RENDERED_FACT] = { + "key": [key[0], list(key[1])], + "applications": {"web-app-foo": {"carried": True}}, + } + tokens.write_text("users: {}\n", encoding="utf-8") + merged = cache_apps.get_merged_applications( + variables=variables, roles_dir=roles, templar=None + ) + self.assertNotIn("carried", merged["web-app-foo"]) + def test_malformed_carrier_is_ignored(self): with tempfile.TemporaryDirectory() as tmp: roles = _seed_minimal_roles(Path(tmp)) diff --git a/utils/cache/carrier.py b/utils/cache/carrier.py index 08c4e786a2..dfda350ae4 100644 --- a/utils/cache/carrier.py +++ b/utils/cache/carrier.py @@ -13,7 +13,12 @@ from __future__ import annotations from collections.abc import Mapping from typing import TYPE_CHECKING, Any -from .base import _cache_key, _resolve_roles_dir, _stable_variables_signature +from .base import ( + _cache_key, + _resolve_roles_dir, + _stable_variables_signature, + _tokens_file_signature, +) if TYPE_CHECKING: import os @@ -30,16 +35,21 @@ def merged_applications_cache_key( Args: variables: The play's variable scope. Only the subset that - `_stable_variables_signature` reads influences the key. + `_stable_variables_signature` reads, and the tokens file it + resolves to, influence the key. roles_dir: Roles tree the payload is built from; defaults to the repository's `roles/`. Returns: - ``(resolved roles dir, stable variables signature)``. + ``(resolved roles dir, stable variables signature extended by the + tokens file's path, mtime and size)``. """ + from .users import _resolve_tokens_file + + tokens = _tokens_file_signature(_resolve_tokens_file(variables)) return ( _cache_key(_resolve_roles_dir(roles_dir=roles_dir)), - _stable_variables_signature(variables), + (*_stable_variables_signature(variables), *(str(part) for part in tokens)), ) From ec72aa40ed4b8942bf3854b9d4d6834c7c57549e Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 15:58:36 +0000 Subject: [PATCH 2/3] update(images): update Docker image versions (web-app-funkwhale) --- roles/web-app-funkwhale/meta/services.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/web-app-funkwhale/meta/services.yml b/roles/web-app-funkwhale/meta/services.yml index de6cb65d1e..19774a94f1 100644 --- a/roles/web-app-funkwhale/meta/services.yml +++ b/roles/web-app-funkwhale/meta/services.yml @@ -11,7 +11,7 @@ funkwhale: # nocheck: default-placement-manager embedded typesense index; node-local in swarm placement: manager image: funkwhale/front - version: 2.0.11 + version: 2.0.12 min_storage: 224MB ports: internal: @@ -36,7 +36,7 @@ api: flavor: curl path: api/v1/instance/nodeinfo/2.0 image: funkwhale/api - version: 2.0.11 + version: 2.0.12 min_storage: 588MB ports: internal: From 702cc2bde2cf852ce664910fb31f8a0dba292919 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 15:58:42 +0000 Subject: [PATCH 3/3] update(images): update Docker image versions (web-app-gitlab) --- roles/web-app-gitlab/meta/services.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/web-app-gitlab/meta/services.yml b/roles/web-app-gitlab/meta/services.yml index 27ac8c52a4..5c13f96c19 100644 --- a/roles/web-app-gitlab/meta/services.yml +++ b/roles/web-app-gitlab/meta/services.yml @@ -76,7 +76,7 @@ gitlab: lifecycle: beta webservice: image: registry.gitlab.com/gitlab-org/build/cng/gitlab-webservice-ce - version: v19.4.2 + version: v19.5.0 name: gitlab-webservice healthcheck: test: ["CMD", "/scripts/healthcheck"] @@ -95,7 +95,7 @@ sidekiq: flavor: tcp path: liveness image: registry.gitlab.com/gitlab-org/build/cng/gitlab-sidekiq-ce - version: v19.4.2 + version: v19.5.0 name: gitlab-sidekiq cpus: "1.0" mem_reservation: 2g @@ -106,7 +106,7 @@ sidekiq: http: 3808 workhorse: image: registry.gitlab.com/gitlab-org/build/cng/gitlab-workhorse-ce - version: v19.4.2 + version: v19.5.0 name: gitlab-workhorse healthcheck: test: ["CMD", "/scripts/healthcheck"] @@ -118,7 +118,7 @@ gitaly: # nocheck: single-replica replicas: 1 image: registry.gitlab.com/gitlab-org/build/cng/gitaly - version: v19.4.2 + version: v19.5.0 healthcheck: test: ["CMD", "/scripts/healthcheck"] name: gitlab-gitaly @@ -131,7 +131,7 @@ gitaly: pids_limit: 1024 shell: image: registry.gitlab.com/gitlab-org/build/cng/gitlab-shell - version: v19.4.2 + version: v19.5.0 name: gitlab-shell ports: internal: @@ -144,7 +144,7 @@ migrations: # nocheck: single-replica replicas: 1 image: registry.gitlab.com/gitlab-org/build/cng/gitlab-rails-ce - version: v19.4.2 + version: v19.5.0 name: gitlab-migrations cpus: "1.0" mem_reservation: 1g