-
Notifications
You must be signed in to change notification settings - Fork 18.9k
cleanup <ID>-init dir and the symlink in <rootdir>/l on failure #49974
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
base: master
Are you sure you want to change the base?
Conversation
|
@thaJeztah @vvoland Could you please review this pr, thanks. |
thaJeztah
left a comment
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.
This seems to make sense, but I'm also slightly wondering if there's possible errors that should be handled differently (although it looks like Removee already handles "not found" errors for at least some implementations).
I could definitely use some more eyes on this to make sure this is the correct approach.
I noticed there's another location where ls.driver.CreateReadWrite is called, and at a quick glance I didn't see a cleanup there as well;
Lines 531 to 536 in c3f484d
| if err := ls.driver.CreateReadWrite(m.mountID, parentID, createOpts); err != nil { | |
| return nil, err | |
| } | |
| if err := ls.saveMount(m); err != nil { | |
| return nil, err | |
| } |
|
|
||
| if err := ls.driver.CreateReadWrite(initID, parent, createOpts); err != nil { | ||
| return "", err | ||
| } |
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.
If we need to remove on any failure, we could use a defer;
- add a
retErroutput variable
func (ls *layerStore) initMount(graphID, parent, mountLabel string, initFunc MountInit, storageOpt map[string]string) (_ string, retErr error) {- define a defer here that attempts to remove on failure;
defer func() {
if retErr != nil {
// cleanup on failure
if err := ls.driver.Remove(initID); err != nil {
log.G(context.TODO()).WithFields(log.Fields{
"initID": initID,
"error": err,
}).Warnf("Removing init layer after failure: %v", retErr)
}
}
}()3a1c2e9 to
43aa788
Compare
|
Done, thank you for your suggestion. @thaJeztah |
43aa788 to
16cf038
Compare
|
cc @dmcgowan ISTR you wanted to have a look |
16cf038 to
3860db0
Compare
|
@thaJeztah Could you please merge this? |
Signed-off-by: zzzzzzzzzy9 <[email protected]>
3860db0 to
4c15a47
Compare
- What I did
This code is used to clean up init when
initMountfails, including the<initID>-initfolder and<rootdir>/lfolder.- How I did it
Use the
ls.driver.Remove()function to cleanup on failure.- How to verify it
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)