Repository navigation
fix(engines): Stop refused a containerised engine the dashboard could have stopped itself - #35
Merged
Merged
Conversation
…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
force-pushed
the
fix/container-engine-stop
branch
from
October 29, 2026 10:52
e1e1c1d to
4034873
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What you saw
Correct diagnosis, useless outcome. The engine on
:8000is 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 thedockergroup (Groups: … 988on the running unit, checked) — the dashboard could have stopped it all along, and in fact already reconstructs thedocker runfor these engines.The fix
docker stop --time 15 <id>/proc/<pid>/cgroupof the clicked pid onlydocker stop■ 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, genuinePermissionError, real/proccgroup → container id, realdocker stop, container reachedexited. The serving engine was untouched (/v1/modelsanswered before and after).333 passed, including 6 new tests intests/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 sinceos.getpgidhas no Windows twin.Windows note: the first head commit failed the Windows lane —
_stubpatchedos.getpgidunconditionally 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 deletinggetpgid/killpgfrom theosmodule before the run (1 passed, 5 skipped), so the runner is a confirmation, not a discovery.