Skip to content
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

storage: cleanup staged layer if unused #2390

Merged
merged 2 commits into from
May 16, 2024

Conversation

giuseppe
Copy link
Member

@giuseppe giuseppe commented May 2, 2024

notify c/storage that the staged layer is not used and must be cleaned up on error.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

This works, but it would be easy to forget next time again.

So I’m leaning towards

out, err :=if err != nil { … }
succeeded := false
defer func() {
    if !succeeded { … CleanupStagedLayer … }
}()
…
…diffOutputs =s.lock.Unlock()
succeeded = true
return

If you think that’s never going to be necessary, shrug, this PR is an improvement as is.


But, also, that code path should never be hit. Is that assumption incorrect?

storage/storage_dest.go Outdated Show resolved Hide resolved
@giuseppe
Copy link
Member Author

giuseppe commented May 2, 2024

If you think that’s never going to be necessary, shrug, this PR is an improvement as is.

your version is better, I've fixed it and pushed a new version

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, this is to follow the rules, allowing us to more precisely use locks in containers/storage#1916 .

But right now there’s containers/storage#1916 (comment) , so I’d prefer to wait a bit here until the that question is resolved.

@mtrmac mtrmac added the kind/bug A defect in an existing functionality (or a PR fixing it) label May 13, 2024
@giuseppe
Copy link
Member Author

containers/storage#1916 is merged, can we reconsider this?

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICS, on return from ApplyDiffFromStagingDirectory, the callers can’t tell whether the lock is now unlocked.

But, also, the locks only exist for directories created by MkdirTemp, and the unlock code is ~idempotent, so extra calls of CleanupStagedLayer don’t actually hurt.

LGTM.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
notify c/storage that the staged layer is not used and must be cleaned
up on error.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@TomSweeneyRedHat
Copy link
Member

LGTM
once the tests are hip

@mtrmac mtrmac merged commit 4f07d28 into containers:main May 16, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A defect in an existing functionality (or a PR fixing it)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants