Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Support Windows Named Pipe for Swarm Mode#27838

Merged
thaJeztah merged 1 commit into
moby:mastermoby/moby:masterfrom
dperny:swarm_support_npipedperny/docker:swarm_support_npipeCopy head branch name to clipboard
Nov 2, 2016
Merged

Support Windows Named Pipe for Swarm Mode#27838
thaJeztah merged 1 commit into
moby:mastermoby/moby:masterfrom
dperny:swarm_support_npipedperny/docker:swarm_support_npipeCopy head branch name to clipboard

Conversation

@dperny

@dperny dperny commented Oct 27, 2016

Copy link
Copy Markdown
Contributor

- What I did

As of moby/swarmkit#1654, the swarmkit manager can now be communicated with over windows named pipe on a windows system. This alters the docker daemon to take advantage of this capability. This change is one small step toward supporting Windows with Docker Swarm mode.

- How I did it

This PR introduces a small change to the manager init process to pass in a windows-specific named pipe name instead of a unix socket directory. It also vendors in the latest swarmkit commit with this named pipe functionality. Again, note, this change includes vendoring of docker/swarmkit

- How to verify it

Build Docker on Windows. Do docker swarm init. Note how instead of failing to even get started, the manage gets all the way to NetworkAllocator before panicking. The fact that we get this far means the change works. With some out-of-scope patches applied, this crash is averted and swarmkit manager accepts commands over the named pipe.

- Description for the changelog

Docker daemon now communicates with Swarmkit over Named Pipe on Windows.

- A picture of a cute animal (not mandatory but encouraged)

This is the world's oldest manatee. His name is Snooty and he is 68 years old. He will be in the Guinness Book of World Records.

image

@LK4D4

LK4D4 commented Oct 27, 2016

Copy link
Copy Markdown
Contributor

experimental failures looks unrelated
ping @tiborvass @anusha-ragunathan

@tiborvass

Copy link
Copy Markdown
Contributor

@LK4D4 CI is green :)

@thaJeztah

Copy link
Copy Markdown
Member

Looks like this needs a rebase now @dperny 😢

@dperny
dperny force-pushed the swarm_support_npipe branch from a446175 to 32993a2 Compare October 31, 2016 15:19
@dperny

dperny commented Oct 31, 2016

Copy link
Copy Markdown
Contributor Author

all squared away @thaJeztah 😎

(note, i reordered these commits. it makes more sense imhoirl to put the swarm revendoring BEFORE the update; this makes every commit a valid build.)

@thaJeztah

Copy link
Copy Markdown
Member

ping @jhowardmsft @friism @johnstep PTAL

@thaJeztah thaJeztah added this to the 1.13.0 milestone Oct 31, 2016

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.

Probably not an issue, since win.ListenPipe calls CreateFile, which should never return EADDRINUSE. If it did, this os.Remove call would try to remove the named pipe with DeleteFile, which will fail. The pipe will not be deleted until the last handle is closed. Therefore, this code path does not apply to Windows.

@lowenna

lowenna commented Oct 31, 2016

Copy link
Copy Markdown
Member

Where the listener itself created? I'm wondering if an ACL is set appropriately on the pipe? As by default it will be ACL'd to LocalSystem when dockerd is running as a (Windows) service.

@johnstep

johnstep commented Oct 31, 2016

Copy link
Copy Markdown
Member

@jhowardmsft Good point; it is passing nil right now, which results in NULL passed to CreateNamedPipe. This will work in testing, if running dockerd.exe directly, elevated, since the default security descriptor grants Administrators write access.

Note: The listener is created here: https://github.com/docker/docker/pull/27838/files#diff-9a7ebccfca7787cfcbb7a0dc051c6d65R15

@johnstep

Copy link
Copy Markdown
Member

@jhowardmsft Hmm, dockerd.exe, started as a service, runs as system for me:

$ cdb -pvr -pn dockerd.exe -c "!token -n;q" | findstr S-
User: S-1-5-18 (Well Known Group: NT AUTHORITY\SYSTEM)
 00 S-1-5-32-544 (Alias: BUILTIN\Administrators)
 01 S-1-1-0 (Well Known Group: localhost\Everyone)
 02 S-1-5-11 (Well Known Group: NT AUTHORITY\Authenticated Users)
 03 S-1-16-16384 (Label: Mandatory Label\System Mandatory Level)
Primary Group: S-1-5-18 (Well Known Group: NT AUTHORITY\SYSTEM)
Integrity Level: S-1-16-16384

$ sc qc docker
[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: docker
        TYPE               : 10  WIN32_OWN_PROCESS
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : C:\Program Files\Docker\dockerd.exe --run-service
        LOAD_ORDER_GROUP   :
        TAG                : 0
        DISPLAY_NAME       : Docker
        DEPENDENCIES       :
        SERVICE_START_NAME : LocalSystem

Therefore, the security descriptor is fine. Is it supposed to run as system?

@lowenna

lowenna commented Oct 31, 2016

Copy link
Copy Markdown
Member

That wasn't I meant. It is supposed to be LocalSystem. I was questioning the ACL on the swarm named pipe.

@johnstep

johnstep commented Oct 31, 2016

Copy link
Copy Markdown
Member

@jhowardmsft So long as docker.exe is running elevated, I think it should be able to connect, but I will verify. Are there cases where the client runs without Administrators enabled in its token?

@lowenna

lowenna commented Oct 31, 2016

Copy link
Copy Markdown
Member

Absolutely - in fact I would strongly recommend the client is not run elevated, and the daemon started with the -G flag (or equivalent in the service config)

@johnstep

johnstep commented Oct 31, 2016

Copy link
Copy Markdown
Member

@jhowardmsft Ah, that is great, thanks! In that case, it sounds like the security descriptor should be created from the same SDDL generated here:

https://github.com/docker/docker/blob/b248de7e332b6e67b08a8981f68060e6ae629ccf/pkg/listeners/listeners_windows.go#L26-L36

Is that what you expect?

@lowenna

lowenna commented Oct 31, 2016

Copy link
Copy Markdown
Member

I believe so, but then again I'm not sure what is expected to be able connect to the 'swarm' pipe.

@dperny

dperny commented Oct 31, 2016

Copy link
Copy Markdown
Contributor Author

So Swarm is a nearly stand-alone process that receives all of its commands over unix socket. The docker daemon is the ONLY thing that should connect to the swarm pipe right now.

I feel like it's worth noting that I was sort of conscripted to fix this bug and so while I'm enjoying working on it, I'm also not quite sure about things like security implications. If you think things should be done a different way than they're already being done, you probably know better than me, but I'll need direct instruction on what needs to be changed and how I can check that I changed it right.

@lowenna

lowenna commented Oct 31, 2016

Copy link
Copy Markdown
Member

I would be inclined to say that the ACL should match the +administrators for the named pipe the engine listens to. But specifically NOT the block of code https://github.com/docker/docker/blob/b248de7e332b6e67b08a8981f68060e6ae629ccf/pkg/listeners/listeners_windows.go#L28-L36, but otherwise the same.

@dperny

dperny commented Oct 31, 2016

Copy link
Copy Markdown
Contributor Author

Alright, I'll work on getting that squared away. It will probably require a change in Swarmkit as well.

@dperny

dperny commented Nov 1, 2016

Copy link
Copy Markdown
Contributor Author

@jhowardmsft I'm sorry, I don't quite understand. what's the difference between that block of code is doing and what I should be doing?

As an aside, the suggested change does not affect the docker/docker portion of this PR at all; it requires a new PR into swarmkit. It's my opinion that right now this PR can be merged as-is, as long as a swarmkit PR goes through and is vendored before 1.13

@lowenna

lowenna commented Nov 1, 2016

Copy link
Copy Markdown
Member

You want these bits. Not the if socketGroup != "" {....} block.

        // allow Administrators and SYSTEM
        sddl := "D:P(A;;GA;;;BA)(A;;GA;;;SY)"
        c := winio.PipeConfig{
            SecurityDescriptor: sddl,
            MessageMode:        true,  // Use message mode so that CloseWrite() is supported
            InputBufferSize:    65536, // Use 64KB buffers to improve performance
            OutputBufferSize:   65536,
        }
        l, err := winio.ListenPipe(addr, &c)


@dperny

dperny commented Nov 1, 2016

Copy link
Copy Markdown
Contributor Author

Thanks! This change is definitely going to be in github.com/docker/swarmkit/xnet for now, and will require no modification this PR. The Swarmkit API is not changing.

Signed-off-by: Drew Erny <drew.erny@docker.com>
@dperny
dperny force-pushed the swarm_support_npipe branch from 32993a2 to 5b6c565 Compare November 2, 2016 20:48
@dperny

dperny commented Nov 2, 2016

Copy link
Copy Markdown
Contributor Author

Rebased onto master, dropped the vendor commit because master now has swarmkit vendored far enough.

@johnstep johnstep left a comment

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.

LGTM

@aluzzardi

Copy link
Copy Markdown
Member

LGTM

@lowenna

lowenna commented Nov 2, 2016

Copy link
Copy Markdown
Member

LGTM (although not tested). Can you open a PR to re-vendor the updated swarmkit too (or add a commit for it here again)?

@aaronlehmann

Copy link
Copy Markdown

Can you open a PR to re-vendor the updated swarmkit too (or add a commit for it here again)?

#27995 has it. Rebasing should do it, unless this has already been rebased since that was merged.

@lowenna

lowenna commented Nov 2, 2016

Copy link
Copy Markdown
Member

@aaronlehmann Nice 👍

@thaJeztah

Copy link
Copy Markdown
Member

looks like it's ready to merge

@thaJeztah
thaJeztah merged commit ed1d57c into moby:master Nov 2, 2016
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.