mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
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.
This commit is contained in:
4
.github/workflows/docker-ci.yaml
vendored
4
.github/workflows/docker-ci.yaml
vendored
@@ -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: |
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user