fix: correct always-true state check in DockerVM.stop()

The condition 'state != "stopped" or state != "exited"' is a tautology,
so the state check was a no-op and a stop request was sent even for a
container that had already exited.

_get_container_state() never returns "stopped" (only "running",
"paused" or "exited"), so the intended negation of the condition used in
_fix_permissions() requires 'and', not 'or' (De Morgan's law).

Added a regression test asserting no stop query is issued for an
already-exited container.
This commit is contained in:
Sanjay Santhanam committed 2026-07-25 10:30:16 -07:00
1 parent 20868aa233
commit 41e8777609
2 files changed
+17 -1

No files matched your search

+1 -1
View File
@@ -869,7 +869,7 @@ class DockerVM(BaseNode):
await self._fix_permissions()
state = await self._get_container_state()
if state != "stopped" or state != "exited":
if state != "stopped" and state != "exited":
# t=5 number of seconds to wait before killing the container
try:
await self.manager.query("POST", "containers/{}/stop".format(self._cid), params={"t": 5})