From 46de9cf916f0df16f8cb613b86b994828a68ea01 Mon Sep 17 00:00:00 2001 From: j4n Date: Tue, 24 Feb 2026 07:54:30 +0100 Subject: [PATCH] fix(cmdeploy): docker: route test commands through container via CHATMAIL_DOCKER Tests SSH into the host and run systemctl/journalctl/env directly, which fails on Docker deployments where services run inside the container. When CHATMAIL_DOCKER is set (to container name), Remote and SSHExec now wrap commands in `docker exec`. Without CHATMAIL_DOCKER, behavior is unchanged. --- .github/workflows/docker-ci.yaml | 4 ++-- cmdeploy/src/cmdeploy/sshexec.py | 3 +++ cmdeploy/src/cmdeploy/tests/plugin.py | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-ci.yaml b/.github/workflows/docker-ci.yaml index 634c6e79..568df646 100644 --- a/.github/workflows/docker-ci.yaml +++ b/.github/workflows/docker-ci.yaml @@ -210,7 +210,7 @@ jobs: ssh root@ns.testrun.org systemctl reload nsd - name: cmdeploy test - run: CHATMAIL_DOMAIN2=ci-chatmail.testrun.org cmdeploy test --slow + run: CHATMAIL_DOCKER=chatmail CHATMAIL_DOMAIN2=ci-chatmail.testrun.org cmdeploy test --slow - name: cmdeploy dns run: | @@ -337,7 +337,7 @@ jobs: ssh root@ns.testrun.org systemctl reload nsd - name: cmdeploy test - run: CHATMAIL_DOMAIN2=ci-chatmail.testrun.org cmdeploy test --slow + run: CHATMAIL_DOCKER=chatmail CHATMAIL_DOMAIN2=ci-chatmail.testrun.org cmdeploy test --slow - name: cmdeploy dns run: | diff --git a/cmdeploy/src/cmdeploy/sshexec.py b/cmdeploy/src/cmdeploy/sshexec.py index 6a37b939..04968637 100644 --- a/cmdeploy/src/cmdeploy/sshexec.py +++ b/cmdeploy/src/cmdeploy/sshexec.py @@ -50,6 +50,9 @@ class SSHExec: FuncError = FuncError def __init__(self, host, verbose=False, python="python3", timeout=60): + docker_container = os.environ.get("CHATMAIL_DOCKER") + if docker_container: + python = f"docker exec -i {docker_container} python3" self.gateway = execnet.makegateway(f"ssh=root@{host}//python={python}") self._remote_cmdloop_channel = bootstrap_remote(self.gateway, remote) self.timeout = timeout diff --git a/cmdeploy/src/cmdeploy/tests/plugin.py b/cmdeploy/src/cmdeploy/tests/plugin.py index 34f258df..08ce9b33 100644 --- a/cmdeploy/src/cmdeploy/tests/plugin.py +++ b/cmdeploy/src/cmdeploy/tests/plugin.py @@ -402,6 +402,9 @@ class Remote: case "@local": command = [] case "localhost": command = [] case _: command = ["ssh", f"root@{self.sshdomain}"] + docker_container = os.environ.get("CHATMAIL_DOCKER") + if docker_container: + command += ["docker", "exec", docker_container] [command.append(arg) for arg in getjournal.split()] self.popen = subprocess.Popen( command,