Repository navigation
fix(deploy): don't let a failed docker ps pass for 'no containers' - #105
Conversation
Sourcery review of #103. compose_projects swallowed docker ps failures (|| p=""), so a broken daemon made compose_p return 0 without running down: teardowns and failure cleanups looked successful while the containers kept running. Both lookups now capture docker's status before sorting (no reliance on the caller's pipefail), warn and return 1; compose_p captures the lookup result instead of reading a process substitution (whose exit status is lost) and returns 1 without calling compose. docker's own stderr is no longer discarded. Every call site already handles non-zero: teardowns log 'down failed', the health check reports 'docker compose ps failed', diagnostics use || true. Tests: 3 new cases (20/20); all 3 fail against the previous helper.
Reviewer's GuideThe PR makes Docker Compose project discovery fail closed: docker ps errors now produce warnings and non-zero status, and compose_p propagates that failure without invoking compose. Tests add coverage for both lookup paths and confirm failed discovery cannot result in a successful no-op teardown. Sequence diagram for fail-closed Compose project discoverysequenceDiagram
participant Caller
participant compose_p
participant compose_projects
participant Docker
participant Compose
Caller->>compose_p: compose_p(stack, args)
compose_p->>compose_projects: compose_projects(stack)
compose_projects->>Docker: docker ps
alt docker ps succeeds
Docker-->>compose_projects: project output
compose_projects-->>compose_p: project names
loop each project
compose_p->>Compose: docker compose -p project args
Compose-->>compose_p: exit status
end
compose_p-->>Caller: compose result
else docker ps fails
Docker-->>compose_projects: non-zero status and stderr
compose_projects-->>Caller: warning and status 1
compose_projects-->>compose_p: lookup failure
compose_p-->>Caller: status 1
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If the new error propagation mishandles a transient or unexpected docker ps failure, deployment teardown aborts before running Compose, leaving containers or other runtime resources behind and potentially failing the deployment. Reverting restores the previous behavior, but any already-created resource buildup or failed deployment would require manual cleanup or rerunning the operation.
Follow-up to Sourcery's review of #103 (the one finding worth fixing).
Problem
compose_projectsturned a faileddocker psinto an empty result (|| p=""). With the daemon unreachable,compose_p <stack> downran nothing and returned 0. Teardowns and failure cleanups then looked successful while the containers kept running. This dates from #101.Fix
sort(so it doesn't depend on the caller'spipefail), print::warning::<stack>: docker ps failed…and return 1. docker's own stderr is no longer thrown away.compose_pstores the lookup result instead of reading< <(compose_projects …), because a process substitution loses its exit status. On a failed lookup it returns 1 without calling compose.Every call site already handles a non-zero return:
::warning::down faileddocker compose ps failed(it runs underpipefail)|| true, and the helper's own warning still showsVerification
test-compose-project.sh: 20/20. The 3 new cases (either lookup fails;compose_pmakes no call and returns non-zero) all fail against the previous helper.Independent of #104 (no overlapping files).
Summary by Sourcery
Prevent failed Docker project discovery from being mistaken for an empty deployment during teardown and cleanup.
Bug Fixes:
Enhancements:
Tests: