Conversation
Expose a synchronous debug endpoint for unreferenced cache metadata cleanup. Serialize release passes, honor cancellation, propagate storage errors, and guard controller shutdown. Keep automatic cleanup enabled. Related to moby#7175. Signed-off-by: yeaury <yeaury@qq.com>
Yeaury
force-pushed
the
codex-release-unreferenced-cache
branch
from
September 30, 2026 07:56
2a1a8f5 to
17415aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #7175.
Motivation
BuildKit releases unreferenced solver cache metadata during cache manager initialization, after background GC reclaims space through a throttled callback, and after an explicit prune removes records. Operators do not currently have a dedicated endpoint to request this metadata cleanup independently of pruning worker cache.
This adds an on-demand maintenance trigger. It does not solve the underlying cost of ReleaseUnreferenced or move automatic cleanup into maintenance windows.
Changes
POST /debug/cache/release-unreferencedon the existing debug listener. The request runs synchronously, returns204 No Contenton success or500 Internal Server Erroron a release error, and logs elapsed time.ErrNotFoundfor an already-removed result.Waiteven on success.Usage and scope
With the debug listener bound to
127.0.0.1:6060:The debug listener should only be accessible to trusted operators. Automatic cleanup and its existing throttle remain enabled. This endpoint does not prune snapshots or blobs, compact cache.db, shorten bbolt transactions, or require taking buildkitd offline. Cancellation is checked while waiting and between storage operations; an in-flight storage operation is not interrupted. Initialization cleanup runs before the controller is available.
Validation
Passed locally:
go test -race -count=1 ./cmd/buildkitd ./control ./solver/bboltcachestoragego test -race -count=1 ./solver -run '^TestReleaseUnreferenced'go test -count=1 -skip Integration ./solvergo vet ./cmd/buildkitd ./controlgit diff --checkBroader validation did not pass:
TestStaleEdgeMerge, between test comparison and progress updates. The same failure reproduces with the unmodified base version ofsolver/cachemanager.gosupplied via a Go overlay../solveringo vetreports an existing discarded cancellation function atsolver/jobs.go:719, which this change does not modify.make validate-allfailed in the full integration test run. Those integration failures have not been triaged; this PR does not claim full validation passes.