Skip to content

support windows named pipe#941

Closed
chanwit wants to merge 1 commit intomoby:masterfrom
chanwit:windows
Closed

support windows named pipe#941
chanwit wants to merge 1 commit intomoby:masterfrom
chanwit:windows

Conversation

@chanwit
Copy link
Copy Markdown

@chanwit chanwit commented Jun 12, 2016

This PR adds Windows named pipe support for SwarmKit to allow running a Worker on Windows and also forming a cluster. Instead of listening a Unix socket, this PR uses Microsoft's go-winio to start a named pipe server.

Tested on a Windows box:

swarmd -l debug -d c:/tmp/node1 --listen-control-api npipe:////./pipe/swarmd.sock --hostname node1 --listen-remote-api 127.0.0.1:4242 --engine-addr <REMOTE DOCKER_HOST>:2375

Then
set SWARM_SOCKET=npipe:////./pipe/swarmd.sock

swarmctl task ls hello_world
ID                         Service        Desired State  Last State              Node
--                         -------        -------------  ----------              ----
33fufdzwywh8p5u9vl8cidy99  hello_world.2  RUNNING        RUNNING 22 minutes ago  node1
ejoseszph4xukbp8e9wkggibt  hello_world.1  RUNNING        RUNNING 22 minutes ago  node1

Updated: to make parsing different kind of protocols (unix, tcp, npipe) being more deterministic, I changed the default sock from /var/... to unix:///var/....

@chanwit
Copy link
Copy Markdown
Author

chanwit commented Jun 12, 2016

Test passed locally (with make coverage) but not sure why the CircleCI failed.

@icecrime
Copy link
Copy Markdown

👍

xnet/util.go Outdated
logrus.Debugf("parse proto addr: %s", s)
parts := strings.SplitN(s, "://", 2)
if len(parts) == 1 {
_, _, err := net.SplitHostPort(parts[0])
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.

How can we assume that an error here means we have a unix address?

Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
@chanwit
Copy link
Copy Markdown
Author

chanwit commented Jun 13, 2016

Thank you @stevvooe I reverted some changes and did a proper error handling.
Could you please review again?

@lowenna
Copy link
Copy Markdown
Member

lowenna commented Jun 23, 2016

@chanwit Are you planning on moving this across to the engine? If not, I'm happy to do it. Thanks :)

@chanwit
Copy link
Copy Markdown
Author

chanwit commented Jun 23, 2016

@jhowardmsft please do it! Let me know when you start the PR, I'll join you there.

@TheJayMann
Copy link
Copy Markdown

I managed to mostly port this to the engine, as shown in the patch I posted on moby/moby#24189. One issue I found with the code in your pull request is that you are passing an empty string as the second parameter to winio.ListenPipe, but when I attempted to compile this, it failed, as it expected a winio.PipeConfig to be passed instead. I attempted to create a PipeConfig based on another example in the engine. Ultimately, I was able to get the daemon to listed to the pipe, but, when creating a cluster, the client hangs, and when connecting a second client, the node sees itself as a manager, but, when listing nodes, lists itself in a down state. My guess is that I used an incorrect security descriptor, but I really don't have much of a clue. I figured I'd mention this here, as the last few comments mention porting this to the engine.

@mwieczorek
Copy link
Copy Markdown

@stevvooe any plan to merge or close this PR? is there anything that can be improved?

ProtoAddr: map[string]string{
"tcp": n.config.ListenRemoteAPI,
"unix": n.config.ListenControlAPI,
"remote": n.config.ListenRemoteAPI,
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.

This doesn't look right. The whole ProtoAddr concept here is a little weird. Both APIs should be mountable to unix or tcp. This makes the mistake of separating control and remote, which is only an implementation detail of docker.

@stevvooe
Copy link
Copy Markdown
Contributor

stevvooe commented Aug 4, 2016

@mwieczorek It will probably need a rebase.

I think the biggest thing that such a PR needs is to ensure that the APIs can be mounted via any listener. I'm not sure if we want to carry windows support -- ideally that would be handled via downstream projects. It also looks like the concept of control and remote being separated is a little hardcoded -- this should be a lot more flexible in practice.

@aaronlehmann
Copy link
Copy Markdown
Collaborator

It also looks like the concept of control and remote being separated is a little hardcoded -- this should be a lot more flexible in practice.

To be fair, I don't think this is at all specific to this PR. The ProtoAddr stuff is part of the existing codebase. It's designed this way because there was a hard requirement that the control API should never be exposed in an unauthenticated way to the outside world.

@stevvooe
Copy link
Copy Markdown
Contributor

stevvooe commented Aug 5, 2016

It's designed this way because there was a hard requirement that the control API should never be exposed in an unauthenticated way to the outside world.

The policy of what is and isn't exposed belongs in docker, not swarmkit.

If we look at the, some really bad things are going on here:

                ProtoAddr: map[string]string{
 -                  "tcp":  n.config.ListenRemoteAPI,
 -                  "unix": n.config.ListenControlAPI,
 +                  "remote":  n.config.ListenRemoteAPI,
 +                  "control": n.config.ListenControlAPI,
                },

SwarmKit should provide components that can be served. The level of coupling is dangerous and limits the ultimate usefulness of the project (granted, grpc suffers from this, as well).

We may want to expose the GRPC some day, and that should be done by changing the listener for that part of the interface. If we intertwine this into a mess of spaghetti, we are just hurting ourselves in the future.

@aluzzardi
Copy link
Copy Markdown
Member

@chanwit @jhowardmsft What are we missing to move this forward? Windows support would be awesome.

@lowenna
Copy link
Copy Markdown
Member

lowenna commented Aug 24, 2016

Time ;) I'm on vacation and when back still have a pile of other things before I could start looking at this.

@aluzzardi aluzzardi self-assigned this Aug 25, 2016
@aluzzardi
Copy link
Copy Markdown
Member

@chanwit Could you please rebase?

I think the engine changes are going to be small - we can carry them over if you don't have the time to do them.

@aaronlehmann @stevvooe: Any objection in merging this? I see your comments @stevvooe but I think those are unrelated from this PR - those problems were already existing and this PR just adds named pipe support.

/cc @friism @icecrime

@aaronlehmann
Copy link
Copy Markdown
Collaborator

I suggest not changing the ProtoAddr keys to control/remote. Instead, add support for a npipe key.

One reason for this is that moving the protocol from the key to the value is effectively an API change - it requires ListenRemoteAPI to be prefixed with tcp://.

@TheJayMann
Copy link
Copy Markdown

@aluzzardi I must also agree with @aaronlehmann regarding changing control/remote back to unix/tcp and adding npipe, as when I attempted earlier to take these changes and apply them to swarmkit in docker, I got issues where at some parts, the tcp:// prefix was not being removed. I was going to make this change myself and reapply it to swarmkit in docker, but hadn't the time to do so.

@chanwit
Copy link
Copy Markdown
Author

chanwit commented Aug 26, 2016

@aluzzardi I'll rebase it and be taking those comments into account

Thank you for all comments. I got some pictures of how to proceed

@aluzzardi
Copy link
Copy Markdown
Member

Thanks @chanwit !

@aluzzardi
Copy link
Copy Markdown
Member

Hey @chanwit, any news regarding this?

No pressure whatsoever but since we'd like to have Windows support we were considering having someone over here carry over the work.

However, before doing that I just want to make sure we are not duplicating efforts.

@chanwit
Copy link
Copy Markdown
Author

chanwit commented Sep 13, 2016

@aluzzardi sorry for being late. I'm eagerly hacking it.
Please name the date and I'll try my best to being on the schedule.

@aluzzardi
Copy link
Copy Markdown
Member

@chanwit No worries! Just wanted to avoid duplicating efforts if we got someone to carry over the changes. Take your time :)

We'd like to get support for 1.13

@JMesser81
Copy link
Copy Markdown

Any updates on this PR? would love to get this merged so that Windows can be one step closer for supporting Swarm

@chanwit
Copy link
Copy Markdown
Author

chanwit commented Oct 12, 2016

@JMesser81 I'm still working on this one. As the milestone stated, it will be available by 1.13.

dperny pushed a commit to dperny/swarmkit-1 that referenced this pull request Oct 17, 2016
Integrate xnet package into the modern code

xnet package was authored by Chanwit Kaewkasi <chanwit@gmail.com>

Integration is largely also based his work PR moby#941.

This is a separate commit because a rebase was prohibitively difficult

Signed-off-by: Drew Erny <drew.erny@docker.com>
dperny added a commit to dperny/swarmkit-1 that referenced this pull request Oct 17, 2016
Integrate xnet package into the modern code

xnet package was authored by Chanwit Kaewkasi <chanwit@gmail.com>

Integration is largely also based his work PR moby#941.

This is a separate commit because a rebase was prohibitively difficult

Signed-off-by: Drew Erny <drew.erny@docker.com>
@aaronlehmann
Copy link
Copy Markdown
Collaborator

Closing this, as the windows named pipe functionality was implemented by #1654.

@TheJayMann
Copy link
Copy Markdown

I really want to be able to try this out with Docker's built in swarm mode. From what I can tell, every so often, the Docker repository does a "revendor." Any chance of knowing that repository is going to do this, or how I can do this myself to test it out?

@friism
Copy link
Copy Markdown

friism commented Oct 28, 2016

@TheJayMann since #1654 was merged, this functionality should now be in the master builds that you can download here: https://master.dockerproject.org/

There probably are some other gotchas, but ping me on michael.friis@docker.com if you get something working!

@aaronlehmann
Copy link
Copy Markdown
Collaborator

It will probably be a few days before it shows up in a master build. As @TheJayMann mentioned, we need to revendor.

There is also this PR that needs to be merged in the docker repository: moby/moby#27838

@friism
Copy link
Copy Markdown

friism commented Oct 28, 2016

argh, sorry - didn't realize this was on swarmkit

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.