-
Notifications
You must be signed in to change notification settings - Fork 99
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
Log the error from umount when it fails in the background #8561
base: master
Are you sure you want to change the base?
Conversation
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.
I found this logic a bit challenging to follow 😅 (After thinking about it, I see that we will only hit the default case if the context is done and we never read from the channel below, but it took a sec) Is there a way to make this more readable or could you add some comments?
I left a comment since I found any other way to write this code very clunky and repetitive. |
// Since resultCh is unbuffered, this only happens when the outer | ||
// function received from the channel and will return this err. | ||
if err != nil { | ||
log.CtxErrorf(ctx, "Failed to unmount %s: %s", f.mountPath, err) | ||
} else { | ||
log.CtxDebugf(ctx, "Unmounted %s", f.mountPath) | ||
} |
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.
In this case, shouldn't the caller function be responsible for logging the error (i.e. this case
should be empty right?) I think this means we're handling the error in two places
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.
Yeah, I guess what I missed is that firecracker.unmountAllVBDs
skips logging on the first attempt. I'm not sure if this is helpful. If it fails because of a cancelled context, than maybe it makes sense to ignore logging, but if it fails because unmount
failed, it seems useful to know what error was returned.
Previously, we logged
Unmounted %s in the background, even after the context was canceled
, even if thef.server.Unmount()
call failed.Also, there was a logging only race, where the context wouldn't be expired in the child goroutine, so it wouldn't log anything, and then it would be expired in the parent goroutine, which would indicate that we might unmount in the background.