Repository navigation
fix(store): Lock a pull's staging directories instead of guessing from the pid #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
hull prunereports a staging directory asRemovedand counts its bytes as reclaimed when another sweeper actually freed it.Failure: prune lists
<digest>.tmp-<pid>withbytesfromDirDiskUsage(prune.go:191-196), then a concurrenthull pull's sweep removes it. Prune'sRemoveStagingDirreachesremoveLockedDir, which now returns nil for a missing directory (pkg/store/image.go:245-247), so prune falls through to prune.go:143 and printsRemoved <name> (leftover from an interrupted pull, 1.2 GB)and adds 1.2 GB to theReclaimedtotal at prune.go:106 — a figure the run did not free. The same happens against a concurrenthull rmi, whoseDeleteImageholds the store lock through its ownRemoveAll(pkg/store/image.go:87-93) while prune'sStagingInFlightcheck at prune.go:179 takes no store lock and sees the unlocked.old-<pid>as prunable.Evidence: the nil-for-missing return at pkg/store/image.go:245-247; the unconditional
Removed/reclaimed +=at cmd/hull/prune.go:143-144.This is the accepted cost of the earlier ENOENT fix, not a reason to undo it — but distinguishing "removed" from "already gone" would keep the printed total honest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The count is right now, but the rmi case in the second half of this comment still shows.
hull rmi golang:1.23-alpine(15,713 entries), withhull prunestarted as soon as the.old-directory appeared:hull pruneAlready gone: sha256:56e4….old-70355 (previous image left behind by an interrupted pull),Reclaimed 0.0 BNothing to prunehull prune --dry-runWould remove sha256:56e4….old-70405 (previous image left behind by an interrupted pull, 258.6 MB),Would reclaim 258.6 MBNothing to pruneNothing is lost, but both lines report an rmi in progress as an interrupted pull, and prune waits on the store lock for the length of the rmi's delete. The pid check this PR replaces skipped the directory because the rmi's pid was alive. Locking the aside directory in
DeleteImagebefore the rename, asswapImagedoes for the displaced image, would letStagingInFlightsee it. That would pair with theremoveLockedDir(aside)suggested for the same rename in the latest review, and would letDeleteImagedelete outside the store lock the wayRemoveStagingDirnow does.