Repository navigation
fix(docker): document container_status() and quote its argument - #1982
Conversation
container_status() returns false for any `docker inspect` failure, not only for a missing container: a daemon that is down or restarting, a socket error or a timeout look the same. Document that contract, and that 'running' includes paused and restarting containers while 'exited' covers created, exited and dead ones, so callers don't read false as "doesn't exist". The name is now passed through escapeshellarg(). Every caller passes one fixed name or an id from `docker-compose ps -q`, so the results don't change.
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
Problem
EE_DOCKER::container_status()returnsfalsewheneverdocker inspectfails, not only when the container doesn't exist: a daemon that is down or restarting, a socket error or a timeout all returnfalsetoo. Nothing documented that, so a caller can readfalseas "no such container" and act on it (create, skip a stop/remove, report a container as gone). The container name was also interpolated into the shell command unquoted.Change
docker inspect -f '{{.State.Running}}':'running'while it runs, which includes paused and restarting containers;'exited'for created, exited and dead;falsewhen inspect fails for any reason; exits viaEE::error()when docker isn't onPATH. It says that callers acting on absence must check that separately.escapeshellarg(). Every caller in core and the packages passes one fixed container name or an id fromdocker-compose ps -q, so results are unchanged. Return values are unchanged.Core callers:
boot_container()runs the givenup -dcommand onfalse, which is idempotent, so an inspect error there is harmless.GlobalContainers::down_global_containers()skips the stop/remove onfalse, but nothing calls it (the image migration goes throughupgrade_global_service()). No core caller needed a change.Testing
truegivesrunning,falsegivesexited, no-such-object, daemon-down and timeout errors givefalse(unchanged from before); the name reachesdocker inspectas one quoted argument; shell-injection payloads don't reach the shell (this one fails without the change).Summary by CodeRabbit