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 bindmount autocreate race #37378
Conversation
volume/mounts/mounts.go
Outdated
| // (Some are auto-created for backwards-compatability) | ||
| // This is checked on the API but setting this here prevents race conditions. | ||
| // where a bind dir existed during validation was removed before reaching the setup code. | ||
| DisableBindmountAutoCreate bool |
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.
Maybe something simpler, like SkipMountPointCreation or DoNotCreateMountPoint?
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 mean, the name doesn't have to contain BindMount, also it's not clear from yours what is being auto created (a mount point).
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 like it, also makes it more straightforward to just skip setup earlier.
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.
Updated.
volume/mounts/mounts.go
Outdated
| if perr.Err != syscall.ENOTDIR { | ||
| return "", errors.Wrapf(err, "error while creating mount source path '%s'", m.Source) | ||
|
|
||
| if !m.DisableBindmountAutoCreate { |
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.
Maybe
if m.DisableBindmountAutoCreate {
return m.Source, nil
}When using the mounts API, bind mounts are not supposed to be automatically created. Before this patch there is a race condition between valiating that a bind path exists and then actually setting up the bind mount where the bind path may exist during validation but was removed during mountpooint setup. This adds a field to the mountpoint struct to ensure that binds created over the mounts API are not accidentally created. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
5db1590
to
1caeb79
Compare
Codecov Report
@@ Coverage Diff @@
## master #37378 +/- ##
=========================================
Coverage ? 34.95%
=========================================
Files ? 610
Lines ? 44862
Branches ? 0
=========================================
Hits ? 15682
Misses ? 27065
Partials ? 2115 |
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 🐯
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
When using the mounts API, bind mounts are not supposed to be
automatically created.
Before this patch there is a race condition between validating that a
bind path exists and then actually setting up the bind mount where the
bind path may exist during validation but was removed during mountpooint
setup.
This adds a field to the mountpoint struct to ensure that binds created
over the mounts API are not accidentally created.
Closes #37083