Skip to content

post: skip sticky disk cleanup when this step reused an existing buildkitd - #136

Merged
bruce-y merged 1 commit into
mainfrom
devin/1788555138-skip-cleanup-on-reused-builder
Sep 8, 2026
Merged

bruce-y merged 1 commit into
mainfrom
devin/1788555138-skip-cleanup-on-reused-builder

Conversation

@bruce-y

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

Copy link
Copy Markdown
Contributor

Summary

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. Since dc5a171, later instances detect the running daemon and reuse it, and their post step correctly skips shutdown via maybeShutdownBuildkitd() — but it then falls straight into the sync / integrity check / 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 this happens on every reuse instance before the owning instance's post finally shuts down and unmounts successfully. Net effect: the disk was being cleaned up, but each reuse instance emitted a spurious cleanup failure (N-1 false reports per job with N setup invocations, which only happens when earlier attempts failed).

Fix: record reuse in action state and have the post step exit early in that case.

// startBlacksmithBuilder, existing-buildkitd branch
stateHelper.setReusedExistingBuilder(true);
return { addr: null, exposeId: "" };

// post
if (stateHelper.getReusedExistingBuilder()) {
  core.info("This instance reused a builder started by an earlier setup-docker-builder step; skipping cleanup ...");
  removeTmpDir();
  reporter.closeBlacksmithAgentClient();
  return;
}

A dedicated state key is used rather than !getBuildkitdAddr() because the fallback path (sticky disk mounted, buildkitd failed to start) also has no addr but does still need the unmount.

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.


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

…dkitd

When setup-docker-builder runs more than once in a job, only the first
instance starts buildkitd and mounts /var/lib/buildkit. Later instances
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. Record reuse in action state and have the
post step exit early in that case.

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 20:54
@bruce-y
bruce-y merged commit e4c1c00 into main Sep 8, 2026
17 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