Skip to content

test/testenv: fix leaking buildx dial-stdio processes on interrupt#984

Merged
cpuguy83 merged 1 commit intoproject-dalec:mainfrom
invidian:fix-leaking-dial-stdio
Mar 11, 2026
Merged

test/testenv: fix leaking buildx dial-stdio processes on interrupt#984
cpuguy83 merged 1 commit intoproject-dalec:mainfrom
invidian:fix-leaking-dial-stdio

Conversation

@invidian
Copy link
Contributor

@invidian invidian commented Mar 4, 2026

What this PR does / why we need it:
Existing implementation was functional only with modified buildx binary and missed few details.

With this commit, we gracefully handle:

  • buildx binary not starting at all, e.g. caused by bad parameter.
  • automated connection issues without explicit confirmation.
  • interruption of test suite gracefully shuts down docker CLI and buildx processes.
  • Docker daemon restarting or crashing.

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
Closes #974

Special notes for your reviewer:

Copilot AI review requested due to automatic review settings March 4, 2026 14:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the integration test harness’ handling of docker buildx dial-stdio lifecycle so buildx/dial-stdio processes don’t leak when the test suite is interrupted or when the dial command fails early. It updates the Buildx dialer implementation and ensures testEnv.Close() runs on interrupt.

Changes:

  • Reworks dial-stdio wiring to avoid cmd.Wait() hangs when the command exits immediately (e.g., bad args), using StdinPipe() + an explicit copy loop.
  • Adds a connection wrapper that can surface underlying command failures instead of generic pipe errors.
  • Updates TestMain to close the test environment on interrupt using a sync.OnceFunc.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
test/testenv/buildx.go Refactors the buildx dial-stdio exec/stdio handling and introduces process-group configuration.
test/main_test.go Ensures test environment cleanup is triggered on Ctrl+C (interrupt) exactly once.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

test/main_test.go:93

  • Typo in comment: uninteruptable should be uninterruptible.
			// This _should_ trigger builds to cancel naturally and exit the program,
			// but in some cases it may not (due to timing, bugs in buildkit, uninteruptable operations, etc.).
			// Cancel our signal handler so the normal handler takes over from here.

@invidian invidian force-pushed the fix-leaking-dial-stdio branch from 7bc6a11 to 970cc92 Compare March 4, 2026 15:17
@invidian invidian requested a review from Copilot March 4, 2026 15:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Existing implementation was functional only with modified buildx binary
and missed few details.

With this commit, we gracefully handle:
- buildx binary not starting at all, e.g. caused by bad parameter.
- automated connection issues without explicit confirmation.
- interruption of test suite gracefully shuts down docker CLI and buildx
  processes.
- Docker daemon restarting or crashing.

Closes project-dalec#974

Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
@invidian invidian force-pushed the fix-leaking-dial-stdio branch from 2206bd9 to efb4869 Compare March 6, 2026 06:18
@cpuguy83 cpuguy83 merged commit e29fa60 into project-dalec:main Mar 11, 2026
79 of 82 checks passed
@invidian invidian deleted the fix-leaking-dial-stdio branch March 12, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] docker-buildx buildx dial-stdio --progress=plain processes leaks from integration tests when suite is interrupted

3 participants