From c8cb7fda8c3aedbbb0918ff5dba1597eb0129560 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 13 Oct 2026 21:31:36 +0200 Subject: [PATCH 01/27] fix(lint): provision the mermaid browser in install-lint, not in the parallel lint run make lint runs install-lint once and then dispatches its fifteen targets in parallel. scripts/lint/mermaid.sh provisioned chrome-headless-shell inside that parallel phase with `npx puppeteer browsers install --install-deps`, whose `apt-get satisfy` carries no lock timeout. In a fresh stack container another target held the apt lock, the shared libraries stayed missing, the script only warned, and all 289 Markdown files then failed on libnspr4.so (#795). utils/install/lint/mermaid_cli.py now provisions the browser right after mmdc, inside the serial install-lint step, as root with --install-deps and as a user without it, because puppeteer refuses to install libraries without root. A failed install deletes the chrome-headless-shell cache folder and retries once under a 900 second timeout per attempt; a cut-off download otherwise leaves a folder without its executable, and puppeteer refuses every later install of that build. The install-lint stamp counts as fresh only while the browser executable exists, so a recreated container provisions it again. mermaid.sh no longer calls apt-get or npx. It renders one minimal diagram first and, when that fails, exits with mmdc's output instead of reporting every Markdown file. Verified: tests/unit/python/scripts/lint/test_mermaid.py stubs mmdc, npx and apt-get. With a browser that cannot load libnspr4.so the script exits 1 with that line, before any Markdown file renders, and mmdc is the only tool it calls. Against main's mermaid.sh the same test fails: it calls apt-get and npx and reports the files one by one. The installer and stamp cases pass, shellcheck is clean. Not verified: a full make lint in a recreated stack container. The race reproduced in one of two runs in the issue. feature/store-i18n changed the provisioning in mermaid.sh with 2f5f52bd1a and dc67bce5f0 (timeout, deleting a cut-off browser). Both behaviours moved into mermaid_cli.py here, so its merge takes this version of mermaid.sh. Closes #795 Co-Authored-By: Claude Opus 5.5 (1M context) --- scripts/lint/mermaid.sh | 23 ++-- tests/unit/python/scripts/lint/__init__.py | 0 .../unit/python/scripts/lint/test_mermaid.py | 62 ++++++++++ .../python/utils/install/lint/test_main.py | 18 +++ .../utils/install/lint/test_mermaid_cli.py | 111 ++++++++++++++++++ utils/install/lint/__main__.py | 5 +- utils/install/lint/mermaid_cli.py | 84 ++++++++++--- 7 files changed, 269 insertions(+), 34 deletions(-) create mode 100644 tests/unit/python/scripts/lint/__init__.py create mode 100644 tests/unit/python/scripts/lint/test_mermaid.py create mode 100644 tests/unit/python/utils/install/lint/test_mermaid_cli.py diff --git a/scripts/lint/mermaid.sh b/scripts/lint/mermaid.sh index 5dd9c0fefd..1f1a606485 100755 --- a/scripts/lint/mermaid.sh +++ b/scripts/lint/mermaid.sh @@ -20,20 +20,6 @@ if ! command -v mmdc >/dev/null 2>&1; then exit 127 fi -# Limitation: install-lint skips the puppeteer browser download so it stays -# sandbox-safe; mermaid-cli (puppeteer-core) bundles none, so provision the -# matching chrome-headless-shell here. --install-deps also pulls chrome's shared -# libs (libnspr4, libnss3, ...) on root Linux. Idempotent; needs network + unzip. -if command -v apt-get >/dev/null 2>&1; then - apt-get -o DPkg::Lock::Timeout=600 update >/dev/null 2>&1 || - echo "Warning: apt-get update failed; chrome's shared libs may stay unresolved." >&2 -fi - -if ! deps_output="$(npx --yes puppeteer browsers install chrome-headless-shell --install-deps 2>&1)"; then - printf 'Warning: chrome-headless-shell provisioning failed; mermaid rendering may fail:\n%s\n' \ - "${deps_output}" >&2 -fi - workdir="$(mktemp -d)" trap 'rm -rf "${workdir}"' EXIT @@ -47,6 +33,15 @@ if [[ ${#md_files[@]} -eq 0 ]]; then exit 0 fi +printf '%s\n' 'flowchart LR' ' a --> b' >"${workdir}/preflight.mmd" +if ! mmdc --puppeteerConfigFile "${puppeteer_cfg}" -i "${workdir}/preflight.mmd" \ + -o "${workdir}/preflight.svg" >"${workdir}/preflight.log" 2>&1; then + printf "mmdc cannot render a minimal diagram, so none of the %d Markdown file(s) was checked. 'make install-lint-force' provisions its browser:\n" \ + "${#md_files[@]}" >&2 + sed 's/^/ /' "${workdir}/preflight.log" >&2 + exit 1 +fi + : "${INFINITO_WORKER_CPU:?INFINITO_WORKER_CPU must be set (provided by default.env via the env loader)}" jobs="${INFINITO_WORKER_CPU}" diff --git a/tests/unit/python/scripts/lint/__init__.py b/tests/unit/python/scripts/lint/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/scripts/lint/test_mermaid.py b/tests/unit/python/scripts/lint/test_mermaid.py new file mode 100644 index 0000000000..30a7c3e1cd --- /dev/null +++ b/tests/unit/python/scripts/lint/test_mermaid.py @@ -0,0 +1,62 @@ +"""``scripts/lint/mermaid.sh`` renders with the browser install-lint provisioned. + +``make lint`` runs its targets in parallel, so the script must not reach for a +package manager, and a browser that cannot start must fail the lint once with +its reason instead of once per Markdown file. +""" + +from __future__ import annotations + +import os +import subprocess +import tempfile +import unittest +from pathlib import Path + +from utils.cache.files import PROJECT_ROOT + +SCRIPT = Path(PROJECT_ROOT) / "scripts" / "lint" / "mermaid.sh" +LIBRARY_ERROR = ( + "chrome-headless-shell: error while loading shared libraries: libnspr4.so" +) +RECORDING_STUB = '#!/bin/sh\necho "$(basename "$0")" >> "$STUB_CALLS"\n' + + +class TestMermaidLint(unittest.TestCase): + def test_a_browser_that_cannot_start_fails_before_any_file_renders(self): + with tempfile.TemporaryDirectory() as tmp: + bin_dir = Path(tmp) + calls = bin_dir / "calls" + calls.touch() + for name in ("npx", "apt-get"): + (bin_dir / name).write_text(RECORDING_STUB) + (bin_dir / "mmdc").write_text( + f"{RECORDING_STUB}echo '{LIBRARY_ERROR}' >&2\nexit 1\n" + ) + for stub in bin_dir.iterdir(): + stub.chmod(0o755) + env = { + k: v + for k, v in os.environ.items() + if not k.startswith("INFINITO_") and k != "BASH_ENV" + } + env["PATH"] = f"{bin_dir}{os.pathsep}{env['PATH']}" + env["STUB_CALLS"] = str(calls) + proc = subprocess.run( + ["bash", str(SCRIPT)], + env=env, + capture_output=True, + text=True, + check=False, + ) + recorded = calls.read_text().split() + + self.assertEqual(proc.returncode, 1, proc.stderr) + self.assertIn("cannot render a minimal diagram", proc.stderr) + self.assertIn(LIBRARY_ERROR, proc.stderr) + self.assertNotIn("❌", proc.stdout) + self.assertEqual(recorded, ["mmdc"]) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/unit/python/utils/install/lint/test_main.py b/tests/unit/python/utils/install/lint/test_main.py index c044c3afa9..6cfd4a48d8 100644 --- a/tests/unit/python/utils/install/lint/test_main.py +++ b/tests/unit/python/utils/install/lint/test_main.py @@ -34,12 +34,30 @@ class TestStampLogic(unittest.TestCase): with ( mock.patch.object(cli, "PROJECT_ROOT", root), mock.patch.object(cli.shutil, "which", return_value="/usr/bin/x"), + mock.patch.object( + cli.mermaid_cli, "browser_installed", return_value=True + ), mock.patch.object(cli, "_install_all") as inst, ): rc = cli.main([]) self.assertEqual(rc, 0) inst.assert_not_called() + def test_missing_mermaid_browser_invalidates_stamp(self) -> None: + with TemporaryDirectory() as tmp: + root = _make_repo_root(tmp, stamp_age_offset=60.0) + with ( + mock.patch.object(cli, "PROJECT_ROOT", root), + mock.patch.object(cli.shutil, "which", return_value="/usr/bin/x"), + mock.patch.object( + cli.mermaid_cli, "browser_installed", return_value=False + ), + mock.patch.object(cli, "_install_all") as inst, + ): + rc = cli.main([]) + self.assertEqual(rc, 0) + inst.assert_called_once() + def test_missing_tool_invalidates_stamp(self) -> None: with TemporaryDirectory() as tmp: root = _make_repo_root(tmp, stamp_age_offset=60.0) diff --git a/tests/unit/python/utils/install/lint/test_mermaid_cli.py b/tests/unit/python/utils/install/lint/test_mermaid_cli.py new file mode 100644 index 0000000000..3c827abe0d --- /dev/null +++ b/tests/unit/python/utils/install/lint/test_mermaid_cli.py @@ -0,0 +1,111 @@ +"""Unit tests for :mod:`utils.install.lint.mermaid_cli`.""" + +from __future__ import annotations + +import os +import subprocess +import unittest +import unittest.mock as mock +from pathlib import Path +from tempfile import TemporaryDirectory + +from utils.install.lint import mermaid_cli + + +def _done(returncode: int) -> subprocess.CompletedProcess[str]: + return subprocess.CompletedProcess([], returncode, stdout="out\n", stderr="err\n") + + +class TestBrowserProvisioning(unittest.TestCase): + def provision(self, *, euid: int, results: list[int]) -> tuple[list, list[str]]: + """Run ``ensure()`` with mmdc present and a stubbed puppeteer. + + Args: + euid: effective uid the run pretends to have. + results: exit codes the successive puppeteer calls return. + + Returns: + The recorded subprocess calls and the warnings emitted. + """ + warnings: list[str] = [] + with ( + TemporaryDirectory() as cache, + mock.patch.dict(os.environ, {"PUPPETEER_CACHE_DIR": cache}), + mock.patch.object(mermaid_cli, "which", return_value=True), + mock.patch.object(mermaid_cli.os, "geteuid", return_value=euid), + mock.patch.object(mermaid_cli, "warn", side_effect=warnings.append), + mock.patch.object( + mermaid_cli.subprocess, + "run", + side_effect=[_done(code) for code in results], + ) as run, + ): + mermaid_cli.ensure() + return run.call_args_list, warnings + + def test_root_installs_the_browser_with_its_libraries(self) -> None: + calls, warnings = self.provision(euid=0, results=[0]) + self.assertEqual(len(calls), 1) + self.assertEqual(calls[0].args[0][-2:], ["chrome-headless-shell", "--install-deps"]) + self.assertEqual(warnings, []) + + def test_a_user_installs_the_browser_without_libraries(self) -> None: + calls, _ = self.provision(euid=1000, results=[0]) + self.assertNotIn("--install-deps", calls[0].args[0]) + + def test_the_browser_install_downloads_despite_the_mmdc_skip_flag(self) -> None: + with mock.patch.dict(os.environ, {"PUPPETEER_SKIP_DOWNLOAD": "1"}): + calls, _ = self.provision(euid=0, results=[0]) + self.assertNotIn("PUPPETEER_SKIP_DOWNLOAD", calls[0].kwargs["env"]) + + def test_a_failed_install_clears_the_browser_cache_and_retries_once(self) -> None: + with TemporaryDirectory() as cache: + folder = Path(cache) / "chrome-headless-shell" / "linux-1" + folder.mkdir(parents=True) + seen: list[bool] = [] + + def run(*_args, **_kwargs): + seen.append(folder.exists()) + return _done(1 if len(seen) == 1 else 0) + + with ( + mock.patch.dict(os.environ, {"PUPPETEER_CACHE_DIR": cache}), + mock.patch.object(mermaid_cli, "which", return_value=True), + mock.patch.object(mermaid_cli.subprocess, "run", side_effect=run), + ): + mermaid_cli.ensure() + self.assertEqual(seen, [True, False]) + + def test_a_second_failure_warns_with_puppeteers_output(self) -> None: + calls, warnings = self.provision(euid=0, results=[1, 1]) + self.assertEqual(len(calls), 2) + self.assertEqual(len(warnings), 1) + self.assertIn("out\nerr\n", warnings[0]) + + def test_a_timeout_warns_instead_of_raising(self) -> None: + with ( + mock.patch.object(mermaid_cli, "which", return_value=True), + mock.patch.object( + mermaid_cli.subprocess, + "run", + side_effect=subprocess.TimeoutExpired("npx", 900), + ), + mock.patch.object(mermaid_cli, "warn") as warn, + ): + mermaid_cli.ensure() + warn.assert_called_once() + + +class TestBrowserInstalled(unittest.TestCase): + def test_the_executable_in_the_puppeteer_cache_counts(self) -> None: + with TemporaryDirectory() as cache: + build = Path(cache) / "chrome-headless-shell" / "linux-1" / "linux64" + build.mkdir(parents=True) + with mock.patch.dict(os.environ, {"PUPPETEER_CACHE_DIR": cache}): + self.assertFalse(mermaid_cli.browser_installed()) + (build / "chrome-headless-shell").write_text("", encoding="utf-8") + self.assertTrue(mermaid_cli.browser_installed()) + + +if __name__ == "__main__": + unittest.main() diff --git a/utils/install/lint/__main__.py b/utils/install/lint/__main__.py index 11fb1fc56a..7bf56b6079 100644 --- a/utils/install/lint/__main__.py +++ b/utils/install/lint/__main__.py @@ -177,7 +177,10 @@ def _stamp_is_fresh(repo_root: Path) -> bool: return False if dep_path.stat().st_mtime > stamp_mtime: return False - return all(shutil.which(tool) is not None for tool in _STAMP_TOOLS) + return ( + all(shutil.which(tool) is not None for tool in _STAMP_TOOLS) + and mermaid_cli.browser_installed() + ) def _touch_stamp(repo_root: Path) -> None: diff --git a/utils/install/lint/mermaid_cli.py b/utils/install/lint/mermaid_cli.py index 099af21a4d..e84c788327 100644 --- a/utils/install/lint/mermaid_cli.py +++ b/utils/install/lint/mermaid_cli.py @@ -1,24 +1,28 @@ -"""Install @mermaid-js/mermaid-cli (mmdc) via npm global. +"""Install @mermaid-js/mermaid-cli (mmdc) and the chrome-headless-shell it renders with. -Best-effort: the puppeteer browser is not downloaded here -(``PUPPETEER_SKIP_DOWNLOAD``) so ``install-lint`` stays sandbox-safe. mmdc only -needs a browser to RENDER, which ``scripts/lint/mermaid.sh`` provisions on demand -(``npx puppeteer browsers install chrome-headless-shell``) right before it -renders. That browser ships as a zip, so ``unzip`` is ensured here (puppeteer's -extractor needs it, else it leaves an empty version dir and mmdc reports the -browser missing). A failed install warns instead of aborting ``install-lint``, -so sandboxes without npm/browser access still get the rest of the lint toolchain. +mmdc comes from npm with ``PUPPETEER_SKIP_DOWNLOAD`` set; the browser is +provisioned through puppeteer afterwards, as root with its shared libraries +(``--install-deps``). ``unzip`` is ensured first because puppeteer extracts the +browser with it. A failed install warns instead of aborting ``install-lint``, so +sandboxes without npm or browser access still get the rest of the lint +toolchain. """ from __future__ import annotations import contextlib import os +import shutil +import subprocess +from pathlib import Path from utils.install.npm import npm_install_global from utils.install.primitives import log, warn, which from utils.install.system_pkg import install_command_via_pkg +BROWSER = "chrome-headless-shell" +PROVISION_TIMEOUT_S = 900 + def _ensure_unzip() -> None: if which("unzip"): @@ -27,16 +31,58 @@ def _ensure_unzip() -> None: install_command_via_pkg("unzip") +def browser_cache() -> Path: + base = os.environ.get("PUPPETEER_CACHE_DIR") or Path.home() / ".cache" / "puppeteer" + return Path(base) / BROWSER + + +def browser_installed() -> bool: + return any(path.is_file() for path in browser_cache().glob(f"*/*/{BROWSER}")) + + +def _provision_browser() -> subprocess.CompletedProcess[str]: + argv = ["npx", "--yes", "puppeteer", "browsers", "install", BROWSER] + if os.geteuid() == 0: + argv.append("--install-deps") + env = {k: v for k, v in os.environ.items() if k != "PUPPETEER_SKIP_DOWNLOAD"} + return subprocess.run( + argv, + env=env, + capture_output=True, + text=True, + timeout=PROVISION_TIMEOUT_S, + check=False, + ) + + +def _ensure_browser() -> None: + log(f"Provisioning {BROWSER} for mmdc via puppeteer.") + try: + done = _provision_browser() + if done.returncode != 0: + shutil.rmtree(browser_cache(), ignore_errors=True) + done = _provision_browser() + except (OSError, subprocess.TimeoutExpired) as exc: + warn(f"{BROWSER} provisioning skipped (optional lint tool): {exc}") + return + if done.returncode != 0: + warn( + f"{BROWSER} provisioning failed (optional lint tool):\n" + f"{done.stdout}{done.stderr}" + ) + + def ensure() -> None: _ensure_unzip() - if which("mmdc"): - return - log("Missing command 'mmdc'. Installing @mermaid-js/mermaid-cli via npm.") - os.environ["PUPPETEER_SKIP_DOWNLOAD"] = "1" - try: - npm_install_global("@mermaid-js/mermaid-cli") - except Exception as exc: # noqa: BLE001 - best-effort optional lint tool - warn(f"mermaid-cli install skipped (optional lint tool): {exc}") - return if not which("mmdc"): - warn("Command 'mmdc' is still unavailable after installation.") + log("Missing command 'mmdc'. Installing @mermaid-js/mermaid-cli via npm.") + os.environ["PUPPETEER_SKIP_DOWNLOAD"] = "1" + try: + npm_install_global("@mermaid-js/mermaid-cli") + except Exception as exc: # noqa: BLE001 - best-effort optional lint tool + warn(f"mermaid-cli install skipped (optional lint tool): {exc}") + return + if not which("mmdc"): + warn("Command 'mmdc' is still unavailable after installation.") + return + _ensure_browser() From ba8f4b5f3a5418de72bf57389a84545e78dcd987 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 13 Oct 2026 21:31:47 +0200 Subject: [PATCH 02/27] fix(sys-svc-container): keep the installed Docker apt key when its refresh is refused A local deploy stopped four times in two days in "Ensure Docker apt key and sources are consistent" (#849). apt_repo.sh downloads the Docker GPG key on every run, and when download.docker.com refused the connection, curl's four attempts were over within about six seconds and the script returned 1, although the key from an earlier run was installed and is all the following apt operations need. install_key now fails only when no key is installed. With a key in place, a refused download prints a warning and keeps it. A downloaded key that differs still replaces the installed one, and the 0644 mode is enforced in every case. The keyring path became an argument: ensure-key-and-sanitize passes the keyring it already hands to sanitize_sources, so the role's call still resolves to /etc/apt/keyrings/docker.asc, and a test can point the script at a temporary keyring. Verified: tests/unit/python/roles/sys-svc-container/files/test_apt_repo.py stubs curl and sudo. A refused download keeps the installed key and ends with changed=0, a refused download without a key exits 1, and a new key replaces the installed one. A copy of the script whose keep branch always errors, the old behaviour, fails the first test. Two local deploys ran the new script with rc 0 and an empty stderr and left the installed key untouched. shellcheck is clean. Not verified live: the refused download itself, which needs download.docker.com to refuse a connection during a deploy. A host without a key still needs the download and still fails when it is refused. Closes #849 Co-Authored-By: Claude Opus 5.5 (1M context) --- .../sys-svc-container/files/shell/apt_repo.sh | 40 +++---- .../sys-svc-container/files/test_apt_repo.py | 100 ++++++++++++++++++ 2 files changed, 122 insertions(+), 18 deletions(-) create mode 100644 tests/unit/python/roles/sys-svc-container/files/test_apt_repo.py diff --git a/roles/sys-svc-container/files/shell/apt_repo.sh b/roles/sys-svc-container/files/shell/apt_repo.sh index 2fbb3e696a..ce983387ee 100644 --- a/roles/sys-svc-container/files/shell/apt_repo.sh +++ b/roles/sys-svc-container/files/shell/apt_repo.sh @@ -1,14 +1,12 @@ #!/usr/bin/env bash set -euo pipefail -KEYRING_DIR="/etc/apt/keyrings" -LEGACY_KEY_PATH="${KEYRING_DIR}/docker.gpg" -KEY_PATH="${KEYRING_DIR}/docker.asc" +KEY_PATH="/etc/apt/keyrings/docker.asc" usage() { cat >&2 <<'EOF' Usage: - apt_repo.sh install-key + apt_repo.sh install-key [keyring-path] apt_repo.sh sanitize-sources [keep-canonical: 0|1] [keyring-path] apt_repo.sh ensure-key-and-sanitize [keep-canonical: 0|1] [keyring-path] @@ -62,33 +60,39 @@ PY install_key() { local distro_id="$1" + local key_path="$2" + local keyring_dir="" local changed=0 local tmp="" - if [[ ! -d "${KEYRING_DIR}" ]]; then + keyring_dir="$(dirname "${key_path}")" + if [[ ! -d "${keyring_dir}" ]]; then changed=1 - elif [[ "$(stat -c '%a' "${KEYRING_DIR}" 2>/dev/null || true)" != "755" ]]; then + elif [[ "$(stat -c '%a' "${keyring_dir}" 2>/dev/null || true)" != "755" ]]; then changed=1 fi - run_privileged install -m 0755 -d "${KEYRING_DIR}" + run_privileged install -m 0755 -d "${keyring_dir}" - if [[ -e "${LEGACY_KEY_PATH}" ]]; then - run_privileged rm -f "${LEGACY_KEY_PATH}" + if [[ -e "${keyring_dir}/docker.gpg" ]]; then + run_privileged rm -f "${keyring_dir}/docker.gpg" changed=1 fi tmp="$(mktemp)" trap 'rm -f "${tmp:-}"' EXIT if ! download_file "https://download.docker.com/linux/${distro_id}/gpg" "${tmp}" || [[ ! -s "${tmp}" ]]; then - echo "[ERROR] Failed to download the Docker GPG key from https://download.docker.com/linux/${distro_id}/gpg." >&2 - return 1 + if [[ ! -s "${key_path}" ]]; then + echo "[ERROR] Failed to download the Docker GPG key from https://download.docker.com/linux/${distro_id}/gpg." >&2 + return 1 + fi + echo "[WARN] Failed to refresh the Docker GPG key from https://download.docker.com/linux/${distro_id}/gpg; keeping ${key_path}." >&2 + elif [[ ! -f "${key_path}" ]] || ! cmp -s "${tmp}" "${key_path}"; then + run_privileged install -m 0644 "${tmp}" "${key_path}" + changed=1 fi - if [[ ! -f "${KEY_PATH}" ]] || ! cmp -s "${tmp}" "${KEY_PATH}"; then - run_privileged install -m 0644 "${tmp}" "${KEY_PATH}" - changed=1 - elif [[ "$(stat -c '%a' "${KEY_PATH}" 2>/dev/null || true)" != "644" ]]; then - run_privileged chmod 0644 "${KEY_PATH}" + if [[ "$(stat -c '%a' "${key_path}" 2>/dev/null || true)" != "644" ]]; then + run_privileged chmod 0644 "${key_path}" changed=1 fi @@ -175,7 +179,7 @@ ensure_key_and_sanitize() { local changed=0 local output="" - output="$(install_key "${distro_id}")" + output="$(install_key "${distro_id}" "${expected_keyring}")" if [[ "${output}" == *"changed=1"* ]]; then changed=1 fi @@ -197,7 +201,7 @@ case "${ACTION}" in usage exit 2 fi - install_key "${DISTRO_ID}" + install_key "${DISTRO_ID}" "${3:-${KEY_PATH}}" ;; sanitize-sources) DISTRO_ID="${2:-}" diff --git a/tests/unit/python/roles/sys-svc-container/files/test_apt_repo.py b/tests/unit/python/roles/sys-svc-container/files/test_apt_repo.py new file mode 100644 index 0000000000..66abd7521e --- /dev/null +++ b/tests/unit/python/roles/sys-svc-container/files/test_apt_repo.py @@ -0,0 +1,100 @@ +import os +import subprocess +import tempfile +import unittest +from pathlib import Path + +from utils import PROJECT_ROOT +from utils.cache.files import read_text + +SCRIPT = PROJECT_ROOT / "roles/sys-svc-container/files/shell/apt_repo.sh" + +CURL_STUB = """#!/bin/sh +dest="" +while [ "$#" -gt 0 ]; do +\tif [ "$1" = "-o" ]; then +\t\tdest="$2" +\t\tshift +\tfi +\tshift +done +if [ -z "$STUB_SERVED_KEY" ]; then +\techo "curl: (7) Failed to connect to download.docker.com port 443 after 0 ms" >&2 +\texit 7 +fi +cp "$STUB_SERVED_KEY" "$dest" +""" + +SUDO_STUB = '#!/bin/sh\nexec "$@"\n' + + +class TestAptRepoInstallKey(unittest.TestCase): + def run_install_key(self, *, installed, served): + """Run `apt_repo.sh install-key` against a stubbed key download. + + Args: + installed: content of the keyring before the run, or None when no + key is installed. + served: content the download returns, or None when the download + host refuses the connection. + + Returns: + Tuple of exit code, stdout, stderr and the keyring content after + the run (None when no keyring exists). + """ + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) + bin_dir = root / "bin" + bin_dir.mkdir() + for name, body in (("curl", CURL_STUB), ("sudo", SUDO_STUB)): + stub = bin_dir / name + stub.write_text(body) + stub.chmod(0o755) + keyring_dir = root / "keyrings" + keyring_dir.mkdir() + keyring_dir.chmod(0o755) + key = keyring_dir / "docker.asc" + if installed is not None: + key.write_text(installed) + key.chmod(0o644) + env = dict(os.environ) + env["PATH"] = f"{bin_dir}{os.pathsep}{env['PATH']}" + env["STUB_SERVED_KEY"] = "" + if served is not None: + served_file = root / "served.asc" + served_file.write_text(served) + env["STUB_SERVED_KEY"] = str(served_file) + done = subprocess.run( + ["bash", str(SCRIPT), "install-key", "debian", str(key)], + env=env, + capture_output=True, + text=True, + check=False, + ) + after = read_text(str(key)) if key.exists() else None + return done.returncode, done.stdout, done.stderr, after + + def test_a_refused_download_keeps_the_installed_key(self): + code, out, err, after = self.run_install_key(installed="OLD KEY\n", served=None) + self.assertEqual(code, 0, err) + self.assertIn("changed=0", out) + self.assertIn("keeping", err) + self.assertEqual(after, "OLD KEY\n") + + def test_a_refused_download_without_a_key_fails(self): + code, _, err, after = self.run_install_key(installed=None, served=None) + self.assertEqual(code, 1) + self.assertIn("Failed to download the Docker GPG key", err) + self.assertIsNone(after) + + def test_a_new_key_replaces_the_installed_one(self): + code, out, err, after = self.run_install_key( + installed="OLD KEY\n", served="NEW KEY\n" + ) + self.assertEqual(code, 0, err) + self.assertIn("changed=1", out) + self.assertEqual(after, "NEW KEY\n") + + +if __name__ == "__main__": + unittest.main() From 15bba26ef3fc7506c8f4320b0a3605ad47d9694d Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 13 Oct 2026 21:31:58 +0200 Subject: [PATCH 03/27] fix(web-app-prometheus): verify publicly trusted probe targets while the private CA is missing The readiness module http_ready rendered insecure_skip_verify from TLS_MODE and lookup('ca_injected', application_id) (#851). The lookup is true only when Prometheus itself has a domain, TLS and the self-signed mode, so in a self-signed deployment where Prometheus runs in another mode the exporter had no CA file and skipped verification. All targets share the module, so a target with a publicly trusted certificate was probed without verification too, and anyone on the probe's path could answer for a failed application. http_ready now always verifies. A second module, http_ready_private_ca, skips verification, and only the targets that need it select it: those in the self-signed mode while the CA is not mounted into Prometheus, through the __param_module label, which overrides the job's module for that target. The default self-signed deployment mounts the CA and keeps every target on the verifying module. Verified on a local self-signed Tor round, where the CA is mounted: the rendered blackbox.yml holds http_ready with insecure_skip_verify: false and http_ready_private_ca with true, and no target of the scrape configuration carries the module label. All targets of that round are http onion names, so the https path itself ran only in the unit tests: tests/unit/python/roles/web-app-prometheus pass, among them a publicly trusted target that keeps the verifying module while the CA is missing, a self-signed target that switches to the private-CA module, and the verifying module rendering insecure_skip_verify: false without the CA. Against the templates of main the three new cases fail. Closes #851 Co-Authored-By: Claude Opus 5.5 (1M context) --- .../templates/configuration/blackbox.yml.j2 | 16 +++- .../templates/configuration/prometheus.yml.j2 | 4 + .../test_blackbox_ready_module.py | 38 ++++++-- .../test_blackbox_targets.py | 90 ++++++++++++++----- 4 files changed, 116 insertions(+), 32 deletions(-) diff --git a/roles/web-app-prometheus/templates/configuration/blackbox.yml.j2 b/roles/web-app-prometheus/templates/configuration/blackbox.yml.j2 index 48147594e0..58feb765be 100644 --- a/roles/web-app-prometheus/templates/configuration/blackbox.yml.j2 +++ b/roles/web-app-prometheus/templates/configuration/blackbox.yml.j2 @@ -26,5 +26,19 @@ modules: fail_if_ssl: false fail_if_not_ssl: false tls_config: - insecure_skip_verify: {{ ((TLS_MODE | lower) == 'self_signed' and not lookup('ca_injected', application_id)) | lower }} + insecure_skip_verify: false + preferred_ip_protocol: "ip4" + + http_ready_private_ca: + prober: http + timeout: 10s + http: + valid_http_versions: ["HTTP/1.1", "HTTP/2.0"] + valid_status_codes: [200, 301, 302, 303, 307, 308, 401, 403] + method: GET + follow_redirects: false + fail_if_ssl: false + fail_if_not_ssl: false + tls_config: + insecure_skip_verify: true preferred_ip_protocol: "ip4" diff --git a/roles/web-app-prometheus/templates/configuration/prometheus.yml.j2 b/roles/web-app-prometheus/templates/configuration/prometheus.yml.j2 index 86ea8e71aa..3292b05829 100644 --- a/roles/web-app-prometheus/templates/configuration/prometheus.yml.j2 +++ b/roles/web-app-prometheus/templates/configuration/prometheus.yml.j2 @@ -43,6 +43,7 @@ scrape_configs: {% set canonical_map = lookup('domains') %} {% set probed_roles = lookup('roles_with_service', 'prometheus') | map(attribute='id') | list %} +{% set private_ca_unverifiable = not lookup('ca_injected', application_id) %} - job_name: "blackbox-healthz" metrics_path: /probe params: @@ -59,6 +60,9 @@ scrape_configs: {% endfor %} labels: app: "{{ _application_id }}" +{% if private_ca_unverifiable and lookup('tls', _application_id, 'mode') == 'self_signed' %} + __param_module: http_ready_private_ca +{% endif %} {% endif %} {% endif %} {% endfor %} diff --git a/tests/unit/python/roles/web-app-prometheus/test_blackbox_ready_module.py b/tests/unit/python/roles/web-app-prometheus/test_blackbox_ready_module.py index c49856cbc6..230d024290 100644 --- a/tests/unit/python/roles/web-app-prometheus/test_blackbox_ready_module.py +++ b/tests/unit/python/roles/web-app-prometheus/test_blackbox_ready_module.py @@ -10,7 +10,9 @@ from utils.cache.yaml import load_yaml_str TEMPLATE_DIR = PROJECT_ROOT / "roles/web-app-prometheus/templates/configuration" -def ready_module(*, tls_mode: str, prometheus_tls: bool, ca_injected: bool) -> dict: +def ready_module( + *, name: str, tls_mode: str, prometheus_tls: bool, ca_injected: bool +) -> dict: def lookup(name, *terms): if name == "tls" and terms[1] == "enabled": return prometheus_tls @@ -29,33 +31,55 @@ def ready_module(*, tls_mode: str, prometheus_tls: bool, ca_injected: bool) -> d application_id="web-app-prometheus", TLS_MODE=tls_mode, ) - return load_yaml_str(rendered)["modules"]["http_ready"]["http"] + return load_yaml_str(rendered)["modules"][name]["http"] class TestBlackboxReadyModule(unittest.TestCase): def test_an_http_target_passes_while_prometheus_itself_uses_tls(self): module = ready_module( - tls_mode="letsencrypt", prometheus_tls=True, ca_injected=False + name="http_ready", + tls_mode="letsencrypt", + prometheus_tls=True, + ca_injected=False, ) self.assertIs(module["fail_if_not_ssl"], False) def test_certificates_are_verified_while_prometheus_itself_has_no_tls(self): module = ready_module( - tls_mode="letsencrypt", prometheus_tls=False, ca_injected=False + name="http_ready", + tls_mode="letsencrypt", + prometheus_tls=False, + ca_injected=False, ) self.assertIs(module["tls_config"]["insecure_skip_verify"], False) def test_certificates_are_verified_once_the_private_ca_is_mounted(self): module = ready_module( - tls_mode="self_signed", prometheus_tls=True, ca_injected=True + name="http_ready", + tls_mode="self_signed", + prometheus_tls=True, + ca_injected=True, ) self.assertIs(module["tls_config"]["insecure_skip_verify"], False) - def test_verification_is_skipped_only_without_the_private_ca(self): + def test_certificates_are_verified_even_without_the_private_ca(self): module = ready_module( - tls_mode="self_signed", prometheus_tls=False, ca_injected=False + name="http_ready", + tls_mode="self_signed", + prometheus_tls=False, + ca_injected=False, + ) + self.assertIs(module["tls_config"]["insecure_skip_verify"], False) + + def test_only_the_private_ca_module_skips_verification(self): + module = ready_module( + name="http_ready_private_ca", + tls_mode="self_signed", + prometheus_tls=False, + ca_injected=False, ) self.assertIs(module["tls_config"]["insecure_skip_verify"], True) + self.assertIs(module["fail_if_not_ssl"], False) if __name__ == "__main__": diff --git a/tests/unit/python/roles/web-app-prometheus/test_blackbox_targets.py b/tests/unit/python/roles/web-app-prometheus/test_blackbox_targets.py index abc914988d..94cf72434a 100644 --- a/tests/unit/python/roles/web-app-prometheus/test_blackbox_targets.py +++ b/tests/unit/python/roles/web-app-prometheus/test_blackbox_targets.py @@ -14,35 +14,48 @@ DOMAINS = { "web-app-prometheus": [f"prometheus.{ONION}"], "web-app-nextcloud": {"nextcloud": f"next.cloud.{ONION}"}, "web-app-gitea": ["git.infinito.test"], + "web-app-matrix": ["matrix.infinito.test"], "web-svc-cdn": ["cdn.infinito.test"], "svc-db-postgres": ["postgres.infinito.test"], } -ROLES_WITH_THE_PROMETHEUS_SERVICE = ["web-app-nextcloud", "web-app-gitea"] +TLS_MODES = { + "web-app-nextcloud": "off", + "web-app-gitea": "self_signed", + "web-app-matrix": "letsencrypt", +} +ROLES_WITH_THE_PROMETHEUS_SERVICE = [ + "web-app-nextcloud", + "web-app-gitea", + "web-app-matrix", +] -def lookup(name, *terms, **_kwargs): - if name == "domains": - return DOMAINS - if name == "roles_with_service": - return [{"id": role} for role in ROLES_WITH_THE_PROMETHEUS_SERVICE] - if name == "tls": - term, want = terms - scheme = "http" if term.endswith(".onion") else "https" - return { - "url.base": f"{scheme}://{term}/", - "protocols.web": "http", - "enabled": False, - }[want] - if name == "domain": - return DOMAINS[terms[0]][0] - if name == "scrape_target": - return f"{terms[1]}:9000" - if name == "native_metrics_apps": - return [] - raise AssertionError(f"the template calls an unexpected lookup: {name!r}") +def probed_groups(*, ca_injected: bool) -> dict[str, dict]: + def lookup(name, *terms, **_kwargs): + if name == "domains": + return DOMAINS + if name == "roles_with_service": + return [{"id": role} for role in ROLES_WITH_THE_PROMETHEUS_SERVICE] + if name == "ca_injected": + return ca_injected + if name == "tls": + term, want = terms + if want == "mode": + return TLS_MODES[term] + scheme = "http" if term.endswith(".onion") else "https" + return { + "url.base": f"{scheme}://{term}/", + "protocols.web": "http", + "enabled": False, + }[want] + if name == "domain": + return DOMAINS[terms[0]][0] + if name == "scrape_target": + return f"{terms[1]}:9000" + if name == "native_metrics_apps": + return [] + raise AssertionError(f"the template calls an unexpected lookup: {name!r}") - -def probed_targets() -> dict[str, list[str]]: env = Environment( loader=FileSystemLoader(str(TEMPLATE_DIR)), undefined=StrictUndefined, @@ -58,11 +71,17 @@ def probed_targets() -> dict[str, list[str]]: ) jobs = {job["job_name"]: job for job in load_yaml_str(rendered)["scrape_configs"]} return { - group["labels"]["app"]: group["targets"] + group["labels"]["app"]: group for group in jobs["blackbox-healthz"]["static_configs"] } +def probed_targets() -> dict[str, list[str]]: + return { + app: group["targets"] for app, group in probed_groups(ca_injected=True).items() + } + + class TestBlackboxTargets(unittest.TestCase): def test_an_onion_app_is_probed_under_its_onion_name_over_http(self): self.assertEqual( @@ -79,6 +98,29 @@ class TestBlackboxTargets(unittest.TestCase): def test_only_the_roles_the_service_lookup_names_are_probed(self): self.assertEqual(set(probed_targets()), set(ROLES_WITH_THE_PROMETHEUS_SERVICE)) + def test_a_private_ca_target_skips_verification_while_the_ca_is_missing(self): + labels = probed_groups(ca_injected=False)["web-app-gitea"]["labels"] + self.assertEqual(labels["__param_module"], "http_ready_private_ca") + + def test_a_publicly_trusted_target_is_verified_while_the_ca_is_missing(self): + labels = probed_groups(ca_injected=False)["web-app-matrix"]["labels"] + self.assertNotIn("__param_module", labels) + + def test_a_plain_http_target_keeps_the_verifying_module(self): + labels = probed_groups(ca_injected=False)["web-app-nextcloud"]["labels"] + self.assertNotIn("__param_module", labels) + + def test_every_target_is_verified_once_the_ca_is_mounted(self): + groups = probed_groups(ca_injected=True) + self.assertEqual( + [ + app + for app, group in groups.items() + if "__param_module" in group["labels"] + ], + [], + ) + if __name__ == "__main__": unittest.main() From a0c7023eabac158781dd52ab4300cd043826e4a0 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 13 Oct 2026 21:32:10 +0200 Subject: [PATCH 04/27] fix(web-app-n8n): log the SSO hook through n8n's own logger The SSO hook reported its start, every sign-in, every created account and every error through this.logger (#852). n8n 2 calls an external hook with a context that holds only dbCollections, so this.logger is undefined and the optional chaining turned every one of those calls into a no-op: after an SSO sign-in that created an account, the container log held no line about it. The hook now resolves the Logger service from n8n's dependency container (@n8n/di and @n8n/backend-common, loaded through n8n's own require like the other modules the hook uses) and writes every message through it. The requires moved to the top of the ready hook so the first message can use the logger. Verified on the pinned image docker.n8n.io/n8nio/n8n:2.44.0, started with EXTERNAL_HOOK_FILES pointing at the hook and N8N_FORWARD_AUTH_HEADER set: with this hook the log carries "SSO middleware initializing with header: X-Forwarded-Email" and "SSO middleware initialized successfully" before "Editor is now accessible via:"; with the hook of main the same start reaches the editor without a single SSO line. Closes #852 Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/web-app-n8n/files/javascript/hooks.js | 40 +++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/roles/web-app-n8n/files/javascript/hooks.js b/roles/web-app-n8n/files/javascript/hooks.js index 80e3f06db6..0864ffa366 100644 --- a/roles/web-app-n8n/files/javascript/hooks.js +++ b/roles/web-app-n8n/files/javascript/hooks.js @@ -40,18 +40,20 @@ module.exports = { n8n: { ready: [ async function ({ app }, config) { - const headerName = process.env.N8N_FORWARD_AUTH_HEADER; - if (!headerName) { - this.logger?.info('N8N_FORWARD_AUTH_HEADER not set; SSO middleware disabled.'); - return; - } - - this.logger?.info(`SSO middleware initializing with header: ${headerName}`); - const { createRequire } = require('module'); const { dirname, resolve } = require('path'); const { randomBytes } = require('crypto'); const n8nRequire = createRequire(require.resolve('n8n')); + const logger = n8nRequire('@n8n/di').Container.get(n8nRequire('@n8n/backend-common').Logger); + + const headerName = process.env.N8N_FORWARD_AUTH_HEADER; + if (!headerName) { + logger.info('N8N_FORWARD_AUTH_HEADER not set; SSO middleware disabled.'); + return; + } + + logger.info(`SSO middleware initializing with header: ${headerName}`); + const Layer = createRequire(n8nRequire.resolve('express'))('router/lib/layer'); const { hash } = n8nRequire('bcryptjs'); const { issueCookie } = require(resolve(dirname(require.resolve('n8n')), 'auth/jwt')); @@ -92,16 +94,16 @@ module.exports = { const payload = JSON.parse(Buffer.from(parts[1], 'base64').toString()); firstName = payload.given_name || ''; lastName = payload.family_name || ''; - this.logger?.debug(`Extracted from access token: firstName="${firstName}", lastName="${lastName}"`); + logger.debug(`Extracted from access token: firstName="${firstName}", lastName="${lastName}"`); } } catch (e) { - this.logger?.debug(`Failed to decode access token: ${e.message}`); + logger.debug(`Failed to decode access token: ${e.message}`); } } // If the forward-auth header with email is missing — do nothing if (!emailHeader) { - this.logger?.debug(`No ${headerName} header found, skipping SSO auto-login`); + logger.debug(`No ${headerName} header found, skipping SSO auto-login`); return next(); } @@ -110,11 +112,11 @@ module.exports = { const userLastName = Array.isArray(lastName) ? lastName[0] : String(lastName).trim(); if (!userEmail) { - this.logger?.debug(`Empty ${headerName} header, skipping SSO auto-login`); + logger.debug(`Empty ${headerName} header, skipping SSO auto-login`); return next(); } - this.logger?.info(`SSO auto-login attempt for email: ${userEmail}`); + logger.info(`SSO auto-login attempt for email: ${userEmail}`); let user = await UserRepo.findOne({ where: { email: userEmail }, @@ -135,7 +137,7 @@ module.exports = { const created = await UserRepo.createUserWithProject(userData); user = created.user; - this.logger?.info(`Created new user: ${userEmail} (${userFirstName} ${userLastName}) via SSO`); + logger.info(`Created new user: ${userEmail} (${userFirstName} ${userLastName}) via SSO`); } else { let changed = false; if (userFirstName && user.firstName !== userFirstName) { @@ -148,14 +150,14 @@ module.exports = { } if (changed) { await UserRepo.save(user); - this.logger?.info(`Updated user: ${userEmail} (${userFirstName} ${userLastName}) via SSO`); + logger.info(`Updated user: ${userEmail} (${userFirstName} ${userLastName}) via SSO`); } else { - this.logger?.info(`Existing user logged in: ${userEmail} via SSO`); + logger.info(`Existing user logged in: ${userEmail} via SSO`); } } if (!user.role) { - this.logger?.error(`User ${userEmail} has no valid role; cannot issue cookie.`); + logger.error(`User ${userEmail} has no valid role; cannot issue cookie.`); res.statusCode = 401; res.end(`User ${userEmail} has no valid role. Ask admin to assign a role.`); return; @@ -168,14 +170,14 @@ module.exports = { return next(); } catch (error) { - this.logger?.error(`SSO middleware error: ${error.message}`); + logger.error(`SSO middleware error: ${error.message}`); return next(error); } }); // Insert our middleware right after cookieParser stack.splice(idx + 1, 0, layer); - this.logger?.info('SSO middleware initialized successfully'); + logger.info('SSO middleware initialized successfully'); } ] } From 25588d44b5680b22b697f2b9616c83491fbf25f8 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 13 Oct 2026 21:32:22 +0200 Subject: [PATCH 05/27] fix(web-app-seaweedfs): carry the tor gate in the sso pin of variant 0 meta/services.yml switches the SSO integration of SeaweedFS off on a Tor node, but variant 0 pinned services.sso to a literal true (#868). A round writes the variant pins into its inventory, the inventory value wins over the expression in services.yml, and a Tor round therefore enabled SSO for a frontend it does not deploy. Measured in a round inventory: `sso {'enabled': True, 'shared': True}` with svc-net-tor in its groups. The pin now carries the same gate as logout, dashboard and prometheus, which #832 already fixed the same way. The sso block in services.yml is marked for the variants-coverage and bond-baseline guards like the frontend block, since no variant may force this consumer on a Tor node. Verified on a local Tor round of variant 0: the round inventory holds `{'enabled': "{{ 'svc-net-tor' not in group_names }}", 'shared': ...}` for the sso block instead of True, and after the deploy only the seaweedfs container runs; seaweedfs-sso-proxy and seaweedfs-redis, which an earlier deploy had started, are gone, and the rendered compose file holds no SSO service. tests/integration/roles/meta/variants and the sso-variant-tor lint pass; without the two markers test_bond_baseline and test_coverage fail on services.sso. feature/store-i18n carries the same pin change for all four services in d70e2bb967, so the two branches merge without a conflict in meta/variants.yml. Closes #868 Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/web-app-seaweedfs/meta/services.yml | 2 ++ roles/web-app-seaweedfs/meta/variants.yml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/web-app-seaweedfs/meta/services.yml b/roles/web-app-seaweedfs/meta/services.yml index 2ba8b58900..c99073bd47 100644 --- a/roles/web-app-seaweedfs/meta/services.yml +++ b/roles/web-app-seaweedfs/meta/services.yml @@ -12,6 +12,8 @@ frontend: domains: - filer - master +# nocheck: variants-coverage the onion gate is a hard invariant; no variant may force this consumer on a tor node. +# nocheck: bond-baseline same reason: variant 0 must not pin this consumer on. sso: bond: 1 enabled: "{{ ('web-app-keycloak' in group_names) and ('svc-net-tor' not in group_names) }}" diff --git a/roles/web-app-seaweedfs/meta/variants.yml b/roles/web-app-seaweedfs/meta/variants.yml index 678afaac86..4ea8d2cbef 100644 --- a/roles/web-app-seaweedfs/meta/variants.yml +++ b/roles/web-app-seaweedfs/meta/variants.yml @@ -6,8 +6,8 @@ container_backup: enabled: true sso: - enabled: true - shared: true + enabled: "{{ 'svc-net-tor' not in group_names }}" + shared: "{{ 'svc-net-tor' not in group_names }}" logout: enabled: "{{ 'svc-net-tor' not in group_names }}" shared: "{{ 'svc-net-tor' not in group_names }}" From 8a29ba0bfdfafaabdfbc839c557085d86ee24527 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 01:04:36 +0200 Subject: [PATCH 06/27] fix(images): leave eol roles out of image discovery The scheduled mirror job has failed every day since 2026-09-25 on the same two images: quay.io/minio/minio and quay.io/minio/mc answer `unauthorized` to anonymous pulls ("2/197 failed", run 38352569503). Both belong to web-app-minio, an eol role outside the lifecycle envelope that default.env tests, so no CI deploy pulls them. iter_role_images now skips every role that is_maintained() reports as unmaintained, the check the version updaters already apply to the same list. On the tree the discovery yields 187 images instead of 192; the five it drops belong to the four eol roles web-app-confluence, web-app-jira, web-app-minio and web-app-phpldapadmin. The mirror sync, resolver and wait read this list, and their descriptions and mirror.md now say so. The roles directory is resolved first: is_maintained reads a relative path as a role name and would keep every role. 475ab9b386 on feature/store-i18n takes the same approach with a lifecycle reader of its own; main already has is_maintained for it. Co-Authored-By: Claude Opus 5.5 (1M context) --- cli/contributing/mirror/resolver/__main__.py | 5 +- cli/contributing/mirror/sync/__main__.py | 4 +- cli/contributing/mirror/wait/__main__.py | 4 +- docs/contributing/artefact/image/mirror.md | 2 +- .../docker/test_image_discovery_lifecycle.py | 67 +++++++++++++++++++ utils/docker/image/discovery.py | 9 ++- 6 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 tests/unit/python/utils/docker/test_image_discovery_lifecycle.py diff --git a/cli/contributing/mirror/resolver/__main__.py b/cli/contributing/mirror/resolver/__main__.py index 01df2b1a08..4085479356 100644 --- a/cli/contributing/mirror/resolver/__main__.py +++ b/cli/contributing/mirror/resolver/__main__.py @@ -12,8 +12,9 @@ from utils.docker.image.discovery import iter_role_images def main() -> int: parser = argparse.ArgumentParser( description=( - "Emit the mirrors.yml mapping that redirects every role-declared " - "image (applications.*.services.*) to its GHCR mirror URI." + "Emit the mirrors.yml mapping that redirects every image a " + "non-eol role declares (applications.*.services.*) to its GHCR " + "mirror URI." ), ) parser.add_argument("--repo-root", default=".") diff --git a/cli/contributing/mirror/sync/__main__.py b/cli/contributing/mirror/sync/__main__.py index 2212f332db..d453732b46 100644 --- a/cli/contributing/mirror/sync/__main__.py +++ b/cli/contributing/mirror/sync/__main__.py @@ -53,8 +53,8 @@ def _throttle_before_next_copy( def main() -> int: parser = argparse.ArgumentParser( description=( - "Mirror every role-declared image and every image the CI runner " - "pulls itself to the configured GHCR registry, " + "Mirror every image a non-eol role declares and every image the " + "CI runner pulls itself to the configured GHCR registry, " "optionally throttled and optionally skipping already-mirrored " "tags." ), diff --git a/cli/contributing/mirror/wait/__main__.py b/cli/contributing/mirror/wait/__main__.py index 85769b2f7c..0820284b5c 100644 --- a/cli/contributing/mirror/wait/__main__.py +++ b/cli/contributing/mirror/wait/__main__.py @@ -23,8 +23,8 @@ def _validate_positive_int(value: str) -> int: def main() -> int: parser = argparse.ArgumentParser( description=( - "Wait until every role-declared image and every image the CI runner " - "pulls itself has been mirrored to the " + "Wait until every image a non-eol role declares and every image " + "the CI runner pulls itself has been mirrored to the " "configured GHCR registry. Used on fork pull_request runs that depend " "on a pull_request_target mirror job populating the destination first." ), diff --git a/docs/contributing/artefact/image/mirror.md b/docs/contributing/artefact/image/mirror.md index a0a8af6a47..e2f97cf848 100644 --- a/docs/contributing/artefact/image/mirror.md +++ b/docs/contributing/artefact/image/mirror.md @@ -32,7 +32,7 @@ Example: `ghcr.io/kevinveenbirkenbach/infinito-nexus-core/mirror/docker.io/nextc ### Image Discovery 🔍 -`utils/docker/image/discovery.py` discovers all role images via `iter_role_images()`. See [origin.md](origin.md) for the declaration format and supported registries. +`utils/docker/image/discovery.py` discovers the role images via `iter_role_images()`. It leaves out every role whose lifecycle is `eol` (`is_maintained()` in `utils/update/base.py`), so neither the mirror nor `mirrors.yml` covers those images. See [origin.md](origin.md) for the declaration format and supported registries. ### GHCRProvider 🐳 diff --git a/tests/unit/python/utils/docker/test_image_discovery_lifecycle.py b/tests/unit/python/utils/docker/test_image_discovery_lifecycle.py new file mode 100644 index 0000000000..5c7386125a --- /dev/null +++ b/tests/unit/python/utils/docker/test_image_discovery_lifecycle.py @@ -0,0 +1,67 @@ +from __future__ import annotations + +import os +import tempfile +import unittest +from pathlib import Path + +from utils.docker.image.discovery import iter_role_images +from utils.roles.mapping import ROLE_FILE_META_SERVICES + +SUPPORTED = """--- +demo: + image: libretranslate/libretranslate + version: v1.9.6 + lifecycle: stable +helper: + image: alpine + version: "3.22" +""" + +RETIRED = """--- +demo: + image: quay.io/minio/minio + version: RELEASE.2025-09-07T16-13-09Z + lifecycle: eol +client: + image: quay.io/minio/mc + version: RELEASE.2025-08-13T08-35-41Z +""" + +UNSTAGED = """--- +demo: + image: libretranslate/libretranslate + version: v1.9.6 +""" + + +class TestImageDiscoveryLifecycle(unittest.TestCase): + def _images(self, services_yaml: str, *, relative: bool = False) -> set[str]: + """Discover the images of one role written into a temporary repository. + + Args: + services_yaml: the role's ``meta/services.yml``. + relative: pass the repository root relative to the working directory. + """ + with tempfile.TemporaryDirectory() as tmp: + services = Path(tmp) / "roles" / "web-app-demo" / ROLE_FILE_META_SERVICES + services.parent.mkdir(parents=True) + services.write_text(services_yaml, encoding="utf-8") + root = Path(os.path.relpath(tmp)) if relative else Path(tmp) + return {ref.service for ref in iter_role_images(root)} + + def test_a_supported_role_yields_every_service(self) -> None: + self.assertEqual({"demo", "helper"}, self._images(SUPPORTED)) + + def test_a_retired_role_yields_none_of_its_services(self) -> None: + self.assertEqual(set(), self._images(RETIRED)) + + def test_a_role_that_names_no_stage_is_kept(self) -> None: + self.assertEqual({"demo"}, self._images(UNSTAGED)) + + def test_a_relative_root_still_leaves_a_retired_role_out(self) -> None: + self.assertEqual(set(), self._images(RETIRED, relative=True)) + + +if __name__ == "__main__": + unittest.main() diff --git a/utils/docker/image/discovery.py b/utils/docker/image/discovery.py index 3246b8fdd5..7f1c7bac0d 100644 --- a/utils/docker/image/discovery.py +++ b/utils/docker/image/discovery.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING from utils.cache.yaml import load_yaml_any as _load_yaml_cached from utils.docker.image.pin import pull_reference from utils.roles.mapping import ROLE_FILE_META_SERVICES +from utils.update.base import is_maintained if TYPE_CHECKING: from collections.abc import Iterable @@ -191,14 +192,18 @@ def iter_role_images(repo_root: Path) -> Iterable[ImageRef]: """ Yield all ImageRef entries discovered across all roles in *repo_root*. - Source: roles/**/meta/services.yml → .{image,version}. + Source: roles/**/meta/services.yml → .{image,version}. Roles the + updaters do not maintain (``is_maintained``) are left out. See docs/contributing/artefact/image.md for the full format reference. """ - roles_dir = repo_root / "roles" + roles_dir = (repo_root / "roles").resolve() for services_file in roles_dir.glob(f"**/{ROLE_FILE_META_SERVICES}"): role_name = services_file.parent.parent.name + if not is_maintained(roles_dir, role_name): + continue + services = load_yaml(services_file) if not isinstance(services, dict): From d412b23409c10afa072f837648251d87100c67c0 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 01:32:05 +0200 Subject: [PATCH 07/27] fix(ci): stop the release backfill below the oldest buildable tag The release backfill dispatches the highest version tag whose images are missing. Every tag from v15.0.0 down to v9.0.2 has its images now, so since 2026-10-05 it picks v9.0.1 every day, and each of the nine runs failed in "Build missing CI images / Image" at `entry.sh: line 19: infinito: command not found`. The v9.0.1 tree cannot build its own image; c680be12ea fixed that build in v9.0.2, and a tag cannot take the fix. highest_release_tag.sh now stops at v9.0.2: no tag below it is picked, so the backfill reports nothing missing instead of retrying v9.0.1. v9.0.0 has the same Dockerfile, Makefile and scripts/docker as v9.0.1. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../resolve/missing/highest_release_tag.sh | 8 +++ .../scripts/meta/resolve/missing/__init__.py | 0 .../missing/test_highest_release_tag.py | 66 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 tests/unit/python/scripts/meta/resolve/missing/__init__.py create mode 100644 tests/unit/python/scripts/meta/resolve/missing/test_highest_release_tag.py diff --git a/scripts/meta/resolve/missing/highest_release_tag.sh b/scripts/meta/resolve/missing/highest_release_tag.sh index 5fbefb79dc..70363b940d 100755 --- a/scripts/meta/resolve/missing/highest_release_tag.sh +++ b/scripts/meta/resolve/missing/highest_release_tag.sh @@ -1,6 +1,11 @@ #!/usr/bin/env bash set -euo pipefail +# The backfill stops below v9.0.2: v9.0.1 cannot build its image from its own +# tree (`infinito: command not found`, fixed by c680be12ea in v9.0.2), and +# v9.0.0 has the same Dockerfile, Makefile and scripts/docker. +oldest_buildable_tag="v9.0.2" + : "${OWNER:?Missing OWNER}" : "${REGISTRY:?Missing REGISTRY}" : "${REPO_PREFIX:?Missing REPO_PREFIX}" @@ -18,6 +23,9 @@ fi for ((i = ${#tags[@]} - 1; i >= 0; i--)); do tag="${tags[$i]}" + if [[ "$(printf '%s\n' "${tag}" "${oldest_buildable_tag}" | sort -V | head -n 1)" != "${oldest_buildable_tag}" ]]; then + exit 0 + fi tag_missing="false" for distro in ${INFINITO_DISTROS}; do diff --git a/tests/unit/python/scripts/meta/resolve/missing/__init__.py b/tests/unit/python/scripts/meta/resolve/missing/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/scripts/meta/resolve/missing/test_highest_release_tag.py b/tests/unit/python/scripts/meta/resolve/missing/test_highest_release_tag.py new file mode 100644 index 0000000000..c9801bb119 --- /dev/null +++ b/tests/unit/python/scripts/meta/resolve/missing/test_highest_release_tag.py @@ -0,0 +1,66 @@ +from __future__ import annotations + +import os +import subprocess +import tempfile +import unittest +from pathlib import Path + +from utils.cache.files import PROJECT_ROOT + +SCRIPT = ( + PROJECT_ROOT / "scripts" / "meta" / "resolve" / "missing" / "highest_release_tag.sh" +) +TAGS = ("v9.0.0", "v9.0.1", "v9.0.2", "v14.1.0", "v15.0.0") +STUBS = { + "git": '#!/usr/bin/env bash\nprintf "%s\\n" ${STUB_TAGS}\n', + "docker": ( + "#!/usr/bin/env bash\n" + 'case " ${STUB_MISSING} " in *" ${3##*:} "*) exit 1 ;; esac\n' + ), +} + + +def pick(*missing: str) -> subprocess.CompletedProcess: + """Run the picker against stubbed ``git`` tags and ``docker`` manifests. + + Args: + missing: tags whose images the registry does not hold. + """ + with tempfile.TemporaryDirectory() as tmp: + for name, body in STUBS.items(): + stub = Path(tmp) / name + stub.write_text(body) + stub.chmod(0o755) + env = { + **{k: v for k, v in os.environ.items() if k != "BASH_ENV"}, + "PATH": f"{tmp}{os.pathsep}{os.environ['PATH']}", + "STUB_TAGS": " ".join(TAGS), + "STUB_MISSING": " ".join(missing), + "OWNER": "acme", + "REGISTRY": "ghcr.io", + "REPO_PREFIX": "core", + "INFINITO_DISTROS": "debian arch", + } + return subprocess.run( + ["bash", str(SCRIPT)], + env=env, + capture_output=True, + text=True, + check=True, + ) + + +class TestHighestReleaseTag(unittest.TestCase): + def test_tags_below_the_oldest_buildable_one_are_not_picked(self) -> None: + self.assertEqual("", pick("v9.0.1", "v9.0.0").stdout) + + def test_the_oldest_buildable_tag_is_picked(self) -> None: + self.assertEqual("v9.0.2\n", pick("v9.0.2", "v9.0.1").stdout) + + def test_the_highest_missing_tag_is_picked(self) -> None: + self.assertEqual("v14.1.0\n", pick("v14.1.0", "v9.0.1").stdout) + + +if __name__ == "__main__": + unittest.main() From fd9286b24f13eb6e011b0a9abf395a83212455cd Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 01:32:35 +0200 Subject: [PATCH 08/27] test(lint): mark the stub call log as written by the test test_no_uncached_file_reads rejects Path.read_text in tests unless the file is written in the test itself. The mermaid script test reads the call log its stubs append to during the run, so that read carries `# nocheck: cache-read`. The mermaid cli test is formatted with ruff. Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/unit/python/scripts/lint/test_mermaid.py | 2 +- tests/unit/python/utils/install/lint/test_mermaid_cli.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/unit/python/scripts/lint/test_mermaid.py b/tests/unit/python/scripts/lint/test_mermaid.py index 30a7c3e1cd..67d3099a2f 100644 --- a/tests/unit/python/scripts/lint/test_mermaid.py +++ b/tests/unit/python/scripts/lint/test_mermaid.py @@ -49,7 +49,7 @@ class TestMermaidLint(unittest.TestCase): text=True, check=False, ) - recorded = calls.read_text().split() + recorded = calls.read_text().split() # nocheck: cache-read stub call log self.assertEqual(proc.returncode, 1, proc.stderr) self.assertIn("cannot render a minimal diagram", proc.stderr) diff --git a/tests/unit/python/utils/install/lint/test_mermaid_cli.py b/tests/unit/python/utils/install/lint/test_mermaid_cli.py index 3c827abe0d..aff181b340 100644 --- a/tests/unit/python/utils/install/lint/test_mermaid_cli.py +++ b/tests/unit/python/utils/install/lint/test_mermaid_cli.py @@ -46,7 +46,9 @@ class TestBrowserProvisioning(unittest.TestCase): def test_root_installs_the_browser_with_its_libraries(self) -> None: calls, warnings = self.provision(euid=0, results=[0]) self.assertEqual(len(calls), 1) - self.assertEqual(calls[0].args[0][-2:], ["chrome-headless-shell", "--install-deps"]) + self.assertEqual( + calls[0].args[0][-2:], ["chrome-headless-shell", "--install-deps"] + ) self.assertEqual(warnings, []) def test_a_user_installs_the_browser_without_libraries(self) -> None: From 078d0a068276ea7f34dce9e892881d6db3abdcae Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 08:56:59 +0200 Subject: [PATCH 09/27] fix(lint): provision mmdc's browser only when it is missing install-lint provisioned chrome-headless-shell on every run, and `make lint` runs install-lint once per lint target in parallel whenever its stamp is not fresh. On CI the stamp never is (eslint lives in node_modules, not on PATH), so one lint job provisioned 16 times (run 38455552981). As root, puppeteer's --install-deps runs `apt-get satisfy` even for an installed browser, and two of those at once fail on the dpkg lock; a failed provisioning then deleted the shared browser cache while lint-mermaid could be rendering with it. The browser is now provisioned only when it is not installed, and --force drops its cache so `make install-lint-force` still reinstalls it with its libraries. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../unit/python/utils/install/lint/test_main.py | 16 +++++++++++++++- .../utils/install/lint/test_mermaid_cli.py | 15 +++++++++++++++ utils/install/lint/__main__.py | 4 +++- utils/install/lint/mermaid_cli.py | 2 ++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/unit/python/utils/install/lint/test_main.py b/tests/unit/python/utils/install/lint/test_main.py index 6cfd4a48d8..1ac3539ca8 100644 --- a/tests/unit/python/utils/install/lint/test_main.py +++ b/tests/unit/python/utils/install/lint/test_main.py @@ -99,9 +99,10 @@ class TestStampLogic(unittest.TestCase): self.assertTrue((root / cli._STAMP).exists()) def test_force_drops_stamp(self) -> None: - with TemporaryDirectory() as tmp: + with TemporaryDirectory() as tmp, TemporaryDirectory() as cache: root = _make_repo_root(tmp, stamp_age_offset=60.0) with ( + mock.patch.dict(os.environ, {"PUPPETEER_CACHE_DIR": cache}), mock.patch.object(cli, "PROJECT_ROOT", root), mock.patch.object(cli, "_install_all") as inst, ): @@ -109,6 +110,19 @@ class TestStampLogic(unittest.TestCase): self.assertEqual(rc, 0) inst.assert_called_once() + def test_force_drops_the_mermaid_browser(self) -> None: + with TemporaryDirectory() as tmp, TemporaryDirectory() as cache: + root = _make_repo_root(tmp, stamp_age_offset=60.0) + browser = Path(cache) / "chrome-headless-shell" / "linux-1" + browser.mkdir(parents=True) + with ( + mock.patch.dict(os.environ, {"PUPPETEER_CACHE_DIR": cache}), + mock.patch.object(cli, "PROJECT_ROOT", root), + mock.patch.object(cli, "_install_all"), + ): + cli.main(["--force"]) + self.assertFalse(browser.exists()) + class TestGroupDispatch(unittest.TestCase): def test_group_only_bypasses_stamp(self) -> None: diff --git a/tests/unit/python/utils/install/lint/test_mermaid_cli.py b/tests/unit/python/utils/install/lint/test_mermaid_cli.py index aff181b340..600879cf61 100644 --- a/tests/unit/python/utils/install/lint/test_mermaid_cli.py +++ b/tests/unit/python/utils/install/lint/test_mermaid_cli.py @@ -84,8 +84,23 @@ class TestBrowserProvisioning(unittest.TestCase): self.assertEqual(len(warnings), 1) self.assertIn("out\nerr\n", warnings[0]) + def test_an_installed_browser_is_not_provisioned_again(self) -> None: + with TemporaryDirectory() as cache: + build = Path(cache) / "chrome-headless-shell" / "linux-1" / "linux64" + build.mkdir(parents=True) + (build / "chrome-headless-shell").write_text("", encoding="utf-8") + with ( + mock.patch.dict(os.environ, {"PUPPETEER_CACHE_DIR": cache}), + mock.patch.object(mermaid_cli, "which", return_value=True), + mock.patch.object(mermaid_cli.subprocess, "run") as run, + ): + mermaid_cli.ensure() + run.assert_not_called() + def test_a_timeout_warns_instead_of_raising(self) -> None: with ( + TemporaryDirectory() as cache, + mock.patch.dict(os.environ, {"PUPPETEER_CACHE_DIR": cache}), mock.patch.object(mermaid_cli, "which", return_value=True), mock.patch.object( mermaid_cli.subprocess, diff --git a/utils/install/lint/__main__.py b/utils/install/lint/__main__.py index 7bf56b6079..9fed403e4b 100644 --- a/utils/install/lint/__main__.py +++ b/utils/install/lint/__main__.py @@ -2,7 +2,8 @@ Mirrors the prior ``scripts/install/lint.sh`` interface: no-arg / ``all`` runs every group + manages the stamp file; explicit groups bypass the -stamp; ``--force`` (as first arg) drops the stamp and reinstalls. +stamp; ``--force`` (as first arg) drops the stamp and mmdc's browser cache +and reinstalls. """ from __future__ import annotations @@ -215,6 +216,7 @@ def main(argv: list[str] | None = None) -> int: stamp_path = repo_root / _STAMP if stamp_path.exists(): stamp_path.unlink() + shutil.rmtree(mermaid_cli.browser_cache(), ignore_errors=True) args = args[1:] if not args: diff --git a/utils/install/lint/mermaid_cli.py b/utils/install/lint/mermaid_cli.py index e84c788327..e60a96371a 100644 --- a/utils/install/lint/mermaid_cli.py +++ b/utils/install/lint/mermaid_cli.py @@ -56,6 +56,8 @@ def _provision_browser() -> subprocess.CompletedProcess[str]: def _ensure_browser() -> None: + if browser_installed(): + return log(f"Provisioning {BROWSER} for mmdc via puppeteer.") try: done = _provision_browser() From f92b7000af006398d0af95ed80b1cd1059d3addf Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 12:01:36 +0200 Subject: [PATCH 10/27] fix(web-app-stalwart): let address bans expire Stalwart bans an address for good once it passes a failure rate: the four *BanPeriod fields of its Security settings are null, and block_ip stores a ban without a period with expires_at.unwrap_or(u64::MAX). Many clients reach Stalwart through one address (the reverse proxy, published ports, Tor, the swarm ingress), so one burst of failed logins locked that path out until someone deleted the BlockedIp entry by hand. The role now sets authBanPeriod, abuseBanPeriod, loiterBanPeriod and scanBanPeriod to services.stalwart.ban_period_seconds, one hour by default, and reloads the settings, as Stalwart's own security test does after it changes a ban period. It reads the settings first and leaves them alone when they already match, so a redeploy changes nothing. Closes #916 Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/web-app-stalwart/README.md | 4 +++ roles/web-app-stalwart/meta/services.yml | 1 + roles/web-app-stalwart/tasks/manager_ops.yml | 3 ++ roles/web-app-stalwart/tasks/security.yml | 34 ++++++++++++++++++++ roles/web-app-stalwart/vars/main.yml | 7 ++++ 5 files changed, 49 insertions(+) create mode 100644 roles/web-app-stalwart/tasks/security.yml diff --git a/roles/web-app-stalwart/README.md b/roles/web-app-stalwart/README.md index 83d455f38a..5693349c6d 100644 --- a/roles/web-app-stalwart/README.md +++ b/roles/web-app-stalwart/README.md @@ -197,6 +197,10 @@ account (or the Keycloak SSO token when SSO is enabled). (`templates/jmap/*.json.j2`). - **Under SSO, trusted internal networks relay without SMTP AUTH** — the no-reply bot has no password once the auth directory is OIDC. +- **Address bans expire after `services.stalwart.ban_period_seconds`** (one + hour by default). Without a period Stalwart keeps a ban forever, and the + reverse proxy, the published ports, Tor and the swarm ingress hand many + clients one address. ## Features diff --git a/roles/web-app-stalwart/meta/services.yml b/roles/web-app-stalwart/meta/services.yml index fcb805d964..924838638f 100644 --- a/roles/web-app-stalwart/meta/services.yml +++ b/roles/web-app-stalwart/meta/services.yml @@ -54,6 +54,7 @@ stalwart: project_hard_restart: true migration: import_mailu: false + ban_period_seconds: 3600 # nocheck: min-storage-headroom Reason: the mail store (maildir blobs, FTS index, queue) lives in this service's volumes and dwarfs the image transfer size min_storage: 20GB domain: "{{ lookup('email').domain }}" diff --git a/roles/web-app-stalwart/tasks/manager_ops.yml b/roles/web-app-stalwart/tasks/manager_ops.yml index 4727bd0c5d..a6d57d500a 100644 --- a/roles/web-app-stalwart/tasks/manager_ops.yml +++ b/roles/web-app-stalwart/tasks/manager_ops.yml @@ -27,6 +27,9 @@ - name: "🔧 Point Stalwart's file tracer at a writable directory" include_tasks: tracing.yml +- name: "⏱️ Let Stalwart's address bans expire" + include_tasks: security.yml + - name: "⚙️ Provision the Stalwart WebUI (WebAdmin) bundle" include_tasks: 02_webadmin.yml diff --git a/roles/web-app-stalwart/tasks/security.yml b/roles/web-app-stalwart/tasks/security.yml new file mode 100644 index 0000000000..a311f8a242 --- /dev/null +++ b/roles/web-app-stalwart/tasks/security.yml @@ -0,0 +1,34 @@ +--- +- name: "📖 Read Stalwart's ban settings" + include_tasks: jmap_call.yml + vars: + stalwart_jmap_body: >- + {{ {'using': ['urn:ietf:params:jmap:core', 'urn:stalwart:jmap'], + 'methodCalls': [['x:Security/get', {'ids': ['singleton']}, 'c0']]} | to_json }} + +- name: "🔍 Resolve Stalwart's current ban periods" + ansible.builtin.set_fact: + stalwart_ban_periods_current: >- + {{ stalwart_jmap.methodResponses[0][1].list[0] + | dict2items | selectattr('key', 'in', STALWART_BAN_PERIODS) | items2dict }} + +- name: "⏱️ Let Stalwart's address bans expire" + when: stalwart_ban_periods_current != STALWART_BAN_PERIODS + block: + - name: "🔧 Set Stalwart's ban periods" + include_tasks: jmap_call.yml + vars: + stalwart_jmap_body: >- + {{ {'using': ['urn:ietf:params:jmap:core', 'urn:stalwart:jmap'], + 'methodCalls': [['x:Security/set', + {'update': {'singleton': STALWART_BAN_PERIODS}}, + 'c0']]} | to_json }} + + - name: "🔄 Reload Stalwart's settings" + include_tasks: jmap_call.yml + vars: + stalwart_jmap_body: >- + {{ {'using': ['urn:ietf:params:jmap:core', 'urn:stalwart:jmap'], + 'methodCalls': [['x:Action/set', + {'create': {'a': {'@type': 'ReloadSettings'}}}, + 'c0']]} | to_json }} diff --git a/roles/web-app-stalwart/vars/main.yml b/roles/web-app-stalwart/vars/main.yml index 4d4cb42c1b..fb23e4e9f2 100644 --- a/roles/web-app-stalwart/vars/main.yml +++ b/roles/web-app-stalwart/vars/main.yml @@ -67,6 +67,13 @@ STALWART_DMARC_RUF: "{{ lookup('config', application_id, 'users.administrator.em STALWART_TRUSTED_NETWORKS: "{{ NETWORK_TRUSTED_PROXY_CIDRS }}" +STALWART_BAN_PERIOD_MS: "{{ (lookup('config', application_id, 'services.stalwart.ban_period_seconds') | int) * 1000 }}" +STALWART_BAN_PERIODS: + authBanPeriod: "{{ STALWART_BAN_PERIOD_MS | int }}" + abuseBanPeriod: "{{ STALWART_BAN_PERIOD_MS | int }}" + loiterBanPeriod: "{{ STALWART_BAN_PERIOD_MS | int }}" + scanBanPeriod: "{{ STALWART_BAN_PERIOD_MS | int }}" + STALWART_SSO_ENABLED: "{{ lookup('sso', application_id, 'is_enabled') | bool }}" STALWART_IMPORT_MAILU: "{{ lookup('config', application_id, 'services.stalwart.migration.import_mailu') | bool }}" From 8c0a6706273ba11dc5ba29129f070a1d745f67f2 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 12:01:49 +0200 Subject: [PATCH 11/27] fix(web-app-n8n): start the gateway probe from its trigger under n8n 2 Since the role moved to n8n 2 (2.42.3 on 2026-10-05, now 2.44.0), POST /rest/workflows/:id/run accepts a manual run only with a trigger to start from or a destination node; any other key, `workflowData` among them, is dropped. The LiteLLM gateway test still sent only `workflowData`, so every attempt failed with HTTP 400 "To run the workflow manually, specify either a trigger to start from or a destination node." (PR #912, run 38455633497, job 115523214958). On main the test sat behind the MCP provisioning failure of n8n#0 that e4078c05fd fixed, so the next main run would have hit it. The test now runs the stored probe workflow from its manual trigger. Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/web-app-n8n/files/playwright/test-litellm-gateway.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/roles/web-app-n8n/files/playwright/test-litellm-gateway.js b/roles/web-app-n8n/files/playwright/test-litellm-gateway.js index 97d55b4d57..7a77fefaed 100644 --- a/roles/web-app-n8n/files/playwright/test-litellm-gateway.js +++ b/roles/web-app-n8n/files/playwright/test-litellm-gateway.js @@ -8,6 +8,7 @@ const gatewayModel = decodeDotenvQuotedValue(process.env.N8N_LITELLM_MODEL); const CREDENTIAL_TYPE = "openAiApi"; const PROBE_WORKFLOW = "infinito:litellm-probe"; +const TRIGGER_NODE = "Start"; const REQUEST_NODE = "Gateway"; const PROMPT = "Reply with exactly the word: pong"; const FINAL_STATUSES = new Set(["success", "error", "crashed", "canceled"]); @@ -158,7 +159,7 @@ function probeWorkflow(credentialId, endpoint) { nodes: [ { id: "infinito-litellm-start", - name: "Start", + name: TRIGGER_NODE, type: "n8n-nodes-base.manualTrigger", typeVersion: 1, position: [0, 0], @@ -188,7 +189,7 @@ function probeWorkflow(credentialId, endpoint) { credentials: { [CREDENTIAL_TYPE]: { id: credentialId, name: credentialName } }, }, ], - connections: { Start: { main: [[{ node: REQUEST_NODE, type: "main", index: 0 }]] } }, + connections: { [TRIGGER_NODE]: { main: [[{ node: REQUEST_NODE, type: "main", index: 0 }]] } }, }; } @@ -286,7 +287,7 @@ exports.register = function (shared) { try { const run = await rest("POST", `/rest/workflows/${workflowId}/run`, { - workflowData: { ...workflow, id: workflowId }, + triggerToStartFrom: { name: TRIGGER_NODE }, }); expect( run.status, From 8a97cd5cfab98a67aa7ef5a58c3d95f7b2aa8b2e Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:54:30 +0000 Subject: [PATCH 12/27] update(images): update Docker image versions (svc-ai-ollama) --- roles/svc-ai-ollama/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/svc-ai-ollama/meta/services.yml b/roles/svc-ai-ollama/meta/services.yml index 77fc9801ed..84f50e6450 100644 --- a/roles/svc-ai-ollama/meta/services.yml +++ b/roles/svc-ai-ollama/meta/services.yml @@ -13,7 +13,7 @@ ollama: backup: no_stop_required: true image: ollama/ollama - version: 0.40.3 + version: 0.40.4 name: ollama min_storage: 3473MB cpus: "4.0" From a25faae191b2a2bcf99b15e39a5e5320c4f397cd Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:54:36 +0000 Subject: [PATCH 13/27] update(images): update Docker image versions (sys-ctl-hlth-csp) --- roles/sys-ctl-hlth-csp/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/sys-ctl-hlth-csp/meta/services.yml b/roles/sys-ctl-hlth-csp/meta/services.yml index 2cff885e8c..ba813f69b7 100644 --- a/roles/sys-ctl-hlth-csp/meta/services.yml +++ b/roles/sys-ctl-hlth-csp/meta/services.yml @@ -8,4 +8,4 @@ csp: categories: [web] csp-checker: image: ghcr.io/kevinveenbirkenbach/csp-checker - version: 3.0.5 + version: 3.1.0 From ca318c2db33df62431a004276a00f2d62cc01fd8 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:54:41 +0000 Subject: [PATCH 14/27] update(images): update Docker image versions (test-e2e-playwright) --- roles/test-e2e-playwright/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/test-e2e-playwright/meta/services.yml b/roles/test-e2e-playwright/meta/services.yml index 893702e0a6..3289d145ec 100644 --- a/roles/test-e2e-playwright/meta/services.yml +++ b/roles/test-e2e-playwright/meta/services.yml @@ -4,4 +4,4 @@ test-e2e-playwright: lifecycle: beta playwright: image: mcr.microsoft.com/playwright - version: "v1.64.0-noble" + version: "v1.64.1-noble" From d25f3c20e190691694194a2c4d2ed4640cb52101 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:54:48 +0000 Subject: [PATCH 15/27] update(images): update Docker image versions (web-app-baserow) --- roles/web-app-baserow/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-baserow/meta/services.yml b/roles/web-app-baserow/meta/services.yml index 410dc54444..cf64f91bb4 100644 --- a/roles/web-app-baserow/meta/services.yml +++ b/roles/web-app-baserow/meta/services.yml @@ -66,7 +66,7 @@ baserow: backup: no_stop_required: true image: baserow/baserow - version: 2.4.0 + version: 2.4.1 custom: true name: baserow min_storage: 785MB From 5000f248befb7d26093ccc0c58099de0cbbac420 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:54:53 +0000 Subject: [PATCH 16/27] update(images): update Docker image versions (web-app-espocrm) --- roles/web-app-espocrm/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-espocrm/meta/services.yml b/roles/web-app-espocrm/meta/services.yml index 59bbaf386e..fcde908d0c 100644 --- a/roles/web-app-espocrm/meta/services.yml +++ b/roles/web-app-espocrm/meta/services.yml @@ -37,7 +37,7 @@ espocrm: swarm: enabled: true image: espocrm/espocrm - version: "10.0.9" + version: "10.0.10" custom: true name: espocrm min_storage: 470MB From 752f1cf7dfdfcb51ee11f820357907f494a1edaf Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:54:59 +0000 Subject: [PATCH 17/27] update(images): update Docker image versions (web-app-matrix) --- roles/web-app-matrix/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-matrix/meta/services.yml b/roles/web-app-matrix/meta/services.yml index e8e59ab894..9148ba0361 100644 --- a/roles/web-app-matrix/meta/services.yml +++ b/roles/web-app-matrix/meta/services.yml @@ -43,7 +43,7 @@ postgres: synapse: healthcheck: flavor: curl - version: v1.162.0 + version: v1.163.0 image: matrixdotorg/synapse name: matrix-synapse backup: From 6158250a33ac00ea9a32ac8d4deb4ccbef2c40c1 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:55:16 +0000 Subject: [PATCH 18/27] update(images): update Docker image versions (web-app-opentalk) --- roles/web-app-opentalk/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-opentalk/meta/services.yml b/roles/web-app-opentalk/meta/services.yml index 4ceba7a5ba..8640838ba9 100644 --- a/roles/web-app-opentalk/meta/services.yml +++ b/roles/web-app-opentalk/meta/services.yml @@ -104,7 +104,7 @@ controller: livekit: name: opentalk-livekit image: livekit/livekit-server - version: v1.13.9 + version: v1.13.10 min_storage: 238MB cpus: "2.0" mem_reservation: 512m From abf9a32294ff0df38de74ba42a1f048f6d50f628 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:55:22 +0000 Subject: [PATCH 19/27] update(images): update Docker image versions (web-app-socialhome) --- roles/web-app-socialhome/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-socialhome/meta/services.yml b/roles/web-app-socialhome/meta/services.yml index d3ff755d73..109b854de9 100644 --- a/roles/web-app-socialhome/meta/services.yml +++ b/roles/web-app-socialhome/meta/services.yml @@ -13,7 +13,7 @@ socialhome: # nocheck: default-placement-manager embedded sqlite in a node-local volume; no clustered storage placement: manager image: ghcr.io/social-home-io/socialhome - version: "2026.10.11" + version: "2026.10.13" ports: local: http: 8089 From 2ee04cdd1ad9643a2954abd5f0ee95eb74378297 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:55:27 +0000 Subject: [PATCH 20/27] update(images): update Docker image versions (web-svc-logout) --- roles/web-svc-logout/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-svc-logout/meta/services.yml b/roles/web-svc-logout/meta/services.yml index 0c88d31868..474b4a831b 100644 --- a/roles/web-svc-logout/meta/services.yml +++ b/roles/web-svc-logout/meta/services.yml @@ -12,7 +12,7 @@ logout: enabled: true shared: true image: ghcr.io/kevinveenbirkenbach/universal-logout - version: v1.4.1 + version: v1.4.2 name: logout min_storage: 250MB cpus: 0.2 From 92946efaad0faf36bfa5f3921c439b3647582586 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:57:02 +0000 Subject: [PATCH 21/27] update(versions): update pins with a declared source (web-app-hugo) --- roles/web-app-hugo/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-hugo/meta/services.yml b/roles/web-app-hugo/meta/services.yml index f2b70dadc4..98f3b15f8d 100644 --- a/roles/web-app-hugo/meta/services.yml +++ b/roles/web-app-hugo/meta/services.yml @@ -35,7 +35,7 @@ hugo: version: 1.31-alpine custom: true builder_image: ghcr.io/gohugoio/hugo - builder_version: v0.167.0 + builder_version: v0.168.0 source_repository: https://github.com/gohugoio/hugoDocs.git source_version: v0.165.0 update: From 2b8a3b299e456d5e2e4c73d879dfcf2ae76d7eff Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:57:07 +0000 Subject: [PATCH 22/27] update(versions): update pins with a declared source (web-app-n8n) --- roles/web-app-n8n/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-n8n/meta/services.yml b/roles/web-app-n8n/meta/services.yml index d4e7d5e36b..46bb83d1b1 100644 --- a/roles/web-app-n8n/meta/services.yml +++ b/roles/web-app-n8n/meta/services.yml @@ -67,7 +67,7 @@ n8n: backup: no_stop_required: false image: docker.n8n.io/n8nio/n8n - version: "2.44.0" + version: "2.44.1" update: type: registry_tags image: docker.n8n.io/n8nio/n8n From 287ca5246587a32618f0b6551ec50eae2e4856e2 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 22:32:06 +0000 Subject: [PATCH 23/27] update(images): update Docker image versions (web-app-fediwall) --- roles/web-app-fediwall/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-fediwall/meta/services.yml b/roles/web-app-fediwall/meta/services.yml index 91af39c490..ed2eb8fb31 100644 --- a/roles/web-app-fediwall/meta/services.yml +++ b/roles/web-app-fediwall/meta/services.yml @@ -52,7 +52,7 @@ fediwall: swarm: enabled: true image: nginx - version: 1.31.6-alpine + version: 1.31.7-alpine custom: true upstream: version: "1.4.0" From 0a6c2458ee94bfc51b25c4ba5da0cdbd2a012547 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 22:32:11 +0000 Subject: [PATCH 24/27] update(images): update Docker image versions (web-app-littlejs) --- roles/web-app-littlejs/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-littlejs/meta/services.yml b/roles/web-app-littlejs/meta/services.yml index b1b6376874..f940fb8081 100644 --- a/roles/web-app-littlejs/meta/services.yml +++ b/roles/web-app-littlejs/meta/services.yml @@ -38,7 +38,7 @@ littlejs: repository: https://github.com/KilledByAPixel/LittleJS.git ref: main image: nginx - version: 1.31.6-alpine + version: 1.31.7-alpine custom: true ports: local: From 5b4cd6a9353bceaccff20a452e9b1013766ab30e Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 22:32:24 +0000 Subject: [PATCH 25/27] update(images): update Docker image versions (web-app-taiga) --- roles/web-app-taiga/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-taiga/meta/services.yml b/roles/web-app-taiga/meta/services.yml index 2a4a3b7f3e..4975dc4fad 100644 --- a/roles/web-app-taiga/meta/services.yml +++ b/roles/web-app-taiga/meta/services.yml @@ -92,7 +92,7 @@ gateway: internal: http: 80 image: nginx - version: 1.31.6-alpine + version: 1.31.7-alpine cpus: "0.3" mem_reservation: 256m mem_limit: 512m From 2a5b93a152eedd2e8f1bcd40302cd8ba6d63064f Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 22:32:28 +0000 Subject: [PATCH 26/27] update(images): update Docker image versions (web-svc-coturn) --- roles/web-svc-coturn/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-svc-coturn/meta/services.yml b/roles/web-svc-coturn/meta/services.yml index 26f1a9818f..6f10a65426 100644 --- a/roles/web-svc-coturn/meta/services.yml +++ b/roles/web-svc-coturn/meta/services.yml @@ -31,7 +31,7 @@ coturn: lifecycle: beta gateway: image: nginx - version: 1.31.6-alpine + version: 1.31.7-alpine cpus: "0.3" mem_reservation: 256m mem_limit: 512m From 829d555be65edb087aa5898f3643872a4f77d7c9 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 23:16:12 +0000 Subject: [PATCH 27/27] update(images): update Docker image versions (web-app-socialhome) --- roles/web-app-socialhome/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-socialhome/meta/services.yml b/roles/web-app-socialhome/meta/services.yml index 109b854de9..d7f917433f 100644 --- a/roles/web-app-socialhome/meta/services.yml +++ b/roles/web-app-socialhome/meta/services.yml @@ -13,7 +13,7 @@ socialhome: # nocheck: default-placement-manager embedded sqlite in a node-local volume; no clustered storage placement: manager image: ghcr.io/social-home-io/socialhome - version: "2026.10.13" + version: "2026.10.14" ports: local: http: 8089