From ac6bd94bc60d844635a9abd6573f7b2bd2a1cede Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2026 19:20:51 +0000 Subject: [PATCH 1/3] update(galaxy): bump pinned Ansible collections --- requirements/requirements.galaxy.yml | 4 ++-- requirements/requirements.git.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements/requirements.galaxy.yml b/requirements/requirements.galaxy.yml index 0a1db299fb..ef98c31538 100644 --- a/requirements/requirements.galaxy.yml +++ b/requirements/requirements.galaxy.yml @@ -7,10 +7,10 @@ collections: - name: kewlfft.aur version: 0.13.0 - name: community.general - version: 13.4.0 + version: 13.5.0 - name: community.docker version: 5.4.0 - name: community.library_inventory_filtering_v1 version: 1.1.5 - name: hetzner.hcloud - version: 7.1.0 + version: 7.2.0 diff --git a/requirements/requirements.git.yml b/requirements/requirements.git.yml index eef6cbd713..58808ee14c 100644 --- a/requirements/requirements.git.yml +++ b/requirements/requirements.git.yml @@ -18,7 +18,7 @@ collections: - name: community.general source: https://github.com/ansible-collections/community.general.git type: git - version: 13.4.0 + version: 13.5.0 - name: community.docker source: https://github.com/ansible-collections/community.docker.git @@ -33,4 +33,4 @@ collections: - name: hetzner.hcloud source: https://github.com/ansible-collections/hetzner.hcloud.git type: git - version: 7.1.0 + version: 7.2.0 From 7968b47cf0570a2289b094d6c027e78fbb0077c3 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 6 Oct 2026 11:02:31 +0200 Subject: [PATCH 2/3] fix(svc-net-tor): give every chutney node one worker thread Tor starts its worker threads by the number of CPU cores it detects, and the cpus limit of the container does not change that number. On a host with 20 cores every node of the private chutney network ran 21 threads and grew to about 0.6 GB. The seven relays and authorities filled the 2g limit and its swap within ten minutes, the kernel killed them one by one, and no circuit could be built any more. The entrypoint now writes NumCPUs 1 into the torrc of every chutney node before it starts the network. Measured on that host over ten minutes: the nodes run 3 threads and stay at 65 to 86 MB, the container at 0.47 GB without swap, where it had filled 2 GB plus 2 GB of swap before. The CLI test of the role fails when a chutney node runs without the limit. Closes #824 Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/svc-net-tor/files/shell/entrypoint.sh | 3 +++ roles/svc-net-tor/files/test/test.sh | 16 ++++++++++++++++ roles/svc-net-tor/templates/test.env.j2 | 2 ++ .../roles/svc-net-tor/test_test_env_sourcing.py | 3 +++ 4 files changed, 24 insertions(+) diff --git a/roles/svc-net-tor/files/shell/entrypoint.sh b/roles/svc-net-tor/files/shell/entrypoint.sh index ccf615aad1..27fe61bc7d 100644 --- a/roles/svc-net-tor/files/shell/entrypoint.sh +++ b/roles/svc-net-tor/files/shell/entrypoint.sh @@ -21,6 +21,9 @@ if [ "${TOR_FLAVOR}" = "chutney" ]; then CHUTNEY_LISTEN_ADDRESS=127.0.0.1 \ ./chutney init --net "${net}" ./chutney configure + for torrc in net/nodes/*/torrc; do + echo "NumCPUs 1" >>"${torrc}" + done ./chutney start ./chutney wait_for_bootstrap diff --git a/roles/svc-net-tor/files/test/test.sh b/roles/svc-net-tor/files/test/test.sh index 68677e034b..07a74906f8 100755 --- a/roles/svc-net-tor/files/test/test.sh +++ b/roles/svc-net-tor/files/test/test.sh @@ -18,6 +18,8 @@ # SLEEP_SECONDS wait between attempts # TOR_DNSMASQ_CONF the dnsmasq drop-in path; its directory is scanned for # upstreams when a probe fails +# TOR_CONTAINER address of the tor container +# TOR_FLAVOR public or chutney set -uo pipefail @@ -26,6 +28,8 @@ NGINX_SERVERS_DIR="${NGINX_SERVERS_DIR:?pass NGINX_SERVERS_DIR as env (the deplo RETRIES="${RETRIES:?pass RETRIES as env (attempts per domain, from svc-net-tor test.env)}" SLEEP_SECONDS="${SLEEP_SECONDS:?pass SLEEP_SECONDS as env (wait between attempts, from svc-net-tor test.env)}" TOR_DNSMASQ_CONF="${TOR_DNSMASQ_CONF:?pass TOR_DNSMASQ_CONF as env (the dnsmasq drop-in path, from svc-net-tor vars)}" +TOR_CONTAINER="${TOR_CONTAINER:?pass TOR_CONTAINER as env (address of the tor container, from svc-net-tor test.env)}" +TOR_FLAVOR="${TOR_FLAVOR:?pass TOR_FLAVOR as env (public or chutney, from svc-net-tor test.env)}" discover_domains() { find "${NGINX_SERVERS_DIR}/http" "${NGINX_SERVERS_DIR}/https" \ @@ -102,4 +106,16 @@ echo "[INFO] ${#domains[@]} probed, ${failed} failed" "$(dirname "${BASH_SOURCE[0]}")/onion_ports.py" || failed=$((failed + 1)) +if [[ "${TOR_FLAVOR}" == "chutney" ]]; then + if ! unbounded="$(container exec "${TOR_CONTAINER}" sh -c 'grep -L "^NumCPUs 1$" /opt/chutney/net/nodes/*/torrc; true')"; then + echo "[FAIL] cannot read the chutney node torrcs in ${TOR_CONTAINER}" + failed=$((failed + 1)) + elif [[ -n "${unbounded}" ]]; then + echo "[FAIL] chutney nodes without NumCPUs 1 start one worker per host core: ${unbounded//$'\n'/ }" + failed=$((failed + 1)) + else + echo "[OK] every chutney node runs one worker" + fi +fi + [[ "${failed}" -eq 0 ]] diff --git a/roles/svc-net-tor/templates/test.env.j2 b/roles/svc-net-tor/templates/test.env.j2 index 6e0bec9054..51288356b2 100644 --- a/roles/svc-net-tor/templates/test.env.j2 +++ b/roles/svc-net-tor/templates/test.env.j2 @@ -5,5 +5,7 @@ ONION_PORT_RETRIES=2 ONION_PORT_TIMEOUT=60 RETRIES=5 SLEEP_SECONDS=10 +TOR_CONTAINER={{ lookup('container_address', application_id, 'tor') }} TOR_DNSMASQ_CONF={{ TOR_DNSMASQ_CONF }} +TOR_FLAVOR={{ TOR_FLAVOR }} TOR_SOCKS={{ lookup('tor_socks') }} diff --git a/tests/unit/python/roles/svc-net-tor/test_test_env_sourcing.py b/tests/unit/python/roles/svc-net-tor/test_test_env_sourcing.py index e0a3f8ed8c..ddb45113bd 100644 --- a/tests/unit/python/roles/svc-net-tor/test_test_env_sourcing.py +++ b/tests/unit/python/roles/svc-net-tor/test_test_env_sourcing.py @@ -26,6 +26,7 @@ PORTS = [25, 80, 587] def _lookup(name: str, *_args: str) -> object: return { "config": "example.onion", + "container_address": "tor", "nginx": "/etc/nginx/conf.d/servers", "tor_ports": [ {"onion_port": port, "target": f"127.0.0.1:{port}"} for port in PORTS @@ -42,8 +43,10 @@ def _render(mode: str) -> str: env.filters.update(FilterModule().filters()) return env.from_string(read_text(str(TEMPLATE))).render( lookup=_lookup, + application_id="svc-net-tor", DEPLOYMENT_MODE=mode, TOR_DNSMASQ_CONF="/etc/dnsmasq.d/tor-onion.conf", + TOR_FLAVOR="chutney", ) From 4f8c1f00f1de3ac359ac828f489ff7fbf3678cbe Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 6 Oct 2026 13:47:17 +0200 Subject: [PATCH 3/3] fix(svc-net-tor): fail the worker check when no torrc can be read The check listed the torrcs without the limit through "grep -L ...; true". With no torrc under /opt/chutney/net/nodes, or with one that cannot be read, grep printed nothing, the trailing true turned its error into success, and the test reported that every node runs one worker. The check now counts the limit per file with "grep -cH" and reads the exit status. A status above 1 or an empty answer fails the test, and a file with a count of 0 is named as before. Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/svc-net-tor/files/test/test.sh | 5 +- .../svc-net-tor/test_chutney_worker_check.py | 107 ++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 tests/unit/python/roles/svc-net-tor/test_chutney_worker_check.py diff --git a/roles/svc-net-tor/files/test/test.sh b/roles/svc-net-tor/files/test/test.sh index 07a74906f8..f3a8989df7 100755 --- a/roles/svc-net-tor/files/test/test.sh +++ b/roles/svc-net-tor/files/test/test.sh @@ -107,7 +107,10 @@ echo "[INFO] ${#domains[@]} probed, ${failed} failed" "$(dirname "${BASH_SOURCE[0]}")/onion_ports.py" || failed=$((failed + 1)) if [[ "${TOR_FLAVOR}" == "chutney" ]]; then - if ! unbounded="$(container exec "${TOR_CONTAINER}" sh -c 'grep -L "^NumCPUs 1$" /opt/chutney/net/nodes/*/torrc; true')"; then + status=0 + workers="$(container exec "${TOR_CONTAINER}" sh -c 'grep -cH "^NumCPUs 1$" /opt/chutney/net/nodes/*/torrc')" || status=$? + unbounded="$(sed -n 's/:0$//p' <<<"${workers}")" + if [[ "${status}" -gt 1 || -z "${workers}" ]]; then echo "[FAIL] cannot read the chutney node torrcs in ${TOR_CONTAINER}" failed=$((failed + 1)) elif [[ -n "${unbounded}" ]]; then diff --git a/tests/unit/python/roles/svc-net-tor/test_chutney_worker_check.py b/tests/unit/python/roles/svc-net-tor/test_chutney_worker_check.py new file mode 100644 index 0000000000..b520ffe58e --- /dev/null +++ b/tests/unit/python/roles/svc-net-tor/test_chutney_worker_check.py @@ -0,0 +1,107 @@ +from __future__ import annotations + +import os +import shutil +import subprocess +import tempfile +import unittest +from pathlib import Path + +from . import PROJECT_ROOT + +TEST_SH = PROJECT_ROOT / "roles" / "svc-net-tor" / "files" / "test" / "test.sh" +BOUNDED = "DataDirectory /data\nNumCPUs 1\n" +UNBOUNDED = "DataDirectory /data\n" +CONTAINER_STUB = """\ +in_container=/opt/chutney/net/nodes +exec sh -c "${5//"${in_container}"/"${NODES_DIR}"}" +""" + + +def _stub(path: Path, body: str) -> None: + path.write_text(f"#!/usr/bin/env bash\n{body}\n", encoding="utf-8") + path.chmod(0o755) + + +def _run( + torrcs: dict[str, str], flavor: str = "chutney", unreadable: str = "" +) -> subprocess.CompletedProcess[str]: + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) + nodes = root / "nodes" + nodes.mkdir() + for node, torrc in torrcs.items(): + (nodes / node).mkdir() + (nodes / node / "torrc").write_text(torrc, encoding="utf-8") + if unreadable: + (nodes / unreadable / "torrc").mkdir(parents=True) + shutil.copy(TEST_SH, root / "test.sh") + _stub(root / "onion_ports.py", "exit 0") + bin_dir = root / "bin" + bin_dir.mkdir() + _stub(bin_dir / "curl", "printf 200") + _stub(bin_dir / "container", CONTAINER_STUB) + return subprocess.run( + ["bash", str(root / "test.sh"), "example.onion"], + env={ + "PATH": f"{bin_dir}{os.pathsep}{os.environ['PATH']}", + "NODES_DIR": str(nodes), + "TOR_SOCKS": "127.0.0.1:9050", + "NGINX_SERVERS_DIR": str(root), + "RETRIES": "1", + "SLEEP_SECONDS": "0", + "TOR_DNSMASQ_CONF": str(root / "tor-onion.conf"), + "TOR_CONTAINER": "tor", + "TOR_FLAVOR": flavor, + }, + capture_output=True, + text=True, + check=False, + ) + + +def _verdict(result: subprocess.CompletedProcess[str]) -> str: + return result.stdout.splitlines()[-1] + + +class TestChutneyWorkerCheck(unittest.TestCase): + def test_nodes_that_all_carry_the_limit_pass(self) -> None: + result = _run({"000a": BOUNDED, "001a": BOUNDED}) + self.assertEqual(_verdict(result), "[OK] every chutney node runs one worker") + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + + def test_a_node_without_the_limit_is_named_and_fails(self) -> None: + result = _run({"000a": BOUNDED, "001a": UNBOUNDED}) + self.assertIn("start one worker per host core", _verdict(result)) + self.assertTrue(_verdict(result).endswith("/001a/torrc"), _verdict(result)) + self.assertNotIn("000a", _verdict(result)) + self.assertEqual(result.returncode, 1) + + def test_nodes_that_all_lack_the_limit_fail(self) -> None: + result = _run({"000a": UNBOUNDED, "001a": UNBOUNDED}) + self.assertIn("/000a/torrc", _verdict(result)) + self.assertIn("/001a/torrc", _verdict(result)) + self.assertEqual(result.returncode, 1) + + def test_no_torrc_to_inspect_fails(self) -> None: + result = _run({}) + self.assertEqual( + _verdict(result), "[FAIL] cannot read the chutney node torrcs in tor" + ) + self.assertEqual(result.returncode, 1) + + def test_a_torrc_that_cannot_be_read_fails_beside_bounded_nodes(self) -> None: + result = _run({"000a": BOUNDED}, unreadable="001a") + self.assertEqual( + _verdict(result), "[FAIL] cannot read the chutney node torrcs in tor" + ) + self.assertEqual(result.returncode, 1) + + def test_the_public_flavor_does_not_run_the_check(self) -> None: + result = _run({}, flavor="public") + self.assertEqual(_verdict(result), "[INFO] 1 probed, 0 failed") + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + + +if __name__ == "__main__": + unittest.main()