-
Notifications
You must be signed in to change notification settings - Fork 247
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
API break: Remove Lockfile.Locked #1399
Conversation
Signed-off-by: Miloslav Trmač <[email protected]>
This should very slightly improve efficiency because we no longer take the lock’s state mutex to determine if we can write to the store. |
Signed-off-by: Miloslav Trmač <[email protected]>
Signed-off-by: Miloslav Trmač <[email protected]>
@@ -302,17 +307,19 @@ func (r *containerStore) Load() error { | |||
r.bylayer = layers | |||
r.byname = names | |||
if needSave { | |||
if !lockedForWriting { | |||
// Eventually, the callers should be modified to retry with a write lock, instead. | |||
return errors.New("container store is inconsistent and the current caller does not hold a write lock") |
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.
How can callers know when they need to try again? I mean how to distinguish this error (which requires retry) from any other? I see ErrDuplicateImageNames in layerStore.Load()
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.
They can’t, currently.
I plan to add that (“try again”, instead of callers hard-coding specific error values) both to load
and the callers simultaneously.
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 retries will be added in #1407 .
Please don’t merge until this is proven not to break Buildah and Podman tests: |
Signed-off-by: Miloslav Trmač <[email protected]>
DO NOT MERGE: Vendor containers/buildah#4350 Remove uses of Lockfile.Locked(): One of them is entirely unnecessary, and the other one is avoidable. [NO NEW TESTS NEEDED] Signed-off-by: Miloslav Trmač <[email protected]>
Signed-off-by: Miloslav Trmač <[email protected]>
Buildah tests succeeded; Podman failures seem unrelated. |
This will replace Lockfile.Locked for the sanity-checking purposes. It is, just like Locked never was, NOT a way for a caller to check the current state. Hence the panic() instead of an error return. Signed-off-by: Miloslav Trmač <[email protected]>
.Locked() will be going away. These are just smoke-tests, so use the .Assert* methods (which are not usable with other concurrent users). The AssertLockedForWriting() tests probably don't work on Windows, but that was the case previously as well. Signed-off-by: Miloslav Trmač <[email protected]>
Instead, have the callers of ReloadIfChanged provide the locking state. Signed-off-by: Miloslav Trmač <[email protected]>
Instead, have the callers of ReloadIfChanged provide the locking state. Signed-off-by: Miloslav Trmač <[email protected]>
Instead, have the callers of ReloadIfChanged provide the locking state. Signed-off-by: Miloslav Trmač <[email protected]>
It is fundamentally incorrect, and no users are remaining. Signed-off-by: Miloslav Trmač <[email protected]>
Signed-off-by: Miloslav Trmač <[email protected]>
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.
LGTM
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.
LGTM
As detailed in #1388,
Lockfile.Locked()
does not return the right values if there are multiple users of the same lock within a single process.So, replace the users by callers correctly tracking locking state; and add
LockFile.AssertLocked
andLockfile.AssertLockedForWriting
purely for diagnostic purposes. These functions can trigger a panic in clearly invalid situations, but can’t be used by callers to avoid tracking state correctly. That’s a bit risky, so I’ll at least trigger Buildah and Podman CI runs with this changeFollowing the precedent of #1376 , this removes the
Locked
method, breaking API of c/storage.See individual commit messages for details.
Fixes #1388 (and makes another small step towards fixing #1136; the relevant places are now annotated).