Skip to content

post-step: keep committing the sticky disk when buildkitd is already gone; disable in-use pruning - #130

Open
piob-io wants to merge 1 commit into
release/v2from
devin/1788364241-v2-prune-inuse-commit-gating
Open

post-step: keep committing the sticky disk when buildkitd is already gone; disable in-use pruning#130
piob-io wants to merge 1 commit into
release/v2from
devin/1788364241-v2-prune-inuse-commit-gating

Conversation

@piob-io

@piob-io piob-io commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to useblacksmith/buildkit#34 for the v2 action. Fixes the failure mode where a job builds and pushes fine but the post-step skips the sticky-disk commit ("Skipping sticky disk commit due to cleanup error"), leaving the cache frozen on the previous snapshot.

Chain being broken: user runs buildx prune --all --keep-storage N in-job → forked buildkitd prunes a parent layer whose children survive → the post-step's diagnostic buildctl du nil-derefs in DiskUsage and buildkitd dies → pkill -TERM buildkitd exits 1 → cleanupError set → commit skipped.

buildkitd.toml (writeBuildkitdTomlFile): add pruneInUse = false under [worker.oci]. With buildkit#34 this selects upstream leaf-first prune semantics for v2, so a size-bounded prune can no longer remove a still-referenced parent. buildkitd builds that don't know the key ignore it. v1 (main) is untouched and keeps the current in-use pruning via the daemon default.

Commit gating (shutdownBuildkitd, maybeShutdownBuildkitd):

// shutdown.ts
export async function shutdownBuildkitd(): Promise<boolean>
  // pkill -TERM exit 1 (no process)  -> warn, return false   (was: throw)
  // pkill -KILL exit 1 (raced exit)  -> return true          (was: throw)
  // graceful / real SIGKILL          -> return true

// main.ts post-step
const wasRunning = await shutdownBuildkitd();
if (!wasRunning) { warn; await logBuildkitdLogTail(); return; }  // cleanup continues

buildctl du was already diagnostic-only (logBuildCacheContents catches). Only sync / unmount / post-unmount flush failures set cleanupError now, i.e. the commit is gated on filesystem safety, not on whether the daemon happened to still be alive.

Cleanup: remove the dead pruneBuildkitCache helper (+ its tests) and the stale max-cache-size-mb input docs — v2's action.yml has no such input; README now points users at buildkitd GC instead of in-job prune.

Tests: shutdown.test.ts (graceful → true, already-gone → false without throwing, other pkill errors rethrown); writeBuildkitdTomlFile asserts pruneInUse = false + GC in the generated TOML. dist/ rebuilt.

Link to Devin session: https://app.devin.ai/sessions/5c8deaae10f14cf49877e6f03ff873f9
Open in Devin Desktop: https://app.devin.ai/desktop/session/5c8deaae10f14cf49877e6f03ff873f9?variant=devin
Requested by: @piob-io


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

…gone; disable in-use pruning

Write pruneInUse = false into buildkitd.toml so a customer-run
`prune --all --keep-storage` uses upstream leaf-first semantics and can no
longer remove a parent layer out from under its children (which leaves
DiskUsage with a dangling parent and crashes the daemon).

Make shutdownBuildkitd report whether a daemon was actually running:
`pkill` exiting 1 means buildkitd already exited, which is not a cleanup
failure. The post-step logs the buildkitd tail and continues with
sync/unmount and the sticky disk commit; only sync/unmount/flush failures
still skip the commit.

Drop the stale max-cache-size-mb docs and the unused pruneBuildkitCache
helper from the v2 branch; v2 relies on buildkitd GC instead.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@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

@piob-io
piob-io requested a review from bruce-y September 2, 2026 18:53
@piob-io
piob-io marked this pull request as ready for review September 2, 2026 18:54
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