Skip to content
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

Merged
merged 1 commit into from Jul 5, 2018

Conversation

cpuguy83
Copy link
Member

@cpuguy83 cpuguy83 commented Jul 2, 2018

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

// (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
Copy link
Contributor

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?

Copy link
Contributor

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).

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

if perr.Err != syscall.ENOTDIR {
return "", errors.Wrapf(err, "error while creating mount source path '%s'", m.Source)

if !m.DisableBindmountAutoCreate {
Copy link
Contributor

@kolyshkin kolyshkin Jul 2, 2018

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>
@cpuguy83 cpuguy83 force-pushed the fix_bindmount_src_create_race branch from 5db1590 to 1caeb79 Compare July 2, 2018 20:42
@codecov
Copy link

codecov bot commented Jul 2, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@b0e6eed). Click here to learn what that means.
The diff coverage is 0%.

@@            Coverage Diff            @@
##             master   #37378   +/-   ##
=========================================
  Coverage          ?   34.95%           
=========================================
  Files             ?      610           
  Lines             ?    44862           
  Branches          ?        0           
=========================================
  Hits              ?    15682           
  Misses            ?    27065           
  Partials          ?     2115

Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐯

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants