Skip to content

fix(engines): Stop refused a containerised engine the dashboard could have stopped itself - #35

Merged
AgentSparko merged 1 commit into
mainfrom
fix/container-engine-stop
Oct 29, 2026
Merged

AgentSparko merged 1 commit into
mainfrom
fix/container-engine-stop

Conversation

@AgentSparko

@AgentSparko AgentSparko commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

What you saw

■ Stop → "process is root-owned — stop it where it was started (docker/systemd)"

Correct diagnosis, useless outcome. The engine on :8000 is a container (rl-flashnext-nvidia-vr8vr8), so the pid the dashboard scanned belongs to root, and a dashboard running as a normal user cannot signal it. But that same user is in the docker group (Groups: … 988 on the running unit, checked) — the dashboard could have stopped it all along, and in fact already reconstructs the docker run for these engines.

The fix

before after
root-owned containerised engine refused, told you to do it yourself docker stop --time 15 <id>
container identity — /proc/<pid>/cgroup of the clicked pid only
engine shutdown quality SIGKILL mid-request graceful stop, GPU released cleanly
not a container (systemd), or no docker "…(docker/systemd)" unchanged honest message, now "…(systemd?)"
confirm dialog "SIGTERMs → SIGKILLs its process group" also says a containerised engine goes through docker stop
success feedback silent toast ■ stopped <name> (docker stop)

The request still carries only a pid — there is no container-name parameter anywhere, so this is not a "stop any container" endpoint.

Proof, not just mocks

A throwaway container really was stopped by the real code path: host pid owned by root, genuine PermissionError, real /proc cgroup → container id, real docker stop, container reached exited. The serving engine was untouched (/v1/models answered before and after).

333 passed, including 6 new tests in tests/test_engine_stop.py (docker called with the pid-derived id; docker failure reported, not swallowed; missing docker → old message; non-container → no docker call at all; handle provenance; worker branch). Process-group tests are marked POSIX-only since os.getpgid has no Windows twin.

Windows note: the first head commit failed the Windows lane — _stub patched os.getpgid unconditionally and the worker-branch test runs on both platforms (AttributeError: <module 'os' (frozen)> has no attribute 'getpgid'). The helper now patches it only where it exists; the Windows condition was reproduced locally by deleting getpgid/killpg from the os module before the run (1 passed, 5 skipped), so the runner is a confirmation, not a discovery.

…sing

A `docker run` engine without a user namespace puts root's process behind the pid the
dashboard scans, so the SIGTERM/SIGKILL that works for a native engine raised
PermissionError and Stop answered "process is root-owned — stop it where it was started
(docker/systemd)". The operator was usually in the docker group at that very moment: the
dashboard had the right tool and handed the job back instead.

Stop now asks docker when the process cannot be signalled. container_id() reads
/proc/<pid>/cgroup for the pid that was clicked — the request still carries a pid and
nothing else, so the button stays an engine stop and not a "stop any container" endpoint.
`docker stop --time 15` is also the better primitive for an engine: it releases the GPU
instead of being SIGKILLed mid-request. When the pid is not a container, or docker cannot
be reached, the old honest message still comes back (reworded to 'systemd?', since docker
is no longer the unhandled case). The worker branch routes through the same helper.

Verified against a real root-owned container, not just mocks: an alpine container's host
pid (owner root) went through stop(), hit the genuine PermissionError path, resolved its
container id from /proc, ran a genuine `docker stop`, and the container reached `exited`.
The serving engine was left alone.

Six tests in tests/test_engine_stop.py: docker is asked with the pid-derived id, a docker
failure is reported instead of claimed as success, missing docker falls back to the old
message, a non-container root process never triggers a docker call, the container handle
can only come from the clicked pid, and the worker branch reaches the helper too. The
process-group half is marked POSIX-only (os.getpgid has no Windows twin). 333 passed.
@AgentSparko
AgentSparko force-pushed the fix/container-engine-stop branch from e1e1c1d to 4034873 Compare October 29, 2026 10:52
@AgentSparko
AgentSparko merged commit e91d99f into main Oct 29, 2026
2 checks passed
@AgentSparko
AgentSparko deleted the fix/container-engine-stop branch October 29, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant