Skip to content

post: skip sticky disk cleanup when this step reused an existing buildkitd (release/v2) - #137

Merged
bruce-y merged 1 commit into
release/v2from
devin/1788555472-skip-cleanup-on-reused-builder-v2
Sep 8, 2026
Merged

bruce-y merged 1 commit into
release/v2from
devin/1788555472-skip-cleanup-on-reused-builder-v2

Conversation

@bruce-y

@bruce-y bruce-y commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

release/v2 port of #136.

When setup-docker-builder runs more than once in the same job (e.g. a composite action that retries a build and calls setup + build-push per attempt), only the first instance starts buildkitd and mounts /var/lib/buildkit. Later instances detect the running daemon and reuse it (builderMode=existing), and their post step correctly skips shutdown via maybeShutdownBuildkitd() — but it then falls straight into the sync / umount /var/lib/buildkit block while buildkitd is still alive. That unmount fails 3× with target is busy and is reported as BUILDER_CLEANUP, feeding blacksmith_stickydisk_failures_total and the "Docker Setup High Failure Count" alert. Post steps run in reverse order, so every reuse instance emits a spurious failure before the owning instance's post finally shuts down and unmounts successfully.

Fix: in the post step, if stateHelper.getBuilderMode() === "existing", skip the whole cleanup + commit-gating block. Unlike v1, v2 already records this mode in state, so no new state key is needed. The structured teardown report is still shipped for that instance (with commitSkipReason=NO_EXPOSE, as today) so the EXISTING builder mode remains visible in telemetry.

if (stateHelper.getBuilderMode() === "existing") {
  core.info("This instance reused a builder started by an earlier setup-docker-builder step; skipping cleanup ...");
  removeTmpDir();
  setCommitSkipped(lifecycle, CommitSkipReason.NO_EXPOSE);
  await shipTeardownReport(lifecycle, exportedBuilds, exposeId);
  reporter.closeBlacksmithAgentClient();
  return;
}

removeTmpDir() and shipTeardownReport() are extracted from the inline post-step code so the early-return path can reuse them. dist/ regenerated via the pre-commit hook.

Link to Devin session: https://app.devin.ai/sessions/b01cb52c7bbb4211ab8557e8e880086d
Open in Devin Desktop: https://app.devin.ai/desktop/session/b01cb52c7bbb4211ab8557e8e880086d?variant=devin
Requested by: @bruce-y


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled. (Staging)


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

…dkitd (release/v2)

When setup-docker-builder runs more than once in a job, only the first
instance starts buildkitd and mounts /var/lib/buildkit. Later instances
(builderMode=existing) already skipped shutdown but still ran the unmount
path while buildkitd was alive, failing with 'target is busy' and
reporting BUILDER_CLEANUP for a disk they do not own. Exit the post step
early in that case; the teardown telemetry report is still shipped.

Co-Authored-By: bruce <[email protected]>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@bruce-y
bruce-y requested a review from piob-io September 4, 2026 21:01
@bruce-y
bruce-y merged commit ded4bfd into release/v2 Sep 8, 2026
13 checks passed
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.

2 participants