-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Fix uneccessary calls to volume.Unmount()
#27116
Conversation
a5b75a1
to
b9f2869
Compare
ping @tonistiigi @anusha-ragunathan PTAL |
I'm not sure I understand this. Do I understand it correctly that this calls |
@tonistiigi This is the existing behavior. |
Also yes, I'm not sure why it's doing the syscall, I just cleaned up the call path for it. |
b9f2869
to
0481482
Compare
LGTM
|
dda9812
to
37440e7
Compare
are we good on this one @mlaventure @tonistiigi ? |
@cpuguy83 When you do the rebase please add a comment to |
Fixes moby#22564 When an error occurs on mount, there should not be any call later to unmount. This can throw off refcounting in the underlying driver unexpectedly. Consider these two cases: ``` $ docker run -v foo:/bar busybox true ``` ``` $ docker run -v foo:/bar -w /foo busybox true ``` In the first case, if mounting `foo` fails, the volume driver will not get a call to unmount (this is the incorrect behavior). In the second case, the volume driver will not get a call to unmount (correct behavior). This occurs because in the first case, `/bar` does not exist in the container, and as such there is no call to `volume.Mount()` during the `create` phase. It will error out during the `start` phase. In the second case `/bar` is created before dealing with the volume because of the `-w`. Because of this, when the volume is being setup docker will try to copy the image path contents in the volume, in which case it will attempt to mount the volume and fail. This happens during the `create` phase. This makes it so the container will not be created (or at least fully created) and the user gets the error on `create` instead of `start`. The error handling is different in these two phases. Changed to only send `unmount` if the volume is mounted. While investigating the cause of the reported issue I found some odd behavior in unmount calls so I've cleaned those up a bit here as well. Signed-off-by: Brian Goff <[email protected]>
37440e7
to
9a2d0bc
Compare
Updated |
LGTM |
1 similar comment
LGTM |
Fixes #22564
When an error occurs on mount, there should not be any call later to
unmount. This can throw off refcounting in the underlying driver
unexpectedly.
Consider these two cases:
In the first case, if mounting
foo
fails, the volume driver willget a call to unmount (this is the incorrect behavior).
In the second case, the volume driver will not get a call to unmount
(correct behavior).
This occurs because in the first case,
/bar
does not exist in thecontainer, and as such there is no call to
volume.Mount()
during thecreate
phase. It will error out during thestart
phase.In the second case
/bar
is created before dealing with the volumebecause of the
-w
. Because of this, when the volume is being setupdocker will try to copy the image path contents in the volume, in which
case it will attempt to mount the volume and fail. This happens during
the
create
phase. This makes it so the container will not be created(or at least fully created) and the user gets the error on
create
instead of
start
. The error handling is different in these two phases.Changed to only send
unmount
if the volume is mounted.While investigating the cause of the reported issue I found some odd
behavior in unmount calls so I've cleaned those up a bit here as well.
Signed-off-by: Brian Goff [email protected]