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 linux mount calls not applying propagation type changes #30416

Merged
merged 1 commit into from Feb 15, 2017

Conversation

stevenh
Copy link
Contributor

@stevenh stevenh commented Jan 24, 2017

Propagation type changes must be done as a separate call, in the same way as read only bind mounts.

To fix this:

  1. Ensure propagation type change flags aren't included in other calls.
  2. Only apply read only bind mount changes once.
  3. Make it clear which parameters are ignored by passing them as empty.
  4. Apply propagation type change in a separate call.

Fixes #30415

Signed-off-by: Steven Hartland steven.hartland@multiplay.co.uk

@thaJeztah
Copy link
Member

ping @cpuguy83 @justincormack PTAL

@stevenh
Copy link
Contributor Author

stevenh commented Jan 24, 2017

Not sure the jenkins errors are related to this PR?
Error processing tar file(exit status 1): no such device

@justincormack
Copy link
Contributor

Can we add some tests for these, as clearly there were not sufficient ones before or it would have been noticed...

@stevenh
Copy link
Contributor Author

stevenh commented Jan 24, 2017

@justincormack tests added

@justincormack
Copy link
Contributor

@stevenh the tests seem to be failing...

@stevenh stevenh force-pushed the linux-mount-fixes branch 2 times, most recently from d5c2092 to 73819b4 Compare January 25, 2017 15:22
@stevenh
Copy link
Contributor Author

stevenh commented Jan 25, 2017

I think there may be something kernel / OS specific about slave mount reporting as this latest version works fine here on ubuntu 16 LTS here, need to investigate more.

@stevenh
Copy link
Contributor Author

stevenh commented Jan 26, 2017

The underlying issue was false assumptions about the parent mounts propagation type in the test, locally its was shared on jenkins they must be private, so the resulting Optionals where unstable.

I've restructured the test to start with a source that has known flags, so hopefully it should be good now.

@stevenh
Copy link
Contributor Author

stevenh commented Jan 27, 2017

@justincormack this good for you now?

@LK4D4
Copy link
Contributor

LK4D4 commented Feb 1, 2017

ping @justincormack

@justincormack
Copy link
Contributor

justincormack commented Feb 2, 2017 via email

@LK4D4
Copy link
Contributor

LK4D4 commented Feb 13, 2017

ping @justincormack

func mount(device, target, mType string, flags uintptr, data string) error {
oflags := flags &^ ptypes
if !isremount(device, flags) {
// Initial call applying all none propagation flags.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo, none->non

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

// isremount returns true if either device name or flags identify a remount request, false otherwise.
func isremount(device string, flags uintptr) bool {
switch {
case flags&syscall.MS_REMOUNT != 0, device == "", device == "none":
Copy link
Contributor

Choose a reason for hiding this comment

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

ok, unsure here. Why is device=="" or device="none" a remount? I can mount a tmpfs with these options. Why is presense of MS_REMOUNT not sufficient?

Copy link
Contributor Author

@stevenh stevenh Feb 15, 2017

Choose a reason for hiding this comment

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

The problem with only looking at MS_REMOUNT is that typical use cases don't do this.

An example of this can be seen in sharedsubtree_linux:

Mount(mountPoint, mountPoint, "none", "bind,rw")

These are covered in the test cases so removing the "" and "none" case you'll see the following failures:

--- FAIL: TestMount (0.22s)
    --- FAIL: TestMount/none-bind,slave (0.00s)
        mounter_linux_test.go:82: no such device
    --- FAIL: TestMount/none-bind,rw,slave (0.00s)
        mounter_linux_test.go:82: no such device
    --- FAIL: TestMount/none-bind,ro,slave (0.00s)
        mounter_linux_test.go:82: no such device
--- FAIL: TestSubtreePrivate (0.02s)
        sharedsubtree_linux_test.go:66: no such device
--- FAIL: TestSubtreeShared (0.00s)
        sharedsubtree_linux_test.go:143: no such device
--- FAIL: TestSubtreeSharedSlave (0.00s)
        sharedsubtree_linux_test.go:222: no such device
--- FAIL: TestSubtreeUnbindable (0.00s)
        sharedsubtree_linux_test.go:303: no such device

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes. Could we add a note in the code explaining that as it is non obvious, especially as the pkg/ code is intended for use outside Docker and external users might be confused...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment added.

Propagation type changes must be done as a separate call, in the
same way as read only bind mounts.

To fix this:
1. Ensure propagation type change flags aren't included in other calls.
2. Apply propagation type change in a separate call.

Also:
* Make it clear which parameters are ignored by passing them as empty.
* Add tests to ensure Mount options are applied correctly.

Fixes moby#30415

Signed-off-by: Steven Hartland <steven.hartland@multiplay.co.uk>
@justincormack
Copy link
Contributor

Windows failure unrelated and passed before comments changed.

Copy link
Contributor

@LK4D4 LK4D4 left a comment

Choose a reason for hiding this comment

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

LGTM

@LK4D4 LK4D4 merged commit d52350d into moby:master Feb 15, 2017
@GordonTheTurtle GordonTheTurtle added this to the 1.14.0 milestone Feb 15, 2017
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.

Propagation types to mount.Mount calls aren't processed correctly
7 participants