fix(compose): ps_status recognises all daemon-unreachable phrasings & can't hang (#178) - #271
Merged
Merged
Conversation
… can't hang (#178) ps_status previously (1) detected an unreachable daemon by scraping stderr for only the exact substring "cannot connect to the docker daemon", so the "failed to connect to the docker API at ..." phrasing (custom/rootless DOCKER_HOST socket) fell through and was misreported as "not-created"; and (2) ran `docker compose ps` with no timeout, so a wedged-but-reachable daemon or an unresponsive TCP DOCKER_HOST hung ls/status/doctor forever. Now it matches a family of daemon-unreachable stderr markers and runs the probe under a bounded 20s timeout (mirroring builder._DOCKER_INFO_TIMEOUT), catching subprocess.TimeoutExpired and degrading to "docker-unreachable". Scoped to the read-only ps_status probe; lifecycle/streaming verbs are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WmChW67jv2BaPk1a8HreHU
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.
Summary
Fixes #178.
compose.ps_statushad two defects that defeated itsdocker-unreachablevsnot-createdcontract:cannot connect to the docker daemon, so the other CLI phrasing —failed to connect to the docker API at ...(custom/rootless socket viaDOCKER_HOST, Docker Desktop stopped) — fell through and was misreported asnot-created, telling the user the instance was never created when the real fault was daemon connectivity.docker compose pscall carried notimeout=, so a wedged-but-reachable daemon or an unresponsive TCPDOCKER_HOSTmadels/status/doctor(all of which readInstance.status→ps_status) hang forever instead of degrading todocker-unreachable.Changes
ps_statusnow matches a family of daemon-unreachable stderr markers (_DAEMON_UNREACHABLE_MARKERS:cannot connect to the docker daemonorfailed to connect to the docker).timeout=_PS_STATUS_TIMEOUT(20 s, mirroringbuilder._DOCKER_INFO_TIMEOUT);subprocess.TimeoutExpiredis caught and mapped todocker-unreachable.ps_statusprobe — lifecycle/streaming verbs (up/down/logs/build) are intentionally left with an unbounded wait.Tests
New cases in
tests/test_compose.py:failed to connect to the docker API at ...stderr →docker-unreachable(pins the misclassification regression).subprocess.TimeoutExpired→docker-unreachable(covers the new timeout branch).timeout=is forwarded todocker compose ps.Existing
cannot connect to the docker daemonandnot-createdpaths are unchanged. Full suite green at 100% line+branch coverage locally (ruff,mypy --strict,pytest).🤖 Generated with Claude Code
https://claude.ai/code/session_01WmChW67jv2BaPk1a8HreHU
Generated by Claude Code