fix: surface Docker connection errors before project load - #13972
fix: surface Docker connection errors before project load#13972scarab-systems wants to merge 2 commits into
Conversation
Signed-off-by: ScarabSystems <scarab.systems@yahoo.com>
| if err := validateFlags(&up, &create); err != nil { | ||
| return err | ||
| } | ||
| return checkDockerConnection(ctx, dockerCli) |
There was a problem hiding this comment.
wonder if this should be inside runUp to avoid connecting to the API before all other validation is completed (at least at a glance it feels like a more natural place to validate the connection)
There was a problem hiding this comment.
I checked this against the command path after your note. runUp is reached after the project has already been loaded by p.WithServices(...); the misleading is a directory error from #13649 is raised during that earlier project-loading path, so moving the ping into runUp would leave the reported case unchanged.
I kept the reachability check after local validation but before project loading, and moved the remaining --attach / --attach-dependencies conflict into validateFlags so that flag-only validation still wins before any Docker API call. Added coverage for both paths. If there is another pre-load owner you prefer for the connection check, I can adjust the placement.
Move the --attach/--attach-dependencies conflict into validateFlags so local flag validation still completes before the Docker API reachability check added for docker#13649. Add a regression test that exercises the conflict without expecting a Docker client call. Verification: - go test ./cmd/compose -run 'TestUp(ReturnsDockerConnectionErrorBeforeConfigPathFallback|ValidatesFlagConflictsBeforeDockerConnection)' -count=1 - go test ./cmd/compose ./pkg/compose -count=1 - make test - make build-and-e2e (fails on base-reproduced e2e tests: TestImageVolume, TestImageVolumeRecreateOnRebuild, TestComposeModel) Signed-off-by: ScarabSystems <scarab.systems@yahoo.com>
What I did
Make
docker compose upcheck Docker API reachability after local flag validation and before project loading. This keeps socket permission or connection errors from being hidden by later config path fallback errors such asis a directory.Moved the
--attach/--attach-dependenciesconflict into local flag validation so it is still reported before any Docker API call.Added regression tests for the empty
COMPOSE_FILEfallback path with a mocked Docker API connection error, and for the attach flag conflict being validated before Docker client use.Related issue
Fixes #13649
Testing
gofmt -s -w cmd/compose/up.go cmd/compose/compose_test.gogo test ./cmd/compose -run 'TestUp(ReturnsDockerConnectionErrorBeforeConfigPathFallback|ValidatesFlagConflictsBeforeDockerConnection)' -count=1go test ./cmd/compose ./pkg/compose -count=1make testCOMPOSE_FILE=""and an inaccessible Docker socket path: surfaced the Docker API connection error instead ofis a directorymake build-and-e2eattempted locally; plugin-mode e2e failed onTestImageVolume,TestImageVolumeRecreateOnRebuild, andTestComposeModel. The same three failures reproduce on unmodifiedorigin/mainin this local environment.