Skip to content

fix(docker): stop running container before removing it in DeleteDevContainer - #1100

Merged
skevetter merged 3 commits into
mainfrom
fix/docker-delete-stop-before-remove
Aug 18, 2026
Merged

skevetter merged 3 commits into
mainfrom
fix/docker-delete-stop-before-remove

Conversation

@skevetter

Copy link
Copy Markdown
Contributor

Root cause

CI job up-provider-podman-rootful-features (rootful) failed (run 32075302649):

  1. During the "should use custom image" spec, the container's SSH tunnel died abnormally mid-command (transient, expected occasionally on loaded CI runners).
  2. The spec's DeferCleanup called workspace delete → dockerDriver.DeleteDevContainer, which called podman rm <id> directly, without stopping the container first. The container was still running (only the exec session into it had died), so podman rm (non-force) refused with "container is running" and cleanup failed.
  3. Ginkgo retried the whole spec, but the container was never removed — it leaked, still running, consuming resources on the runner.
  4. Every subsequent podman command in the same job (including an unrelated sudo podman ps in the next spec) then slowed dramatically under the resulting contention, blowing through spec timeouts, and the whole test binary eventually panicked with test timed out after 10m0s.

pkg/driver/docker/lifecycle.go's DeleteDevContainer was the only driver skipping stop-before-remove — both pkg/driver/apple/lifecycle.go and pkg/driver/microsandbox/microsandbox.go already stop a running container before removing it.

Fix

DeleteDevContainer now stops a running container before removing it, mirroring the Apple driver's pattern: a stop failure is logged but removal is still attempted.

Verification

  • Added TestDeleteDevContainer_StopsRunningContainerBeforeRemove, which fails against the pre-fix code with the exact error class seen in CI (cannot remove running container) and passes with the fix.
  • go build ./... and go test ./pkg/driver/docker/... pass.
  • golangci-lint run ./pkg/driver/docker/... clean (pre-existing, unrelated cyclop finding in runPreflight untouched).

…ntainer

podman/docker refuse to `rm` a running container. The Apple and
microsandbox drivers already stop before removing; the docker driver
skipped this, so a workspace left running after an aborted tunnel
(e.g. a killed exec session) failed to delete and leaked, cascading
into resource contention and cascading timeouts in
up-provider-podman-rootful-features CI runs.

Mirrors the Apple driver's forgiving pattern: a stop failure is
logged but removal is still attempted.
@netlify

netlify Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 7880bec
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a83b3beb977750008eff930

@netlify

netlify Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 7880bec
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a83b3bffd50d00007fc43a7

@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@skevetter, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

Limit details: You’ve used all 1 included review currently available under your plan.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 34ffa68a-775a-4a36-b966-e9fa6d3f5761

📥 Commits

Reviewing files that changed from the base of the PR and between 54e32f2 and 7880bec.

📒 Files selected for processing (2)
  • pkg/driver/docker/lifecycle.go
  • pkg/driver/docker/lifecycle_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@skevetter
skevetter marked this pull request as ready for review August 18, 2026 00:02
@skevetter
skevetter enabled auto-merge (squash) August 18, 2026 00:02
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 critical

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Security 1 critical

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@skevetter
skevetter disabled auto-merge August 18, 2026 01:22
@skevetter
skevetter merged commit 3f78591 into main Aug 18, 2026
22 checks passed
@skevetter
skevetter deleted the fix/docker-delete-stop-before-remove branch August 18, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant