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/roles/web-app-funkwhale/meta/services.yml b/roles/web-app-funkwhale/meta/services.yml index fe1905e096..46c35c0772 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: @@ -37,7 +37,7 @@ api: path: api/v1/instance/nodeinfo/2.0 name: funkwhale-api image: funkwhale/api - version: 2.0.11 + version: 2.0.12 min_storage: 588MB ports: internal: diff --git a/roles/web-app-gitlab/meta/services.yml b/roles/web-app-gitlab/meta/services.yml index 975f9ba929..aa93bd984f 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 diff --git a/tasks/stages/01_constructor.yml b/tasks/stages/01_constructor.yml index 42de68a025..04814a385a 100644 --- a/tasks/stages/01_constructor.yml +++ b/tasks/stages/01_constructor.yml @@ -52,6 +52,10 @@ - name: "📍 Place the shared services and the proxy on their hosts" ansible.builtin.include_tasks: ./tasks/utils/constructor/placement.yml +- 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)), )