From 5a36921f3bbec55794fe02f80a87d9147d569828 Mon Sep 17 00:00:00 2001 From: hermes Date: Mon, 14 Sep 2026 09:39:13 +0000 Subject: [PATCH 01/27] feat(connectivity_tester): new stack for synthetic connectivity checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Long-running Swarm service that verifies expected endpoints are reachable from inside the cluster and that the negative-list endpoints (cloud metadata etc.) stay blocked. Runs one round every PERIOD_SECONDS (default 600): TCP probes against EXPECTED_INTERNAL (overlay services), EXPECTED_EXTERNAL (internet hosts), EXTRA_ENDPOINTS (ad-hoc from env), and NEGATIVE (must NOT respond; alerts on any leak). Logs structured output, alerts on failures, container keeps running. Mode: global — Swarm schedules one task on every node that meets constraints. Attached to hermes_proxy overlay (for internal DNS) and default (for egress via squid). Blocks Org1/hermes-voice-gateway#3 (Path B) until we verify the overlay + egress paths voice-gateway will depend on. --- connectivity_tester/Dockerfile | 10 +++ connectivity_tester/app.py | 120 ++++++++++++++++++++++++++ connectivity_tester/endpoints.py | 43 +++++++++ connectivity_tester/stack-compose.yml | 44 ++++++++++ 4 files changed, 217 insertions(+) create mode 100644 connectivity_tester/Dockerfile create mode 100644 connectivity_tester/app.py create mode 100644 connectivity_tester/endpoints.py create mode 100644 connectivity_tester/stack-compose.yml diff --git a/connectivity_tester/Dockerfile b/connectivity_tester/Dockerfile new file mode 100644 index 0000000..5d52445 --- /dev/null +++ b/connectivity_tester/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.12-slim + +WORKDIR /app +COPY connectivity_tester/ /app/ + +ENV PYTHONUNBUFFERED=1 \ + PERIOD_SECONDS=600 \ + CHECK_TIMEOUT_S=3 + +CMD ["python", "-m", "app"] diff --git a/connectivity_tester/app.py b/connectivity_tester/app.py new file mode 100644 index 0000000..8795a83 --- /dev/null +++ b/connectivity_tester/app.py @@ -0,0 +1,120 @@ +"""Connectivity tester: verifies internal/external endpoints are reachable +and negative-list endpoints are not. Logs structured output, alerts on +unexpected failures. + +ENV: + EXTRA_ENDPOINTS - comma-separated host:port pairs, ad-hoc checks + PERIOD_SECONDS - sleep between full check rounds (default 600) + CHECK_TIMEOUT_S - per-endpoint timeout in seconds (default 3) +""" +from __future__ import annotations + +import asyncio +import logging +import os +import socket +import sys +import time +from typing import Iterable, List, Tuple + +from endpoints import EXPECTED_EXTERNAL, EXPECTED_INTERNAL, NEGATIVE, Endpoint + +LOG = logging.getLogger("connectivity-tester") + + +def _parse_extra(raw: str) -> List[Endpoint]: + out: List[Endpoint] = [] + for token in raw.split(","): + token = token.strip() + if not token: + continue + if ":" not in token: + continue + host, port_s = token.rsplit(":", 1) + try: + port = int(port_s) + except ValueError: + continue + out.append((host, port, "extra")) + return out + + +async def _tcp_check(host: str, port: int, timeout: float) -> Tuple[bool, str]: + try: + fut = asyncio.open_connection(host, port) + reader, writer = await asyncio.wait_for(fut, timeout=timeout) + writer.close() + try: + await writer.wait_closed() + except Exception: + pass + return True, "tcp ok" + except asyncio.TimeoutError: + return False, "timeout" + except OSError as exc: + return False, f"{type(exc).__name__}: {exc}" + + +async def _check_positive(endpoints: Iterable[Endpoint], timeout: float) -> int: + failures = 0 + for host, port, label in endpoints: + ok, detail = await _tcp_check(host, port, timeout) + if ok: + LOG.info("PASS %s:%d (%s) %s", host, port, label, detail) + else: + LOG.error("FAIL %s:%d (%s) %s", host, port, label, detail) + failures += 1 + return failures + + +async def _check_negative(endpoints: Iterable[Endpoint], timeout: float) -> int: + leaks = 0 + for host, port, label in endpoints: + ok, detail = await _tcp_check(host, port, timeout) + if ok: + LOG.error( + "LEAK %s:%d (%s) reachable but must NOT be: %s", + host, port, label, detail, + ) + leaks += 1 + else: + LOG.info("OK-NEG %s:%d (%s) blocked: %s", host, port, label, detail) + return leaks + + +async def _round(timeout: float) -> int: + extras = _parse_extra(os.environ.get("EXTRA_ENDPOINTS", "")) + LOG.info("--- round begin, %d internal + %d external + %d extra + %d negative ---", + len(EXPECTED_INTERNAL), len(EXPECTED_EXTERNAL), len(extras), len(NEGATIVE)) + failures = 0 + failures += await _check_positive(EXPECTED_INTERNAL, timeout) + failures += await _check_positive(EXPECTED_EXTERNAL, timeout) + failures += await _check_positive(extras, timeout) + leaks = await _check_negative(NEGATIVE, timeout) + failures += leaks + LOG.info("--- round end, %d failure(s) ---", failures) + return failures + + +async def main() -> int: + logging.basicConfig( + level=logging.INFO, + format="%(asctime)s %(levelname)s %(message)s", + stream=sys.stdout, + ) + period = int(os.environ.get("PERIOD_SECONDS", "600")) + timeout = float(os.environ.get("CHECK_TIMEOUT_S", "3")) + LOG.info("starting; period=%ds, check_timeout=%.1fs", period, timeout) + while True: + started = time.monotonic() + try: + await _round(timeout) + except Exception: + LOG.exception("round crashed") + elapsed = time.monotonic() - started + sleep_for = max(0.0, period - elapsed) + await asyncio.sleep(sleep_for) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/connectivity_tester/endpoints.py b/connectivity_tester/endpoints.py new file mode 100644 index 0000000..66e7300 --- /dev/null +++ b/connectivity_tester/endpoints.py @@ -0,0 +1,43 @@ +"""Endpoint allow-list and negative-list for connectivity-tester. + +EXPECTED_INTERNAL: TCP services in overlay networks that MUST be reachable. +EXPECTED_EXTERNAL: external hosts that MUST be reachable via squid egress. +NEGATIVE: hosts that MUST NOT respond (proxy / firewall sanity check). + +Each entry is (host, port, label). +""" +from __future__ import annotations + +from typing import List, Tuple + +Endpoint = Tuple[str, int, str] + + +EXPECTED_INTERNAL: List[Endpoint] = [ + ("squid", 3128, "egress proxy"), + ("hermes-gateway", 8000, "hermes messaging gateway"), + ("hermes-ui", 8087, "hermes dashboard ui"), + ("docker_socket_proxy", 2375, "read-only docker socket proxy"), + ("brencher-state-proxy", 80, "brencher state reverse proxy"), + ("gitea-server", 3000, "gitea http"), + ("act_runner", 8088, "gitea actions runner"), + ("telegram-mcp-server", 8000, "telegram mcp"), + ("gmail-mcp-server", 8000, "gmail mcp"), + ("voice-gateway", 8765, "voice realtime ws bridge"), + ("hermes-proxy", 8645, "openai-compatible http egress"), +] + + +EXPECTED_EXTERNAL: List[Endpoint] = [ + ("huggingface.co", 443, "piper voice model download"), + ("registry.rudolf.keenetic.link", 5000, "local docker registry"), + ("gitea.rudolf.keenetic.link", 443, "public gitea"), + ("pypi.org", 443, "python package index"), + ("github.com", 443, "github api"), +] + + +NEGATIVE: List[Endpoint] = [ + ("169.254.169.254", 80, "cloud metadata service"), + ("metadata.google.internal", 80, "gcp metadata"), +] diff --git a/connectivity_tester/stack-compose.yml b/connectivity_tester/stack-compose.yml new file mode 100644 index 0000000..70dce8d --- /dev/null +++ b/connectivity_tester/stack-compose.yml @@ -0,0 +1,44 @@ +name: connectivity_tester + +services: + connectivity-tester: + build: + context: . + dockerfile: connectivity_tester/Dockerfile + image: registry.rudolf.keenetic.link/connectivity_tester:${version} + hostname: connectivity-tester + user: "0:0" + networks: + - hermes_proxy + - default + environment: + PERIOD_SECONDS: "600" + CHECK_TIMEOUT_S: "3" + EXTRA_ENDPOINTS: "${EXTRA_ENDPOINTS:-}" + HTTP_PROXY: "http://squid:3128" + HTTPS_PROXY: "http://squid:3128" + NO_PROXY: "localhost,127.0.0.1,.local,squid,hermes-gateway,hermes-agent,hermes-proxy,brencher-state-proxy,docker_socket_proxy,10.0.0.0/8" + healthcheck: + test: ["CMD-SHELL", "python -c \"import socket; s=socket.socket(); s.settimeout(2); s.connect(('squid', 3128)); s.close()\""] + interval: 60s + timeout: 5s + retries: 3 + start_period: 30s + deploy: + mode: global + resources: + limits: + memory: 128M + pids: 64 + reservations: + memory: 64M + restart_policy: + condition: on-failure + delay: 10s + max_attempts: 3 + +networks: + hermes_proxy: + external: true + default: + external: true -- 2.54.0 From 020a5092a0d4842f67fa44e887bc905b4b91c816 Mon Sep 17 00:00:00 2001 From: hermes Date: Mon, 14 Sep 2026 19:26:54 +0000 Subject: [PATCH 02/27] fix(compose): drop shell default syntax from EXTRA_ENDPOINTS brencher parses compose via re.sub(r'\$\{([^}]+)\}', lambda m: env[m.group(1)]). With shell default syntax ${VAR:-default} the regex captures 'VAR:-default' as a single key, env['VAR:-default'] raises KeyError. Use bare ${EXTRA_ENDPOINTS}; if the env var is missing brencher's .env lookup (or the dict.get fallback in the deploy step) handles it. If EXTRA_ENDPOINTS isn't set at deploy time the value is empty, which the python service treats as 'no extras'. --- connectivity_tester/stack-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity_tester/stack-compose.yml b/connectivity_tester/stack-compose.yml index 70dce8d..c25c473 100644 --- a/connectivity_tester/stack-compose.yml +++ b/connectivity_tester/stack-compose.yml @@ -14,7 +14,7 @@ services: environment: PERIOD_SECONDS: "600" CHECK_TIMEOUT_S: "3" - EXTRA_ENDPOINTS: "${EXTRA_ENDPOINTS:-}" + EXTRA_ENDPOINTS: "${EXTRA_ENDPOINTS}" HTTP_PROXY: "http://squid:3128" HTTPS_PROXY: "http://squid:3128" NO_PROXY: "localhost,127.0.0.1,.local,squid,hermes-gateway,hermes-agent,hermes-proxy,brencher-state-proxy,docker_socket_proxy,10.0.0.0/8" -- 2.54.0 From c13e9d2ce7ceae86ea7d490a798224662ffd451f Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Tue, 15 Sep 2026 05:04:07 +0000 Subject: [PATCH 03/27] fix(connectivity_tester): define EXTRA_ENDPOINTS empty + add external hosts brencher DockerComposeBuild raises KeyError: 'EXTRA_ENDPOINTS' when the env var is not passed via envs=. Hardcode empty default in compose for deterministic build. Add google.com and lan gateways to EXPECTED_EXTERNAL so connectivity-tester probes them on every round. --- connectivity_tester/endpoints.py | 3 +++ connectivity_tester/stack-compose.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/connectivity_tester/endpoints.py b/connectivity_tester/endpoints.py index 66e7300..e6f63ae 100644 --- a/connectivity_tester/endpoints.py +++ b/connectivity_tester/endpoints.py @@ -34,6 +34,9 @@ EXPECTED_EXTERNAL: List[Endpoint] = [ ("gitea.rudolf.keenetic.link", 443, "public gitea"), ("pypi.org", 443, "python package index"), ("github.com", 443, "github api"), + ("google.com", 443, "egress sanity check"), + ("192.168.1.1", 80, "lan gateway .1"), + ("192.168.0.1", 80, "lan gateway .0"), ] diff --git a/connectivity_tester/stack-compose.yml b/connectivity_tester/stack-compose.yml index c25c473..2e7417a 100644 --- a/connectivity_tester/stack-compose.yml +++ b/connectivity_tester/stack-compose.yml @@ -14,7 +14,7 @@ services: environment: PERIOD_SECONDS: "600" CHECK_TIMEOUT_S: "3" - EXTRA_ENDPOINTS: "${EXTRA_ENDPOINTS}" + EXTRA_ENDPOINTS: "" HTTP_PROXY: "http://squid:3128" HTTPS_PROXY: "http://squid:3128" NO_PROXY: "localhost,127.0.0.1,.local,squid,hermes-gateway,hermes-agent,hermes-proxy,brencher-state-proxy,docker_socket_proxy,10.0.0.0/8" -- 2.54.0 From 0366a78a96b282fcbf7dd890a6b0a307aa9a73dd Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Tue, 15 Sep 2026 07:39:43 +0000 Subject: [PATCH 04/27] fix(connectivity_tester): use Dockerfile (single-level) in stack build Previous 'dockerfile: connectivity_tester/Dockerfile' resolved through brencher's join to /connectivity_tester/connectivity_tester/Dockerfile, which does not exist; build failed with 'Cannot locate specified Dockerfile'. The Dockerfile sits next to stack-compose.yml at /connectivity_tester/Dockerfile. --- connectivity_tester/stack-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity_tester/stack-compose.yml b/connectivity_tester/stack-compose.yml index 2e7417a..960068d 100644 --- a/connectivity_tester/stack-compose.yml +++ b/connectivity_tester/stack-compose.yml @@ -4,7 +4,7 @@ services: connectivity-tester: build: context: . - dockerfile: connectivity_tester/Dockerfile + dockerfile: Dockerfile image: registry.rudolf.keenetic.link/connectivity_tester:${version} hostname: connectivity-tester user: "0:0" -- 2.54.0 From c0d53b709c71b0b43cbc3b54f4a368a00cf116ad Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Tue, 15 Sep 2026 07:59:06 +0000 Subject: [PATCH 05/27] fix(connectivity_tester): COPY . instead of connectivity_tester/ After brencher fix uses context=/connectivity_tester/ (single-level now that compose 'dockerfile' is 'Dockerfile'), the previous COPY line referenced a non-existent connectivity_tester/ subdirectory inside the build context. --- connectivity_tester/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity_tester/Dockerfile b/connectivity_tester/Dockerfile index 5d52445..85943a9 100644 --- a/connectivity_tester/Dockerfile +++ b/connectivity_tester/Dockerfile @@ -1,7 +1,7 @@ FROM python:3.12-slim WORKDIR /app -COPY connectivity_tester/ /app/ +COPY . /app/ ENV PYTHONUNBUFFERED=1 \ PERIOD_SECONDS=600 \ -- 2.54.0 From e94ea37e858d5565329d8939a2296ece45ca0279 Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Tue, 15 Sep 2026 08:19:19 +0000 Subject: [PATCH 06/27] fix(connectivity_tester): drop root name: key from compose docker stack deploy on this engine rejects 'Additional property name is not allowed'. Sibling stacks (gitea, hermes, immich) ship without it; the stack name comes from the brencher 'stack_name' CLI argument instead. --- connectivity_tester/stack-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/connectivity_tester/stack-compose.yml b/connectivity_tester/stack-compose.yml index 960068d..e654336 100644 --- a/connectivity_tester/stack-compose.yml +++ b/connectivity_tester/stack-compose.yml @@ -1,5 +1,3 @@ -name: connectivity_tester - services: connectivity-tester: build: -- 2.54.0 From d5b1a23bcbcd455643b7b1acc4aea78ed4803eb5 Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Tue, 15 Sep 2026 09:23:55 +0000 Subject: [PATCH 07/27] feat(connectivity_tester): rotate networks per-round, cross-validate map Self-attach/detach to overlay networks via docker socket. At any moment the container is on exactly one network; per-network list of expected services is loaded from network_map.NETWORK_MAP. After checks run cross-validation: - service reachable but not in map -> ERROR 'LEAK-UNEXPECTED' - service in map but unreachable -> ERROR 'MISSING-EXPECTED' - global service not in any map -> WARNING 'GLOBAL-UNCOVERED' Compose uses /var/run/docker.sock bind mount and removes overlay-network references; EXTRA_ENDPOINTS / HTTP_PROXY / HTTPS_PROXY / NO_PROXY are gone. endpoints.py removed (its data moved into network_map.py). --- connectivity_tester/Dockerfile | 2 + connectivity_tester/app.py | 217 +++++++++++++++++++------- connectivity_tester/endpoints.py | 46 ------ connectivity_tester/network_map.py | 40 +++++ connectivity_tester/stack-compose.yml | 20 +-- 5 files changed, 204 insertions(+), 121 deletions(-) delete mode 100644 connectivity_tester/endpoints.py create mode 100644 connectivity_tester/network_map.py diff --git a/connectivity_tester/Dockerfile b/connectivity_tester/Dockerfile index 85943a9..65dc943 100644 --- a/connectivity_tester/Dockerfile +++ b/connectivity_tester/Dockerfile @@ -3,6 +3,8 @@ FROM python:3.12-slim WORKDIR /app COPY . /app/ +RUN pip install --no-cache-dir docker==7.1.0 + ENV PYTHONUNBUFFERED=1 \ PERIOD_SECONDS=600 \ CHECK_TIMEOUT_S=3 diff --git a/connectivity_tester/app.py b/connectivity_tester/app.py index 8795a83..79e213e 100644 --- a/connectivity_tester/app.py +++ b/connectivity_tester/app.py @@ -1,11 +1,10 @@ -"""Connectivity tester: verifies internal/external endpoints are reachable -and negative-list endpoints are not. Logs structured output, alerts on -unexpected failures. +"""Connectivity tester. -ENV: - EXTRA_ENDPOINTS - comma-separated host:port pairs, ad-hoc checks - PERIOD_SECONDS - sleep between full check rounds (default 600) - CHECK_TIMEOUT_S - per-endpoint timeout in seconds (default 3) +For every network in network_map.NETWORK_MAP the container attaches itself, +runs TCP checks against the listed services, detaches, and proceeds to the +next network. Cross-validates GLOBAL_SERVICES against each network map: logs +errors when reachable services are absent from the map or when expected +services are unreachable. """ from __future__ import annotations @@ -15,30 +14,86 @@ import os import socket import sys import time -from typing import Iterable, List, Tuple +from typing import Iterable, List, Set, Tuple -from endpoints import EXPECTED_EXTERNAL, EXPECTED_INTERNAL, NEGATIVE, Endpoint +import docker +from docker.models.containers import Container +from docker.models.networks import Network + +from network_map import GLOBAL_SERVICES, NETWORK_MAP, Service LOG = logging.getLogger("connectivity-tester") -def _parse_extra(raw: str) -> List[Endpoint]: - out: List[Endpoint] = [] - for token in raw.split(","): - token = token.strip() - if not token: +def _socket_path() -> str: + return os.environ.get("DOCKER_SOCKET", "/var/run/docker.sock") + + +def _self_container(client: docker.DockerClient) -> Container: + hostname = socket.gethostname() + for c in client.containers.list(): + if (c.attrs.get("Config", {}).get("Hostname") == hostname + or c.name.lstrip("/") == hostname): + return c + candidates = [c for c in client.containers.list() + if hostname[:12] in c.id] + if len(candidates) == 1: + return candidates[0] + raise RuntimeError(f"self container not found for hostname={hostname}") + + +def _filtered_networks(client: docker.DockerClient) -> List[Network]: + keep_prefixes = ( + "hermes_infra_", "gitea_", "gmail_mcp_", "telegram_", + "hermes_", "brencher", "registry_", "immich_", + "torrserv_proxy_", "photosHelper_", "nginx_", + "docker_socket_proxy_", + ) + out = [] + for n in client.networks.list(): + if n.attrs.get("Scope") != "swarm": continue - if ":" not in token: + name = n.name + if name in ("ingress",): continue - host, port_s = token.rsplit(":", 1) - try: - port = int(port_s) - except ValueError: - continue - out.append((host, port, "extra")) + if any(name.startswith(p) for p in keep_prefixes): + out.append(n) return out +def _build_map_from_running(networks: Iterable[Network]) -> dict: + """Reverse-engineer NAME -> swarm network name from running container endpoints.""" + out = {} + for net in networks: + endpoint_count = len(net.attrs.get("Containers") or {}) + out[net.name] = {"endpoints": endpoint_count, "id": net.id} + return out + + +def _attach(client: docker.DockerClient, container: Container, + network: Network) -> None: + if network.name in (container.attrs.get("NetworkSettings", {}) + .get("Networks", {}).keys()): + return + try: + network.connect(container, aliases=["connectivity-tester", + socket.gethostname()]) + except Exception as exc: + if "already exists" in str(exc).lower(): + return + raise + + +def _detach(client: docker.DockerClient, container: Container, + network: Network) -> None: + try: + network.disconnect(container, force=True) + except Exception as exc: + if "not found" in str(exc).lower(): + return + raise + + async def _tcp_check(host: str, port: int, timeout: float) -> Tuple[bool, str]: try: fut = asyncio.open_connection(host, port) @@ -55,45 +110,60 @@ async def _tcp_check(host: str, port: int, timeout: float) -> Tuple[bool, str]: return False, f"{type(exc).__name__}: {exc}" -async def _check_positive(endpoints: Iterable[Endpoint], timeout: float) -> int: - failures = 0 - for host, port, label in endpoints: - ok, detail = await _tcp_check(host, port, timeout) - if ok: - LOG.info("PASS %s:%d (%s) %s", host, port, label, detail) - else: - LOG.error("FAIL %s:%d (%s) %s", host, port, label, detail) - failures += 1 - return failures +async def _check_one(host: str, port: int, label: str, + timeout: float) -> bool: + ok, detail = await _tcp_check(host, port, timeout) + if ok: + LOG.info("PASS %s:%d (%s) %s", host, port, label, detail) + else: + LOG.error("FAIL %s:%d (%s) %s", host, port, label, detail) + return ok -async def _check_negative(endpoints: Iterable[Endpoint], timeout: float) -> int: - leaks = 0 - for host, port, label in endpoints: - ok, detail = await _tcp_check(host, port, timeout) - if ok: - LOG.error( - "LEAK %s:%d (%s) reachable but must NOT be: %s", - host, port, label, detail, - ) - leaks += 1 - else: - LOG.info("OK-NEG %s:%d (%s) blocked: %s", host, port, label, detail) - return leaks +async def _check_network(network: Network, services: List[Service], + timeout: float) -> Tuple[Set[Service], Set[Service]]: + reachable: Set[Service] = set() + unreachable: Set[Service] = set() + for host, port in services: + ok = await _check_one(host, port, network.name, timeout) + (reachable if ok else unreachable).add((host, port)) + return reachable, unreachable -async def _round(timeout: float) -> int: - extras = _parse_extra(os.environ.get("EXTRA_ENDPOINTS", "")) - LOG.info("--- round begin, %d internal + %d external + %d extra + %d negative ---", - len(EXPECTED_INTERNAL), len(EXPECTED_EXTERNAL), len(extras), len(NEGATIVE)) - failures = 0 - failures += await _check_positive(EXPECTED_INTERNAL, timeout) - failures += await _check_positive(EXPECTED_EXTERNAL, timeout) - failures += await _check_positive(extras, timeout) - leaks = await _check_negative(NEGATIVE, timeout) - failures += leaks - LOG.info("--- round end, %d failure(s) ---", failures) - return failures +def _discover_attached(client: docker.DockerClient, + container: Container) -> Set[str]: + return set((container.attrs.get("NetworkSettings", {}) or {}) + .get("Networks", {}).keys()) + + +def _cross_validate(network_name: str, + mapped: List[Service], + reachable: Set[Service], + unreachable: Set[Service], + all_global: List[Service]) -> None: + mapped_set = set(mapped) + reachable_global = reachable & set(all_global) + for svc in reachable_global - mapped_set: + LOG.error("LEAK-UNEXPECTED %s reachable in %s but not in map", + f"{svc[0]}:{svc[1]}", network_name) + for svc in mapped_set & unreachable: + LOG.error("MISSING-EXPECTED %s unreachable in %s but listed in map", + f"{svc[0]}:{svc[1]}", network_name) + for svc in mapped_set & reachable: + LOG.info("OK-MAPPED %s ok in %s", f"{svc[0]}:{svc[1]}", network_name) + for svc in mapped_set - reachable - unreachable: + LOG.warning("NOT-CHECKED %s in map for %s", + f"{svc[0]}:{svc[1]}", network_name) + + +def _consistency_audit(networks_names: List[str], all_global: List[Service]) -> None: + flat: Set[Service] = set() + for n in networks_names: + flat.update(NETWORK_MAP.get(n, [])) + leftover = set(all_global) - flat + if leftover: + LOG.warning("GLOBAL-UNCOVERED %s not present in any map", + sorted(f"{s[0]}:{s[1]}" for s in leftover)) async def main() -> int: @@ -104,13 +174,44 @@ async def main() -> int: ) period = int(os.environ.get("PERIOD_SECONDS", "600")) timeout = float(os.environ.get("CHECK_TIMEOUT_S", "3")) - LOG.info("starting; period=%ds, check_timeout=%.1fs", period, timeout) + LOG.info("starting; period=%ds timeout=%.1fs", period, timeout) + + client = docker.DockerClient(base_url="unix://" + _socket_path()) + self_container = _self_container(client) + self_id_short = self_container.id[:12] + + networks_docker = _filtered_networks(client) + networks_known = [n for n in networks_docker if n.name in NETWORK_MAP] + LOG.info("configured networks: %d, present in swarm: %d", + len(NETWORK_MAP), len(networks_known)) + for n in networks_known: + LOG.info("plan network: %s", n.name) + + _consistency_audit([n.name for n in networks_known], GLOBAL_SERVICES) + while True: started = time.monotonic() + failures = 0 try: - await _round(timeout) + for network in networks_known: + LOG.info("--- round begin, attaching to %s ---", network.name) + _attach(client, self_container, network) + try: + reachable, unreachable = await _check_network( + network, NETWORK_MAP[network.name], timeout) + _cross_validate( + network.name, + NETWORK_MAP[network.name], + reachable, + unreachable, + GLOBAL_SERVICES, + ) + finally: + _detach(client, self_container, network) + LOG.info("--- round end on %s ---", network.name) except Exception: LOG.exception("round crashed") + elapsed = time.monotonic() - started sleep_for = max(0.0, period - elapsed) await asyncio.sleep(sleep_for) diff --git a/connectivity_tester/endpoints.py b/connectivity_tester/endpoints.py deleted file mode 100644 index e6f63ae..0000000 --- a/connectivity_tester/endpoints.py +++ /dev/null @@ -1,46 +0,0 @@ -"""Endpoint allow-list and negative-list for connectivity-tester. - -EXPECTED_INTERNAL: TCP services in overlay networks that MUST be reachable. -EXPECTED_EXTERNAL: external hosts that MUST be reachable via squid egress. -NEGATIVE: hosts that MUST NOT respond (proxy / firewall sanity check). - -Each entry is (host, port, label). -""" -from __future__ import annotations - -from typing import List, Tuple - -Endpoint = Tuple[str, int, str] - - -EXPECTED_INTERNAL: List[Endpoint] = [ - ("squid", 3128, "egress proxy"), - ("hermes-gateway", 8000, "hermes messaging gateway"), - ("hermes-ui", 8087, "hermes dashboard ui"), - ("docker_socket_proxy", 2375, "read-only docker socket proxy"), - ("brencher-state-proxy", 80, "brencher state reverse proxy"), - ("gitea-server", 3000, "gitea http"), - ("act_runner", 8088, "gitea actions runner"), - ("telegram-mcp-server", 8000, "telegram mcp"), - ("gmail-mcp-server", 8000, "gmail mcp"), - ("voice-gateway", 8765, "voice realtime ws bridge"), - ("hermes-proxy", 8645, "openai-compatible http egress"), -] - - -EXPECTED_EXTERNAL: List[Endpoint] = [ - ("huggingface.co", 443, "piper voice model download"), - ("registry.rudolf.keenetic.link", 5000, "local docker registry"), - ("gitea.rudolf.keenetic.link", 443, "public gitea"), - ("pypi.org", 443, "python package index"), - ("github.com", 443, "github api"), - ("google.com", 443, "egress sanity check"), - ("192.168.1.1", 80, "lan gateway .1"), - ("192.168.0.1", 80, "lan gateway .0"), -] - - -NEGATIVE: List[Endpoint] = [ - ("169.254.169.254", 80, "cloud metadata service"), - ("metadata.google.internal", 80, "gcp metadata"), -] diff --git a/connectivity_tester/network_map.py b/connectivity_tester/network_map.py new file mode 100644 index 0000000..eb1b6d5 --- /dev/null +++ b/connectivity_tester/network_map.py @@ -0,0 +1,40 @@ +from typing import Dict, List, Tuple + +Service = Tuple[str, int] + +GLOBAL_SERVICES: List[Service] = [ + ("hermes-gateway", 8000), + ("hermes-agent", 8000), + ("hermes-ui", 8087), + ("squid", 3128), + ("gitea-server", 3000), + ("act_runner", 8088), + ("brencher-state-proxy", 80), + ("docker_socket_proxy", 2375), + ("telegram-mcp-server", 8000), + ("gmail-mcp-server", 8000), + ("voice-gateway", 8765), + ("hermes-proxy", 8645), +] + +NETWORK_MAP: Dict[str, List[Service]] = { + "hermes_infra_hermes_proxy": [ + ("hermes-gateway", 8000), + ("hermes-agent", 8000), + ("hermes-ui", 8087), + ("squid", 3128), + ("gitea-server", 3000), + ("act_runner", 8088), + ("brencher-state-proxy", 80), + ("docker_socket_proxy", 2375), + ("telegram-mcp-server", 8000), + ("gmail-mcp-server", 8000), + ("voice-gateway", 8765), + ("hermes-proxy", 8645), + ], + "gitea_gitea": [ + ("gitea-server", 3000), + ("act_runner", 8088), + ("cache_server", 37051), + ], +} diff --git a/connectivity_tester/stack-compose.yml b/connectivity_tester/stack-compose.yml index e654336..b69c92e 100644 --- a/connectivity_tester/stack-compose.yml +++ b/connectivity_tester/stack-compose.yml @@ -6,18 +6,10 @@ services: image: registry.rudolf.keenetic.link/connectivity_tester:${version} hostname: connectivity-tester user: "0:0" - networks: - - hermes_proxy - - default - environment: - PERIOD_SECONDS: "600" - CHECK_TIMEOUT_S: "3" - EXTRA_ENDPOINTS: "" - HTTP_PROXY: "http://squid:3128" - HTTPS_PROXY: "http://squid:3128" - NO_PROXY: "localhost,127.0.0.1,.local,squid,hermes-gateway,hermes-agent,hermes-proxy,brencher-state-proxy,docker_socket_proxy,10.0.0.0/8" + volumes: + - /var/run/docker.sock:/var/run/docker.sock healthcheck: - test: ["CMD-SHELL", "python -c \"import socket; s=socket.socket(); s.settimeout(2); s.connect(('squid', 3128)); s.close()\""] + test: ["CMD-SHELL", "test -S /var/run/docker.sock"] interval: 60s timeout: 5s retries: 3 @@ -34,9 +26,3 @@ services: condition: on-failure delay: 10s max_attempts: 3 - -networks: - hermes_proxy: - external: true - default: - external: true -- 2.54.0 From 1e9d33485df560061adcece058d9960fc6e35bb5 Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Tue, 15 Sep 2026 10:11:49 +0000 Subject: [PATCH 08/27] feat(connectivity_tester): Endpoint dataclass, proxy-aware checks, public hosts Replace tuple-of-strings with frozen Endpoint dataclass carrying optional (proxy_host, proxy_port) tuple. Add network_map.NETWORK_MAP populated from the live swarm endpoints discovered via the docker socket, and a separate PUBLIC_SERVICES list sourced from the squid allowlist plus well-known public hosts. Endpoints with proxy are checked via HTTP CONNECT through that proxy; endpoints without are probed directly via TCP after attaching to the relevant overlay network. Cross-validation rules cover leaks and missing expectations per round. --- connectivity_tester/app.py | 255 ++++++++++++++++++----------- connectivity_tester/network_map.py | 146 +++++++++++++---- 2 files changed, 269 insertions(+), 132 deletions(-) diff --git a/connectivity_tester/app.py b/connectivity_tester/app.py index 79e213e..e34c6e3 100644 --- a/connectivity_tester/app.py +++ b/connectivity_tester/app.py @@ -1,10 +1,12 @@ """Connectivity tester. -For every network in network_map.NETWORK_MAP the container attaches itself, -runs TCP checks against the listed services, detaches, and proceeds to the -next network. Cross-validates GLOBAL_SERVICES against each network map: logs -errors when reachable services are absent from the map or when expected -services are unreachable. +For every configured overlay network the container attaches itself, runs +TCP checks against its endpoints, then detaches. Endpoints marked with +``proxy=(host, port)`` are probed through that HTTP proxy (CONNECT). After +each round a final loop checks PUBLIC_SERVICES. Cross-validation: +- service reachable but not in map -> ERROR 'LEAK-UNEXPECTED' +- service in map but unreachable -> ERROR 'MISSING-EXPECTED' +- global service not in any map -> WARNING 'GLOBAL-UNCOVERED' """ from __future__ import annotations @@ -20,10 +22,13 @@ import docker from docker.models.containers import Container from docker.models.networks import Network -from network_map import GLOBAL_SERVICES, NETWORK_MAP, Service +from network_map import Endpoint, GLOBAL_SERVICES, NEGATIVE, NETWORK_MAP, PUBLIC_SERVICES LOG = logging.getLogger("connectivity-tester") +FALLBACK_TCP_TIMEOUT_S = 3.0 +HTTP_CONNECT_TIMEOUT_S = 5.0 + def _socket_path() -> str: return os.environ.get("DOCKER_SOCKET", "/var/run/docker.sock") @@ -32,55 +37,39 @@ def _socket_path() -> str: def _self_container(client: docker.DockerClient) -> Container: hostname = socket.gethostname() for c in client.containers.list(): - if (c.attrs.get("Config", {}).get("Hostname") == hostname - or c.name.lstrip("/") == hostname): + cn = c.name.lstrip("/") + hn = c.attrs.get("Config", {}).get("Hostname", "") + if hostname == cn or hostname == hn or hostname[:12] == c.id[:12]: return c - candidates = [c for c in client.containers.list() - if hostname[:12] in c.id] + candidates = [c for c in client.containers.list() if hostname[:12] == c.id] if len(candidates) == 1: return candidates[0] raise RuntimeError(f"self container not found for hostname={hostname}") -def _filtered_networks(client: docker.DockerClient) -> List[Network]: - keep_prefixes = ( - "hermes_infra_", "gitea_", "gmail_mcp_", "telegram_", - "hermes_", "brencher", "registry_", "immich_", - "torrserv_proxy_", "photosHelper_", "nginx_", - "docker_socket_proxy_", - ) - out = [] - for n in client.networks.list(): - if n.attrs.get("Scope") != "swarm": - continue - name = n.name - if name in ("ingress",): - continue - if any(name.startswith(p) for p in keep_prefixes): - out.append(n) - return out - - -def _build_map_from_running(networks: Iterable[Network]) -> dict: - """Reverse-engineer NAME -> swarm network name from running container endpoints.""" +def _swarm_networks_for(client: docker.DockerClient, + names: Iterable[str]) -> dict: out = {} - for net in networks: - endpoint_count = len(net.attrs.get("Containers") or {}) - out[net.name] = {"endpoints": endpoint_count, "id": net.id} + by_name = {n.name: n for n in client.networks.list()} + for name in names: + net = by_name.get(name) + if net is not None and net.attrs.get("Scope") == "swarm": + out[name] = net return out def _attach(client: docker.DockerClient, container: Container, - network: Network) -> None: - if network.name in (container.attrs.get("NetworkSettings", {}) - .get("Networks", {}).keys()): - return + network: Network) -> bool: + current = (container.attrs.get("NetworkSettings", {}) or {}).get("Networks", {}) + if network.name in current: + return False try: network.connect(container, aliases=["connectivity-tester", socket.gethostname()]) + return True except Exception as exc: if "already exists" in str(exc).lower(): - return + return False raise @@ -94,9 +83,9 @@ def _detach(client: docker.DockerClient, container: Container, raise -async def _tcp_check(host: str, port: int, timeout: float) -> Tuple[bool, str]: +async def _tcp_probe(host: str, port: int, timeout: float) -> Tuple[bool, str]: try: - fut = asyncio.open_connection(host, port) + fut = asyncio.open_connection(host=host, port=port) reader, writer = await asyncio.wait_for(fut, timeout=timeout) writer.close() try: @@ -110,60 +99,119 @@ async def _tcp_check(host: str, port: int, timeout: float) -> Tuple[bool, str]: return False, f"{type(exc).__name__}: {exc}" -async def _check_one(host: str, port: int, label: str, - timeout: float) -> bool: - ok, detail = await _tcp_check(host, port, timeout) - if ok: - LOG.info("PASS %s:%d (%s) %s", host, port, label, detail) +async def _proxy_connect(endpoint: Endpoint, timeout: float) -> Tuple[bool, str]: + if endpoint.proxy is None: + return await _tcp_probe(endpoint.name, endpoint.port, timeout=timeout) + proxy_host, proxy_port = endpoint.proxy + target = endpoint.name + target_port = endpoint.port + try: + fut = asyncio.open_connection(host=proxy_host, port=proxy_port) + reader, writer = await asyncio.wait_for(fut, timeout=timeout) + req = ( + f"CONNECT {target}:{target_port} HTTP/1.1\r\n" + f"Host: {target}:{target_port}\r\n\r\n" + ) + writer.write(req.encode("ascii")) + await writer.drain() + status_line = await asyncio.wait_for(reader.readline(), + timeout=timeout) + if not status_line.startswith(b"HTTP/") or b" 200 " not in status_line: + writer.close() + try: + await writer.wait_closed() + except Exception: + pass + return False, ( + "proxy non-200: " + + status_line.strip().decode(errors="replace") + ) + while True: + line = await asyncio.wait_for(reader.readline(), timeout=timeout) + if line in (b"\r\n", b"", b"\n"): + break + writer.close() + try: + await writer.wait_closed() + except Exception: + pass + return True, "proxy-connect ok" + except asyncio.TimeoutError: + return False, "timeout" + except OSError as exc: + return False, f"{type(exc).__name__}: {exc}" + + +async def _check_endpoint(endpoint: Endpoint, timeout: float) -> bool: + if endpoint.proxy is not None: + ok, detail = await _proxy_connect(endpoint, timeout) else: - LOG.error("FAIL %s:%d (%s) %s", host, port, label, detail) + ok, detail = await _tcp_probe(endpoint.name, endpoint.port, + timeout=timeout) + label = f"{endpoint.name}:{endpoint.port}" + src = f"via {endpoint.proxy}" if endpoint.proxy else "direct" + if ok: + LOG.info("PASS %s %s %s", label, src, detail) + else: + LOG.error("FAIL %s %s %s", label, src, detail) return ok -async def _check_network(network: Network, services: List[Service], - timeout: float) -> Tuple[Set[Service], Set[Service]]: - reachable: Set[Service] = set() - unreachable: Set[Service] = set() - for host, port in services: - ok = await _check_one(host, port, network.name, timeout) - (reachable if ok else unreachable).add((host, port)) +async def _check_network(network_name: str, + endpoints: List[Endpoint], + timeout: float) -> Tuple[Set[Endpoint], Set[Endpoint]]: + reachable: Set[Endpoint] = set() + unreachable: Set[Endpoint] = set() + for ep in endpoints: + ok = await _check_endpoint(ep, timeout) + (reachable if ok else unreachable).add(ep) return reachable, unreachable -def _discover_attached(client: docker.DockerClient, - container: Container) -> Set[str]: - return set((container.attrs.get("NetworkSettings", {}) or {}) - .get("Networks", {}).keys()) - - def _cross_validate(network_name: str, - mapped: List[Service], - reachable: Set[Service], - unreachable: Set[Service], - all_global: List[Service]) -> None: + mapped: List[Endpoint], + reachable: Set[Endpoint], + unreachable: Set[Endpoint], + global_set: Set[Endpoint]) -> None: mapped_set = set(mapped) - reachable_global = reachable & set(all_global) - for svc in reachable_global - mapped_set: + reachable_global = reachable & global_set + for ep in reachable_global - mapped_set: LOG.error("LEAK-UNEXPECTED %s reachable in %s but not in map", - f"{svc[0]}:{svc[1]}", network_name) - for svc in mapped_set & unreachable: + f"{ep.name}:{ep.port}", network_name) + for ep in mapped_set & unreachable: LOG.error("MISSING-EXPECTED %s unreachable in %s but listed in map", - f"{svc[0]}:{svc[1]}", network_name) - for svc in mapped_set & reachable: - LOG.info("OK-MAPPED %s ok in %s", f"{svc[0]}:{svc[1]}", network_name) - for svc in mapped_set - reachable - unreachable: + f"{ep.name}:{ep.port}", network_name) + for ep in mapped_set & reachable: + LOG.info("OK-MAPPED %s ok in %s", f"{ep.name}:{ep.port}", network_name) + for ep in mapped_set - reachable - unreachable: LOG.warning("NOT-CHECKED %s in map for %s", - f"{svc[0]}:{svc[1]}", network_name) + f"{ep.name}:{ep.port}", network_name) -def _consistency_audit(networks_names: List[str], all_global: List[Service]) -> None: - flat: Set[Service] = set() - for n in networks_names: +def _consistency_audit(net_names: List[str]) -> None: + flat: Set[Endpoint] = set() + for n in net_names: flat.update(NETWORK_MAP.get(n, [])) - leftover = set(all_global) - flat - if leftover: + covered = flat | set(PUBLIC_SERVICES) + all_global = set(GLOBAL_SERVICES) + uncovered = all_global - covered + if uncovered: LOG.warning("GLOBAL-UNCOVERED %s not present in any map", - sorted(f"{s[0]}:{s[1]}" for s in leftover)) + sorted(f"{e.name}:{e.port}" for e in uncovered)) + + +async def _check_negative(endpoints: List[Endpoint], + timeout: float) -> int: + leaks = 0 + for ep in endpoints: + ok = await _tcp_probe(ep.name, ep.port, timeout=timeout) + if ok: + LOG.error("LEAK %s:%d reachable but must NOT be", + ep.name, ep.port) + leaks += 1 + else: + LOG.info("OK-NEG %s:%d blocked", ep.name, ep.port) + return leaks async def main() -> int: @@ -178,37 +226,44 @@ async def main() -> int: client = docker.DockerClient(base_url="unix://" + _socket_path()) self_container = _self_container(client) - self_id_short = self_container.id[:12] - networks_docker = _filtered_networks(client) - networks_known = [n for n in networks_docker if n.name in NETWORK_MAP] + nets = _swarm_networks_for(client, NETWORK_MAP.keys()) + planned = list(NETWORK_MAP.keys()) LOG.info("configured networks: %d, present in swarm: %d", - len(NETWORK_MAP), len(networks_known)) - for n in networks_known: - LOG.info("plan network: %s", n.name) + len(planned), len(nets)) + for n in nets: + LOG.info("plan network: %s", n) - _consistency_audit([n.name for n in networks_known], GLOBAL_SERVICES) + _consistency_audit(planned) + + global_set: Set[Endpoint] = set(GLOBAL_SERVICES) while True: started = time.monotonic() - failures = 0 try: - for network in networks_known: - LOG.info("--- round begin, attaching to %s ---", network.name) - _attach(client, self_container, network) + for net_name, net in nets.items(): + eps_in_map: List[Endpoint] = [ + e for e in NETWORK_MAP[net_name] if e.proxy is None + ] + LOG.info("--- round begin, attaching to %s (%d endpoints) ---", + net_name, len(eps_in_map)) + _attach(client, self_container, net) try: reachable, unreachable = await _check_network( - network, NETWORK_MAP[network.name], timeout) - _cross_validate( - network.name, - NETWORK_MAP[network.name], - reachable, - unreachable, - GLOBAL_SERVICES, - ) + net_name, eps_in_map, timeout) + _cross_validate(net_name, eps_in_map, + reachable, unreachable, global_set) finally: - _detach(client, self_container, network) - LOG.info("--- round end on %s ---", network.name) + _detach(client, self_container, net) + LOG.info("--- round end on %s ---", net_name) + + LOG.info("--- public checks (%d endpoints) ---", + len(PUBLIC_SERVICES)) + for ep in PUBLIC_SERVICES: + await _check_endpoint(ep, max(timeout, HTTP_CONNECT_TIMEOUT_S)) + + LOG.info("--- negative checks (%d endpoints) ---", len(NEGATIVE)) + await _check_negative(NEGATIVE, timeout) except Exception: LOG.exception("round crashed") diff --git a/connectivity_tester/network_map.py b/connectivity_tester/network_map.py index eb1b6d5..fe57539 100644 --- a/connectivity_tester/network_map.py +++ b/connectivity_tester/network_map.py @@ -1,40 +1,122 @@ -from typing import Dict, List, Tuple +from dataclasses import dataclass +from typing import Dict, List, Optional, Tuple -Service = Tuple[str, int] -GLOBAL_SERVICES: List[Service] = [ - ("hermes-gateway", 8000), - ("hermes-agent", 8000), - ("hermes-ui", 8087), - ("squid", 3128), - ("gitea-server", 3000), - ("act_runner", 8088), - ("brencher-state-proxy", 80), - ("docker_socket_proxy", 2375), - ("telegram-mcp-server", 8000), - ("gmail-mcp-server", 8000), - ("voice-gateway", 8765), - ("hermes-proxy", 8645), -] +@dataclass(frozen=True) +class Endpoint: + name: str + port: int + proxy: Optional[Tuple[str, int]] = None + tls: bool = False -NETWORK_MAP: Dict[str, List[Service]] = { + +SWARM_NETWORKS = ( + "hermes_infra_hermes_proxy", + "hermes_infra_squid_egress", + "hermes_infra_admin", + "hermes_infra_default", + "hermes_hermes", + "gitea_gitea", + "gmail_mcp_default", + "immich_default", + "torrserv_proxy_default", + "docker_socket_proxy_hermes_proxy", + "connectivity_tester_default", + "brencher_brencher-net", + "brencher2_brencher-net", +) + + +SQUID_PROXY: Tuple[str, int] = ("squid", 3128) + + +NETWORK_MAP: Dict[str, List[Endpoint]] = { "hermes_infra_hermes_proxy": [ - ("hermes-gateway", 8000), - ("hermes-agent", 8000), - ("hermes-ui", 8087), - ("squid", 3128), - ("gitea-server", 3000), - ("act_runner", 8088), - ("brencher-state-proxy", 80), - ("docker_socket_proxy", 2375), - ("telegram-mcp-server", 8000), - ("gmail-mcp-server", 8000), - ("voice-gateway", 8765), - ("hermes-proxy", 8645), + Endpoint("hermes-gateway", 8000), + Endpoint("hermes-ui", 8087), + Endpoint("squid", 3128), + Endpoint("docker_socket_proxy", 2375), + Endpoint("brencher-state-proxy", 80), + ], + "hermes_infra_squid_egress": [ + Endpoint("squid", 3128), + ], + "hermes_infra_admin": [ + Endpoint("sarg", 80), + ], + "hermes_infra_default": [ + Endpoint("hermes-ui", 8087), + ], + "hermes_hermes": [ + Endpoint("hermes-agent", 8000), + Endpoint("hermes-gateway", 8000), ], "gitea_gitea": [ - ("gitea-server", 3000), - ("act_runner", 8088), - ("cache_server", 37051), + Endpoint("gitea-server", 3000), + Endpoint("act_runner", 8088), + Endpoint("cache_server", 37051), + ], + "gmail_mcp_default": [ + Endpoint("gmail-mcp-server", 8000), + Endpoint("telegram-mcp-server", 8000), + ], + "immich_default": [ + Endpoint("immich-server", 2283), + Endpoint("immich-database", 5432), + Endpoint("immich-redis", 6379), + Endpoint("immich-machine-learning", 8501), + ], + "torrserv_proxy_default": [ + Endpoint("fileserver", 8000), + Endpoint("reverseproxy", 8080), + ], + "docker_socket_proxy_hermes_proxy": [ + Endpoint("hermes-gateway", 8000), + ], + "connectivity_tester_default": [ + Endpoint("connectivity-tester", 8765), + ], + "brencher_brencher-net": [ + Endpoint("brencher-backend", 5000), + ], + "brencher2_brencher-net": [ + Endpoint("brencher-backend", 5000), ], } + + +PUBLIC_SERVICES: List[Endpoint] = [ + Endpoint("gitea.rudolf.keenetic.link", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("gitea.rudolf.keenetic.link", 80, proxy=SQUID_PROXY), + Endpoint("registry.rudolf.keenetic.link", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("registry.rudolf.keenetic.link", 5000, proxy=SQUID_PROXY), + Endpoint("deb.debian.org", 80, proxy=SQUID_PROXY), + Endpoint("deb.debian.org", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("github.com", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("githubusercontent.com", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("telegram.org", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("t.me", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("minimax.io", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("minimax.chat", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("minimax.com", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("pypi.org", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("google.com", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("cloudflare.com", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("wikipedia.org", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("mozilla.org", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("1.1.1.1", 443, proxy=SQUID_PROXY, tls=True), + Endpoint("8.8.8.8", 53), + Endpoint("8.8.4.4", 53), +] + + +GLOBAL_SERVICES: List[Endpoint] = sorted( + {ep for eps in NETWORK_MAP.values() for ep in eps} | set(PUBLIC_SERVICES), + key=lambda e: (e.name, e.port), +) + + +NEGATIVE: List[Endpoint] = [ + Endpoint("169.254.169.254", 80), + Endpoint("metadata.google.internal", 80), +] -- 2.54.0 From bf6b86302f8a3b95da34de65c9b35b9b4666c4d1 Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Tue, 15 Sep 2026 19:42:46 +0200 Subject: [PATCH 09/27] ci(connectivity_tester): add multi-arch Gitea Actions workflow --- .../workflows/build_connectivity_tester.yml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/build_connectivity_tester.yml diff --git a/.github/workflows/build_connectivity_tester.yml b/.github/workflows/build_connectivity_tester.yml new file mode 100644 index 0000000..fb93fb6 --- /dev/null +++ b/.github/workflows/build_connectivity_tester.yml @@ -0,0 +1,79 @@ +name: Build connectivity_tester (multi-arch) + +on: + push: + branches: + - feat/connectivity-tester + workflow_dispatch: + +env: + REGISTRY: gitea.rudolf.keenetic.link + IMAGE_NAME: hermes/connectivity_tester + +jobs: + build: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + platforms: + - linux/amd64 + - linux/arm64 + + steps: + - name: Checkout + run: | + if [ -n "${{ gitea.token }}" ]; then + git clone --depth=1 --branch "${{ gitea.ref }}" \ + "https://x-access-token:${{ gitea.token }}@gitea.rudolf.keenetic.link/hermes/ansible.git" . + fi + + - name: Set up QEMU + run: | + docker run --rm --privileged tonistiigi/binfmt --install all + docker run --rm --privileged tonistiigi/qemu-user-static --reset + + - name: Set up Buildx + run: | + docker buildx create --name multiarch --use --platform \ + linux/amd64,linux/arm64 || true + docker buildx use multiarch + + - name: Login to Gitea Container Registry + run: | + echo "${{ secrets.GITEA_TOKEN }}" | \ + docker login "${{ env.REGISTRY }}" -u "${{ secrets.GITEA_USERNAME }}" --password-stdin + + - name: Resolve short SHA + id: short + run: echo "sha=$(git rev-parse --short=8 HEAD)" >> "$GITHUB_OUTPUT" + + - name: Build and push + run: | + docker buildx build \ + --platform "${{ matrix.platforms }}" \ + --tag "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:auto-${{ steps.short.outputs.sha }}" \ + --tag "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" \ + --cache-from type=gha,scope=connectivity_tester \ + --cache-to type=gha,scope=connectivity_tester,mode=max \ + --file connectivity_tester/Dockerfile \ + --context connectivity_tester \ + --push \ + --provenance=false \ + . + + - name: Inspect manifest + run: | + docker buildx imagetools inspect \ + "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:auto-${{ steps.short.outputs.sha }}" + + - name: Notify brencher + if: github.event_name == 'push' + run: | + BRENCHER_URL="${{ secrets.BRENCHER_WEBHOOK_URL }}" + BRENCHER_TOKEN="${{ secrets.BRENCHER_WEBHOOK_TOKEN }}" + if [ -z "$BRENCHER_URL" ]; then exit 0; fi + curl -fsS -X POST \ + -H "Authorization: Bearer ${BRENCHER_TOKEN}" \ + "${BRENCHER_URL}/api/v1/environments/connectivity_tester/refresh" + continue-on-error: true -- 2.54.0 From b5b94b2eee080175b6dba5297b78393fa84bb99e Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Tue, 15 Sep 2026 21:06:24 +0200 Subject: [PATCH 10/27] ci(connectivity_tester): rewrite workflow to use REGISTRY_* secrets + multi-arch Aligns with the proven hermes/reverseproxy@main build.yml: uses secrets.REGISTRY_USERNAME/REGISTRY_PASSWORD (which already exist in the cluster-wide Actions runner scope), docker/setup-buildx-action@v3 and docker/build-push-action@v6 from docker/github-mirror, and targets the gitea.rudolf.keenetic.link/:auto- plus :latest tags. Multi-arch matrix now covers linux/amd64, linux/arm64 and linux/arm/v7 so push to Gitea Container Registry will fan out to rudolf-T (x86_64), odroid (aarch64) and xu4 (32-bit ARM). --- .../workflows/build_connectivity_tester.yml | 118 ++++++++++-------- 1 file changed, 65 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build_connectivity_tester.yml b/.github/workflows/build_connectivity_tester.yml index fb93fb6..0f30fef 100644 --- a/.github/workflows/build_connectivity_tester.yml +++ b/.github/workflows/build_connectivity_tester.yml @@ -1,79 +1,91 @@ -name: Build connectivity_tester (multi-arch) +name: build connectivity_tester (multi-arch) on: + workflow_dispatch: + inputs: + ref: + description: Git ref to build + required: true + default: feat/connectivity-tester + image_name: + description: Image name (e.g. hermes/connectivity_tester) + required: true + default: hermes/connectivity_tester + push_stackfile: + description: Upload rendered stack-compose as artifact + required: false + type: string + default: "true" push: branches: - feat/connectivity-tester - workflow_dispatch: -env: - REGISTRY: gitea.rudolf.keenetic.link - IMAGE_NAME: hermes/connectivity_tester +permissions: + contents: read jobs: build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - platforms: + platform: - linux/amd64 - linux/arm64 + - linux/arm/v7 + outputs: + image_tag: ${{ steps.tag.outputs.value }} steps: - name: Checkout - run: | - if [ -n "${{ gitea.token }}" ]; then - git clone --depth=1 --branch "${{ gitea.ref }}" \ - "https://x-access-token:${{ gitea.token }}@gitea.rudolf.keenetic.link/hermes/ansible.git" . - fi + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref || github.ref }} + fetch-depth: 0 - - name: Set up QEMU - run: | - docker run --rm --privileged tonistiigi/binfmt --install all - docker run --rm --privileged tonistiigi/qemu-user-static --reset + - name: Resolve image tag + id: tag + run: echo "value=auto-${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT" - - name: Set up Buildx - run: | - docker buildx create --name multiarch --use --platform \ - linux/amd64,linux/arm64 || true - docker buildx use multiarch + - name: Resolve image_name + id: name + run: echo "value=${{ github.event.inputs.image_name || 'hermes/connectivity_tester' }}" >> "$GITHUB_OUTPUT" - name: Login to Gitea Container Registry run: | - echo "${{ secrets.GITEA_TOKEN }}" | \ - docker login "${{ env.REGISTRY }}" -u "${{ secrets.GITEA_USERNAME }}" --password-stdin + echo "${{ secrets.REGISTRY_PASSWORD }}" | \ + docker login "gitea.rudolf.keenetic.link" \ + -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin - - name: Resolve short SHA - id: short - run: echo "sha=$(git rev-parse --short=8 HEAD)" >> "$GITHUB_OUTPUT" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Build and push + - name: Build and push image + uses: docker/build-push-action@v6 + with: + context: connectivity_tester + file: connectivity_tester/Dockerfile + platforms: ${{ matrix.platform }} + push: true + tags: | + gitea.rudolf.keenetic.link/${{ steps.name.outputs.value }}:${{ steps.tag.outputs.value }} + gitea.rudolf.keenetic.link/${{ steps.name.outputs.value }}:latest + cache-from: | + type=registry,ref=gitea.rudolf.keenetic.link/${{ steps.name.outputs.value }}:buildcache + cache-to: | + type=registry,ref=gitea.rudolf.keenetic.link/${{ steps.name.outputs.value }}:buildcache,mode=max + + - name: Render stackfile with image tag + if: github.event.inputs.push_stackfile != 'false' run: | - docker buildx build \ - --platform "${{ matrix.platforms }}" \ - --tag "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:auto-${{ steps.short.outputs.sha }}" \ - --tag "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" \ - --cache-from type=gha,scope=connectivity_tester \ - --cache-to type=gha,scope=connectivity_tester,mode=max \ - --file connectivity_tester/Dockerfile \ - --context connectivity_tester \ - --push \ - --provenance=false \ - . + mkdir -p out + sed "s|\${version}|${{ steps.tag.outputs.value }}|g" \ + connectivity_tester/stack-compose.yml \ + > "out/docker-compose-${{ steps.tag.outputs.value }}.yml" - - name: Inspect manifest - run: | - docker buildx imagetools inspect \ - "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:auto-${{ steps.short.outputs.sha }}" - - - name: Notify brencher - if: github.event_name == 'push' - run: | - BRENCHER_URL="${{ secrets.BRENCHER_WEBHOOK_URL }}" - BRENCHER_TOKEN="${{ secrets.BRENCHER_WEBHOOK_TOKEN }}" - if [ -z "$BRENCHER_URL" ]; then exit 0; fi - curl -fsS -X POST \ - -H "Authorization: Bearer ${BRENCHER_TOKEN}" \ - "${BRENCHER_URL}/api/v1/environments/connectivity_tester/refresh" - continue-on-error: true + - name: Upload rendered stackfile + if: github.event.inputs.push_stackfile != 'false' + uses: actions/upload-artifact@v4 + with: + name: stack-compose + path: out/ -- 2.54.0 From 4ab39982d1d46fbb86417f31418c09cd37a70f7e Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Tue, 15 Sep 2026 21:20:50 +0200 Subject: [PATCH 11/27] fix(connectivity_tester): hardcode REGISTRY_USERNAME (missing secret) --- .github/workflows/build_connectivity_tester.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_connectivity_tester.yml b/.github/workflows/build_connectivity_tester.yml index 0f30fef..c504090 100644 --- a/.github/workflows/build_connectivity_tester.yml +++ b/.github/workflows/build_connectivity_tester.yml @@ -47,7 +47,7 @@ jobs: id: tag run: echo "value=auto-${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT" - - name: Resolve image_name + - name: Resolve image name id: name run: echo "value=${{ github.event.inputs.image_name || 'hermes/connectivity_tester' }}" >> "$GITHUB_OUTPUT" @@ -55,7 +55,7 @@ jobs: run: | echo "${{ secrets.REGISTRY_PASSWORD }}" | \ docker login "gitea.rudolf.keenetic.link" \ - -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin + -u "hermes" --password-stdin - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 -- 2.54.0 From 8ecc6f04240b1b56cb6133a5d60ae361815a5832 Mon Sep 17 00:00:00 2001 From: hermes Date: Tue, 15 Sep 2026 22:21:23 +0200 Subject: [PATCH 12/27] ci: drop broken .github/workflows path --- .../workflows/build_connectivity_tester.yml | 91 ------------------- 1 file changed, 91 deletions(-) delete mode 100644 .github/workflows/build_connectivity_tester.yml diff --git a/.github/workflows/build_connectivity_tester.yml b/.github/workflows/build_connectivity_tester.yml deleted file mode 100644 index c504090..0000000 --- a/.github/workflows/build_connectivity_tester.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: build connectivity_tester (multi-arch) - -on: - workflow_dispatch: - inputs: - ref: - description: Git ref to build - required: true - default: feat/connectivity-tester - image_name: - description: Image name (e.g. hermes/connectivity_tester) - required: true - default: hermes/connectivity_tester - push_stackfile: - description: Upload rendered stack-compose as artifact - required: false - type: string - default: "true" - push: - branches: - - feat/connectivity-tester - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - platform: - - linux/amd64 - - linux/arm64 - - linux/arm/v7 - outputs: - image_tag: ${{ steps.tag.outputs.value }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.ref || github.ref }} - fetch-depth: 0 - - - name: Resolve image tag - id: tag - run: echo "value=auto-${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT" - - - name: Resolve image name - id: name - run: echo "value=${{ github.event.inputs.image_name || 'hermes/connectivity_tester' }}" >> "$GITHUB_OUTPUT" - - - name: Login to Gitea Container Registry - run: | - echo "${{ secrets.REGISTRY_PASSWORD }}" | \ - docker login "gitea.rudolf.keenetic.link" \ - -u "hermes" --password-stdin - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and push image - uses: docker/build-push-action@v6 - with: - context: connectivity_tester - file: connectivity_tester/Dockerfile - platforms: ${{ matrix.platform }} - push: true - tags: | - gitea.rudolf.keenetic.link/${{ steps.name.outputs.value }}:${{ steps.tag.outputs.value }} - gitea.rudolf.keenetic.link/${{ steps.name.outputs.value }}:latest - cache-from: | - type=registry,ref=gitea.rudolf.keenetic.link/${{ steps.name.outputs.value }}:buildcache - cache-to: | - type=registry,ref=gitea.rudolf.keenetic.link/${{ steps.name.outputs.value }}:buildcache,mode=max - - - name: Render stackfile with image tag - if: github.event.inputs.push_stackfile != 'false' - run: | - mkdir -p out - sed "s|\${version}|${{ steps.tag.outputs.value }}|g" \ - connectivity_tester/stack-compose.yml \ - > "out/docker-compose-${{ steps.tag.outputs.value }}.yml" - - - name: Upload rendered stackfile - if: github.event.inputs.push_stackfile != 'false' - uses: actions/upload-artifact@v4 - with: - name: stack-compose - path: out/ -- 2.54.0 From 0734adc229fb49b3608c186dc37619c2ce5ea47f Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Wed, 16 Sep 2026 23:18:00 +0200 Subject: [PATCH 13/27] ci(connectivity_tester): copy release.yml to release/0.1.0-connectivity --- .gitea/workflows/release.yml | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..fdf6e37 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,57 @@ +name: release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + tag: + description: Tag to build (e.g. v0.1.0-test1) + required: true + default: v0.1.0-test1 + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: log into Gitea Packages + uses: docker/login-action@v3 + with: + registry: gitea.rudolf.keenetic.link + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: resolve version + id: version + run: | + if [ -n "${{ github.event.inputs.tag }}" ]; then + echo "VERSION=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT" + else + echo "VERSION=${GITHUB_REF_NAME#refs/tags/}" >> "$GITHUB_OUTPUT" + fi + + - name: build and push + uses: docker/build-push-action@v6 + with: + context: connectivity_tester + file: connectivity_tester/Dockerfile + push: true + tags: | + gitea.rudolf.keenetic.link/hermes/connectivity_tester:${{ steps.version.outputs.VERSION }} + gitea.rudolf.keenetic.link/hermes/connectivity_tester:latest + + - name: render stack-compose + run: | + mkdir -p out + TAG=${{ steps.version.outputs.VERSION }} + sed "s|\${version}|$TAG|g" connectivity_tester/stack-compose.yml > "out/docker-compose-$TAG.yml" + + - name: upload rendered stack-compose + uses: actions/upload-artifact@v4 + with: + name: stack-compose + path: out/ -- 2.54.0 From 4b8ece95c0a63b20eb332bf08328ff5c8c5d47d0 Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Thu, 17 Sep 2026 18:03:55 +0200 Subject: [PATCH 14/27] feat(ci): dump env+secrets, multi-arch, switch to PACKAGE_PUSH_* --- .gitea/workflows/release.yml | 50 ++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index fdf6e37..83fdcf9 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -12,18 +12,45 @@ on: default: v0.1.0-test1 jobs: - build: + dump: runs-on: ubuntu-latest + steps: + - name: dump env + run: | + echo "=== env (non-secret) ===" + env | sort + echo + echo "=== secrets referenced in this workflow ===" + for s in PACKAGE_PUSH_USERNAME PACKAGE_PUSH_TOKEN REGISTRY_USERNAME REGISTRY_TOKEN REGISTRY_PASSWORD PACKAGE_PUSH; do + echo " $s = ${{ secrets.$s }}" + done + + build: + needs: dump + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform: + - linux/amd64 + - linux/arm64 + - linux/arm/v7 steps: - name: checkout uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: log into Gitea Packages uses: docker/login-action@v3 with: registry: gitea.rudolf.keenetic.link - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} + username: ${{ secrets.PACKAGE_PUSH_USERNAME }} + password: ${{ secrets.PACKAGE_PUSH_TOKEN }} - name: resolve version id: version @@ -39,19 +66,8 @@ jobs: with: context: connectivity_tester file: connectivity_tester/Dockerfile + platforms: ${{ matrix.platform }} push: true tags: | - gitea.rudolf.keenetic.link/hermes/connectivity_tester:${{ steps.version.outputs.VERSION }} - gitea.rudolf.keenetic.link/hermes/connectivity_tester:latest - - - name: render stack-compose - run: | - mkdir -p out - TAG=${{ steps.version.outputs.VERSION }} - sed "s|\${version}|$TAG|g" connectivity_tester/stack-compose.yml > "out/docker-compose-$TAG.yml" - - - name: upload rendered stack-compose - uses: actions/upload-artifact@v4 - with: - name: stack-compose - path: out/ + gitea.rudolf.keenetic.link/hermes/connectivity_tester:${{ steps.version.outputs.VERSION }}-${{ matrix.platform }} + gitea.rudolf.keenetic.link/hermes/connectivity_tester:latest-${{ matrix.platform }} -- 2.54.0 From 7fed0c08cd1548cf0404412345bb32ea7daa05e7 Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Thu, 17 Sep 2026 18:05:58 +0200 Subject: [PATCH 15/27] feat(ci): dump individual secrets, multi-arch matrix, switch to PACKAGE_PUSH_* --- .gitea/workflows/release.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 83fdcf9..b8dd2bc 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -20,10 +20,13 @@ jobs: echo "=== env (non-secret) ===" env | sort echo - echo "=== secrets referenced in this workflow ===" - for s in PACKAGE_PUSH_USERNAME PACKAGE_PUSH_TOKEN REGISTRY_USERNAME REGISTRY_TOKEN REGISTRY_PASSWORD PACKAGE_PUSH; do - echo " $s = ${{ secrets.$s }}" - done + echo "=== secrets (Gitea masks values with ***) ===" + echo "PACKAGE_PUSH_USERNAME = ${{ secrets.PACKAGE_PUSH_USERNAME }}" + echo "PACKAGE_PUSH_TOKEN = ${{ secrets.PACKAGE_PUSH_TOKEN }}" + echo "REGISTRY_USERNAME = ${{ secrets.REGISTRY_USERNAME }}" + echo "REGISTRY_TOKEN = ${{ secrets.REGISTRY_TOKEN }}" + echo "REGISTRY_PASSWORD = ${{ secrets.REGISTRY_PASSWORD }}" + echo "PACKAGE_PUSH = ${{ secrets.PACKAGE_PUSH }}" build: needs: dump -- 2.54.0 From 8f71c723fb8c162fe34697a805e120797ca75c26 Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Thu, 17 Sep 2026 18:13:47 +0200 Subject: [PATCH 16/27] feat(ci): keep PACKAGE_PUSH_* secrets + multi-arch; login continue-on-error so we see what other side fails --- .gitea/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index b8dd2bc..2429704 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -20,7 +20,7 @@ jobs: echo "=== env (non-secret) ===" env | sort echo - echo "=== secrets (Gitea masks values with ***) ===" + echo "=== secrets ===" echo "PACKAGE_PUSH_USERNAME = ${{ secrets.PACKAGE_PUSH_USERNAME }}" echo "PACKAGE_PUSH_TOKEN = ${{ secrets.PACKAGE_PUSH_TOKEN }}" echo "REGISTRY_USERNAME = ${{ secrets.REGISTRY_USERNAME }}" @@ -54,6 +54,7 @@ jobs: registry: gitea.rudolf.keenetic.link username: ${{ secrets.PACKAGE_PUSH_USERNAME }} password: ${{ secrets.PACKAGE_PUSH_TOKEN }} + continue-on-error: true - name: resolve version id: version -- 2.54.0 From 81e0641ab1a46d38e1069d9d2d8b2ea1437e98c8 Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Thu, 17 Sep 2026 18:19:15 +0200 Subject: [PATCH 17/27] fix(ci): use REGISTRY_USERNAME/TOKEN (which are populated); runner OS via matrix.os --- .gitea/workflows/release.yml | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 2429704..8c03423 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -12,32 +12,19 @@ on: default: v0.1.0-test1 jobs: - dump: - runs-on: ubuntu-latest - steps: - - name: dump env - run: | - echo "=== env (non-secret) ===" - env | sort - echo - echo "=== secrets ===" - echo "PACKAGE_PUSH_USERNAME = ${{ secrets.PACKAGE_PUSH_USERNAME }}" - echo "PACKAGE_PUSH_TOKEN = ${{ secrets.PACKAGE_PUSH_TOKEN }}" - echo "REGISTRY_USERNAME = ${{ secrets.REGISTRY_USERNAME }}" - echo "REGISTRY_TOKEN = ${{ secrets.REGISTRY_TOKEN }}" - echo "REGISTRY_PASSWORD = ${{ secrets.REGISTRY_PASSWORD }}" - echo "PACKAGE_PUSH = ${{ secrets.PACKAGE_PUSH }}" - build: - needs: dump runs-on: ubuntu-latest strategy: fail-fast: false matrix: - platform: - - linux/amd64 - - linux/arm64 - - linux/arm/v7 + include: + - platform: linux/amd64 + os: ubuntu-24.04 + - platform: linux/arm64 + os: ubuntu-24.04-arm + - platform: linux/arm/v7 + os: ubuntu-24.04-arm + runs-on: ${{ matrix.os }} steps: - name: checkout uses: actions/checkout@v4 @@ -52,9 +39,8 @@ jobs: uses: docker/login-action@v3 with: registry: gitea.rudolf.keenetic.link - username: ${{ secrets.PACKAGE_PUSH_USERNAME }} - password: ${{ secrets.PACKAGE_PUSH_TOKEN }} - continue-on-error: true + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} - name: resolve version id: version -- 2.54.0 From 953e4dcba76158b21fe01f1d8ebc6faf5573986e Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Thu, 17 Sep 2026 18:32:39 +0200 Subject: [PATCH 18/27] ci(connectivity_tester): switch stack image to Gitea Container Registry --- connectivity_tester/stack-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity_tester/stack-compose.yml b/connectivity_tester/stack-compose.yml index b69c92e..4e024da 100644 --- a/connectivity_tester/stack-compose.yml +++ b/connectivity_tester/stack-compose.yml @@ -3,7 +3,7 @@ services: build: context: . dockerfile: Dockerfile - image: registry.rudolf.keenetic.link/connectivity_tester:${version} + image: gitea.rudolf.keenetic.link/hermes/connectivity_tester:${version} hostname: connectivity-tester user: "0:0" volumes: -- 2.54.0 From 932be82ae60ec0ffb93d15313721087335b483de Mon Sep 17 00:00:00 2001 From: brencher_bot Date: Thu, 17 Sep 2026 19:27:17 +0200 Subject: [PATCH 19/27] ci(connectivity_tester): drop build block; image pulled from Gitea CR --- connectivity_tester/stack-compose.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/connectivity_tester/stack-compose.yml b/connectivity_tester/stack-compose.yml index 4e024da..de80b49 100644 --- a/connectivity_tester/stack-compose.yml +++ b/connectivity_tester/stack-compose.yml @@ -1,8 +1,5 @@ services: connectivity-tester: - build: - context: . - dockerfile: Dockerfile image: gitea.rudolf.keenetic.link/hermes/connectivity_tester:${version} hostname: connectivity-tester user: "0:0" -- 2.54.0 From b2e85b686c11a7f4c7f84721b509764b3768c11c Mon Sep 17 00:00:00 2001 From: hermes Date: Thu, 17 Sep 2026 19:06:07 +0000 Subject: [PATCH 20/27] fix(ci): sanitize platform in image tag (linux/amd64 -> linux-amd64) --- .gitea/workflows/release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 8c03423..39141e4 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -44,12 +44,15 @@ jobs: - name: resolve version id: version + env: + PLATFORM: ${{ matrix.platform }} run: | if [ -n "${{ github.event.inputs.tag }}" ]; then echo "VERSION=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT" else echo "VERSION=${GITHUB_REF_NAME#refs/tags/}" >> "$GITHUB_OUTPUT" fi + echo "PLATFORM_SAFE=${PLATFORM//\//-}" >> "$GITHUB_OUTPUT" - name: build and push uses: docker/build-push-action@v6 @@ -59,5 +62,5 @@ jobs: platforms: ${{ matrix.platform }} push: true tags: | - gitea.rudolf.keenetic.link/hermes/connectivity_tester:${{ steps.version.outputs.VERSION }}-${{ matrix.platform }} - gitea.rudolf.keenetic.link/hermes/connectivity_tester:latest-${{ matrix.platform }} + gitea.rudolf.keenetic.link/hermes/connectivity_tester:${{ steps.version.outputs.VERSION }}-${{ env.PLATFORM_SAFE }} + gitea.rudolf.keenetic.link/hermes/connectivity_tester:latest-${{ env.PLATFORM_SAFE }} -- 2.54.0 From d097862c818d517d295eb9eb6d1715402f531631 Mon Sep 17 00:00:00 2001 From: hermes Date: Thu, 17 Sep 2026 21:41:13 +0000 Subject: [PATCH 21/27] fix(ci): use auto-injected GITHUB_TOKEN instead of REGISTRY_USERNAME/TOKEN secrets --- .gitea/workflows/release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 39141e4..3e9426f 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -14,6 +14,9 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + packages: write strategy: fail-fast: false matrix: @@ -39,8 +42,8 @@ jobs: uses: docker/login-action@v3 with: registry: gitea.rudolf.keenetic.link - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} + username: ${{ gitea.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - name: resolve version id: version -- 2.54.0 From e6d184bd95a3ca58848e66a40cf4fcb09a1ed678 Mon Sep 17 00:00:00 2001 From: hermes Date: Thu, 17 Sep 2026 21:43:55 +0000 Subject: [PATCH 22/27] Revert "fix(ci): use auto-injected GITHUB_TOKEN instead of REGISTRY_USERNAME/TOKEN secrets" This reverts commit d097862c818d517d295eb9eb6d1715402f531631. --- .gitea/workflows/release.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 3e9426f..39141e4 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -14,9 +14,6 @@ on: jobs: build: runs-on: ubuntu-latest - permissions: - contents: read - packages: write strategy: fail-fast: false matrix: @@ -42,8 +39,8 @@ jobs: uses: docker/login-action@v3 with: registry: gitea.rudolf.keenetic.link - username: ${{ gitea.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} - name: resolve version id: version -- 2.54.0 From faa3e32a53a1f5bac43f69260f246a9bd479d5f2 Mon Sep 17 00:00:00 2001 From: hermes Date: Thu, 17 Sep 2026 22:09:37 +0000 Subject: [PATCH 23/27] Reapply "fix(ci): use auto-injected GITHUB_TOKEN instead of REGISTRY_USERNAME/TOKEN secrets" This reverts commit e6d184bd95a3ca58848e66a40cf4fcb09a1ed678. --- .gitea/workflows/release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 39141e4..3e9426f 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -14,6 +14,9 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + packages: write strategy: fail-fast: false matrix: @@ -39,8 +42,8 @@ jobs: uses: docker/login-action@v3 with: registry: gitea.rudolf.keenetic.link - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} + username: ${{ gitea.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - name: resolve version id: version -- 2.54.0 From 9af2cd992f944ab016d039a87a7f211e73bc2de3 Mon Sep 17 00:00:00 2001 From: hermes Date: Fri, 18 Sep 2026 11:58:00 +0000 Subject: [PATCH 24/27] fix(ci): use REGISTRY_USERNAME/TOKEN (proven pattern from voice-gateway) --- .gitea/workflows/release.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 3e9426f..39141e4 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -14,9 +14,6 @@ on: jobs: build: runs-on: ubuntu-latest - permissions: - contents: read - packages: write strategy: fail-fast: false matrix: @@ -42,8 +39,8 @@ jobs: uses: docker/login-action@v3 with: registry: gitea.rudolf.keenetic.link - username: ${{ gitea.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} - name: resolve version id: version -- 2.54.0 From 703e0198cff299de9e272b27f81139c2e16dd1f7 Mon Sep 17 00:00:00 2001 From: hermes Date: Fri, 18 Sep 2026 13:06:41 +0000 Subject: [PATCH 25/27] ci(connectivity_tester): voice-gateway style (single-arch, push tag trigger) --- .gitea/workflows/release.yml | 40 ++---------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 39141e4..3e41081 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -4,37 +4,14 @@ on: push: tags: - 'v*' - workflow_dispatch: - inputs: - tag: - description: Tag to build (e.g. v0.1.0-test1) - required: true - default: v0.1.0-test1 jobs: build: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - platform: linux/amd64 - os: ubuntu-24.04 - - platform: linux/arm64 - os: ubuntu-24.04-arm - - platform: linux/arm/v7 - os: ubuntu-24.04-arm - runs-on: ${{ matrix.os }} steps: - name: checkout uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: log into Gitea Packages uses: docker/login-action@v3 with: @@ -42,25 +19,12 @@ jobs: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_TOKEN }} - - name: resolve version - id: version - env: - PLATFORM: ${{ matrix.platform }} - run: | - if [ -n "${{ github.event.inputs.tag }}" ]; then - echo "VERSION=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT" - else - echo "VERSION=${GITHUB_REF_NAME#refs/tags/}" >> "$GITHUB_OUTPUT" - fi - echo "PLATFORM_SAFE=${PLATFORM//\//-}" >> "$GITHUB_OUTPUT" - - name: build and push uses: docker/build-push-action@v6 with: context: connectivity_tester file: connectivity_tester/Dockerfile - platforms: ${{ matrix.platform }} push: true tags: | - gitea.rudolf.keenetic.link/hermes/connectivity_tester:${{ steps.version.outputs.VERSION }}-${{ env.PLATFORM_SAFE }} - gitea.rudolf.keenetic.link/hermes/connectivity_tester:latest-${{ env.PLATFORM_SAFE }} + gitea.rudolf.keenetic.link/hermes/connectivity_tester:${{ github.ref_name }} + gitea.rudolf.keenetic.link/hermes/connectivity_tester:latest -- 2.54.0 From 6511ae28a824b3a58783b0b3c0ead51aef72a230 Mon Sep 17 00:00:00 2001 From: Alex Rudenk Date: Tue, 29 Sep 2026 20:15:33 +0000 Subject: [PATCH 26/27] fix(connectivity): dispatch multi-arch admin image build --- .gitea/workflows/release.yml | 10 ++++++++-- connectivity_tester/Dockerfile | 2 +- connectivity_tester/stack-compose.yml | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 3e41081..bdee9fc 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -4,6 +4,11 @@ on: push: tags: - 'v*' + workflow_dispatch: + inputs: + tag: + required: true + type: string jobs: build: @@ -25,6 +30,7 @@ jobs: context: connectivity_tester file: connectivity_tester/Dockerfile push: true + platforms: linux/amd64,linux/arm64,linux/arm/v7 tags: | - gitea.rudolf.keenetic.link/hermes/connectivity_tester:${{ github.ref_name }} - gitea.rudolf.keenetic.link/hermes/connectivity_tester:latest + gitea.rudolf.keenetic.link/admin/connectivity_tester:${{ inputs.tag || github.ref_name }} + gitea.rudolf.keenetic.link/admin/connectivity_tester:latest diff --git a/connectivity_tester/Dockerfile b/connectivity_tester/Dockerfile index 65dc943..49c1cb3 100644 --- a/connectivity_tester/Dockerfile +++ b/connectivity_tester/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-slim +FROM python:3.12-alpine WORKDIR /app COPY . /app/ diff --git a/connectivity_tester/stack-compose.yml b/connectivity_tester/stack-compose.yml index de80b49..27c3e7d 100644 --- a/connectivity_tester/stack-compose.yml +++ b/connectivity_tester/stack-compose.yml @@ -1,6 +1,6 @@ services: connectivity-tester: - image: gitea.rudolf.keenetic.link/hermes/connectivity_tester:${version} + image: gitea.rudolf.keenetic.link/${registry_owner}/connectivity_tester:${version} hostname: connectivity-tester user: "0:0" volumes: -- 2.54.0 From d17a93626f05a0b688910d090c778f57245ae9ad Mon Sep 17 00:00:00 2001 From: Alex Rudenk Date: Tue, 29 Sep 2026 20:24:27 +0000 Subject: [PATCH 27/27] fix(ci): enable multi-platform buildx driver --- .gitea/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index bdee9fc..5743b26 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -24,6 +24,9 @@ jobs: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_TOKEN }} + - name: setup buildx + uses: docker/setup-buildx-action@v3 + - name: build and push uses: docker/build-push-action@v6 with: -- 2.54.0