Skip to content

Windows: named pipe mounts#33852

Merged
yongtang merged 1 commit intomoby:masterfrom
jstarks:win_named_pipes
Aug 7, 2017
Merged

Windows: named pipe mounts#33852
yongtang merged 1 commit intomoby:masterfrom
jstarks:win_named_pipes

Conversation

@jstarks
Copy link
Copy Markdown
Contributor

@jstarks jstarks commented Jun 27, 2017

Current insider builds of Windows have support for mounting individual
named pipe servers from the host to the guest. This allows, for example,
exposing the docker engine's named pipe to a container.

This change allows the user to request such a mount via the normal bind
mount syntax in the CLI:

docker run -v \\.\pipe\docker_engine:\\.\pipe\docker_engine <args>

@jstarks
Copy link
Copy Markdown
Contributor Author

jstarks commented Jun 27, 2017

@jhowardmsft PTAL. One thing I didn't add was a version check; if you do this on an older Windows version it will silently ignore the pipe list. If you can suggest a proper version check, I can add one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Constant?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could add a continue after this line, then can remove the else below and out-dent it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is that good go style? I thought since this was an either-or and not a special case + skip situation, the indentation was better.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's fair

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For a version check, you could use system.GetOSVersion() and fail the attempt if build < ~16230. Here might be a good spot and check mps.Length > 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I picked an older build number since the platform support has been available in insider builds for a little while.

@lowenna
Copy link
Copy Markdown
Member

lowenna commented Jun 27, 2017

@johnstep FYI

Copy link
Copy Markdown
Member

@lowenna lowenna 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
Copy Markdown
Member

@lowenna lowenna Jun 27, 2017

Choose a reason for hiding this comment

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

If you mark this 'TODO @jhowardmsft:...', I'll have a better chance of remembering 😊

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think at RTM we just need to search the code base for GetOSVersion and reevaluate all the checks, like we did at Server 2016 release.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if mnt.ReadOnly { errExtraField("ReadOnly") }?

@AkihiroSuda
Copy link
Copy Markdown
Member

  • Please add integration test? (But probably Skip() on current windows CI?)
  • No support for swarm-mode? (can be another PR?)

@AkihiroSuda
Copy link
Copy Markdown
Member

ping @jstarks

Copy link
Copy Markdown
Member

@johnstep johnstep left a comment

Choose a reason for hiding this comment

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

LGTM

@johnstep
Copy link
Copy Markdown
Member

@jstarks, it looks good but will you address the feedback from @AkihiroSuda when you have a chance?

@jstarks jstarks force-pushed the win_named_pipes branch 2 times, most recently from 0318e48 to 4748196 Compare July 28, 2017 01:59
@jstarks
Copy link
Copy Markdown
Contributor Author

jstarks commented Jul 28, 2017

I've pushed a new change that adds an integration test (only runs against RS3) and adds the read-only check, as requested by @AkihiroSuda. Thanks for the suggestions!

Swarm will have to be a separate PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is -> GreaterThan?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How about AtLeast?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IIUC, this requires newer CLI binary? (new test should be an API test)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think this requires a CLI binary change since the bind mount parsing happens on the server side. When I ran this test locally I used an existing CLI.

Regardless, I didn't realize that new tests were at the API level, but I can change+move this if necessary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, please convert the test to API test?
https://forums.mobyproject.org/t/evolution-of-testing-moby/38

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't see any existing API tests that launch a container using the API. They all use the CLI... E.g. TestGetContainersAttachWebsocket. Are there any samples I'm missing?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TestContainersAPICreateMountsTmpfs is one of API tests that is similar to your workload

func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *check.C) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, thanks! Updated. By going through the API directly I was able to find a bug, which is now fixed. I also added some unit tests in volume.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, should'nt we honor the skipAbsolutePathCheck option ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This option is obsolete. I removed it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should do a 2 pass regex parsing because if source is a pipe, dest should be a pipe as well
Is this case tested somewhere btw ? (making sure c:\windows:\.\pipe\docker_engine and \.\pipe\docker_engine:c:\data are invalid)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also with LCOW, how would we do named pipe bindings ? would it be mounted as a domain socket ? (would be awesome to be able to do \.pipe\docker_engine:/var/run/docker.sock mapping)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Named pipe semantics aren't quite the same as Unix socket semantics, unfortunately (e.g. for Docker's named pipe transport we simulate shutdown() by sending a zero-byte write). Given that, we're not going to support this kind of mapping at the platform level. However, we could add a relay mechanism to Docker to support this specific case with the semantics Docker expects.

I'm also thinking about whether we can add AF_UNIX support to Windows directly... then we could change Docker to bind to a Unix socket in Windows by default (as well as the named pipe, for compatibility reasons), and bind mounting this would be more natural and perhaps supportable in the platform. But that wouldn't be for LCOW v1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Regarding two-pass regex, the second pass validation I've just now added to validateMountConfig so that it occurs even if you pass pre-parsed mounts via the API instead of via the raw (-v) field.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed, the validateMountConfig is a better place to validate that.

@dhiltgen looks like the named pipe / unix socket mapping we were counting on to make linux flavored ucp controller run on windows won't be so easy then... We'll still have to rely on tcp/tls to connect to the daemon

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@simonferquel well right now the UCP agent is a windows container, and that can have the daemon pipe mounted in as a pipe.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add failing cases for \.\pipe\foo:c:\data and c:\windows:\.\pipe\foo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Done.

@lowenna
Copy link
Copy Markdown
Member

lowenna commented Aug 1, 2017

Just realized, HCSShim should probably be v0.5.28 rather than .26 (latest pre-Sirupsen), or v0.6.1 if #34272 gets merged first (which is imminent).

@lowenna
Copy link
Copy Markdown
Member

lowenna commented Aug 2, 2017

34272 is merged and HCSShim v0.6.1 is currently in moby/moby master. You can just drop that commit now, and all should be good.

Copy link
Copy Markdown
Contributor

@simonferquel simonferquel left a comment

Choose a reason for hiding this comment

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

LGTM

@jstarks
Copy link
Copy Markdown
Contributor Author

jstarks commented Aug 3, 2017

Fixed gofmt issue that was blocking janky.

Current insider builds of Windows have support for mounting individual
named pipe servers from the host to the guest. This allows, for example,
exposing the docker engine's named pipe to a container.

This change allows the user to request such a mount via the normal bind
mount syntax in the CLI:

  docker run -v \\.\pipe\docker_engine:\\.\pipe\docker_engine <args>

Signed-off-by: John Starks <jostarks@microsoft.com>
@jstarks
Copy link
Copy Markdown
Contributor Author

jstarks commented Aug 7, 2017

Re-pushed to resolve merge conflicts

@lowenna
Copy link
Copy Markdown
Member

lowenna commented Aug 7, 2017

Moving to merge when green CI

@yongtang
Copy link
Copy Markdown
Member

yongtang commented Aug 7, 2017

All Jenkins tests passed. Merging.

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.

9 participants