Skip to content

Support Windows Named Pipe REDUX#1654

Merged
aaronlehmann merged 1 commit intomoby:masterfrom
dperny:support_windows_named_pipe
Oct 27, 2016
Merged

Support Windows Named Pipe REDUX#1654
aaronlehmann merged 1 commit intomoby:masterfrom
dperny:support_windows_named_pipe

Conversation

@dperny
Copy link
Copy Markdown
Collaborator

@dperny dperny commented 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 #941. This is a separate commit because a rebase was prohibitively difficult

I can break this into two different commits, one with him as author, if he approves, so he gets git credit for his added code. I did this locally but then reverted it because of potential legal issues (and I didn't want to put words in his mouth).

Signed-off-by: Drew Erny drew.erny@docker.com

@dperny
Copy link
Copy Markdown
Collaborator Author

dperny commented Oct 17, 2016

I have NO IDEA if this works. Theoretically you should just be able to pass --listen-addr npipe://whatever/goeshere and it should work? I don't have Windows to test it on.

@dperny
Copy link
Copy Markdown
Collaborator Author

dperny commented Oct 17, 2016

/cc @aluzzardi @mavenugo

@dperny
Copy link
Copy Markdown
Collaborator Author

dperny commented Oct 18, 2016

This is totally broken, actually. please stand by.

@dperny dperny force-pushed the support_windows_named_pipe branch from 498c6e2 to f9eaa76 Compare October 18, 2016 18:20
@dperny
Copy link
Copy Markdown
Collaborator Author

dperny commented Oct 18, 2016

This should work now, PTAL.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Oct 18, 2016

Current coverage is 55.98% (diff: 25.00%)

Merging #1654 into master will increase coverage by 0.22%

@@             master      #1654   diff @@
==========================================
  Files            89         89          
  Lines         14598      14494   -104   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits           8139       8114    -25   
+ Misses         5372       5297    -75   
+ Partials       1087       1083     -4   

Sunburst

Powered by Codecov. Last update fa14f4a...a1c8923

// we need to use named pipes `npipe` as the control api instead.
// so, here, we just use a hack. if the protocol is says unix but we're on
// windows, just use a named pipe anyway. problem changed.
if proto == "unix" {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Personally I don't think this hack belongs here.

Just make this a ListenLocal function that isn't passed a protocol. The windows version should use winio.ListenPipe and the unix version should use Listen("unix", addr).

For now the manager can special-case "unix" as needing a call to ListenLocal, but I think we should immediately refactor the manager to remove the ProtoAddr map so the hack isn't necessary.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree that this should be done, but then it leads itself right into unrolling that loop and doing a big refactor of the listening code, which is a headache all of its own. I'd say anything more than a straight API substitution is out of scope.

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.

I think that loop could be easily unrolled - right now most of the content is unix specific anyway and the tcp side is pretty straightforward:

if _, ok := config.ProtoListener["unix"]; !ok {
  l, err := xnet.ListenLocal(config.ProtoAddr["unix"])
  ...
  // No need for proto == "unix"
  if unwrappedErr == syscall.EADDRINUSE {
  }
  ...  
}

if _, ok := config.ProtoListener["tcp"]; !ok {
  // Note no need to use xnet here
  ... := net.Listen("tcp", config.ProtoAddr["unix"])
  // No need for weird if proto == "tcp"
  tcpAddr = l.Addr().String()  
}

Thoughts?

I think that loop can be just unrolled to two if and we don't have to mess with proto == [tcp|unix] in the loop, just add the statements

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.

To @dperny's point - I don't know if that should be done in a separate PR to keep the scope of this one simple.

@dperny dperny force-pushed the support_windows_named_pipe branch from 1aa0a20 to 2120b77 Compare October 19, 2016 21:09
@dperny
Copy link
Copy Markdown
Collaborator Author

dperny commented Oct 19, 2016

This is the docker/docker change.

https://github.com/dperny/docker/tree/swarm_support_npipe

return nil, errors.Wrap(err, "failed to create socket directory")
// don't create a socket directory if we're on windows. we used named pipe
if runtime.GOOS != "windows" {
err := os.MkdirAll(filepath.Dir(config.ProtoAddr["unix"]), 0700)
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.

Do we need MkdirAll for npipes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

oohhhhh that's not good. that's wrong. that should be GOOS == "windows"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

no it definitely is supposed to be GOOS != "windows". if the OS is not windows we create a directory. we don't need to make a directory for windows named pipes; they exist in their own, like, space.

@dperny dperny force-pushed the support_windows_named_pipe branch from 6d5dce7 to 2a31308 Compare October 20, 2016 20:55
@aluzzardi
Copy link
Copy Markdown
Member

aluzzardi commented Oct 20, 2016

Not a fan of xnet (to have an extra package) ...

What if we had a manager.listenLocal() function defined in manager_{unix,windows}.go instead?

@aaronlehmann ?

@dperny
Copy link
Copy Markdown
Collaborator Author

dperny commented Oct 20, 2016

We also have a dialer function, which is called from node/node.go. The benefit of this structure is that both platform-specific network functions are in the same place.

@dperny dperny force-pushed the support_windows_named_pipe branch from 2a31308 to 8b2bc1d Compare October 24, 2016 21:57
@dperny dperny changed the title [WIP] Support Windows Named Pipe REDUX Support Windows Named Pipe REDUX Oct 24, 2016
@dperny
Copy link
Copy Markdown
Collaborator Author

dperny commented Oct 24, 2016

i have no idea what i broke.

@aaronlehmann
Copy link
Copy Markdown
Collaborator

The integration tests have been acting up recently. It's probably not your fault.

Adds support for windows named pipes by adding an xnet package
containing functions for opening platform-agnostic local sockets

Signed-off-by: Drew Erny <drew.erny@docker.com>
@dperny dperny force-pushed the support_windows_named_pipe branch from 8b2bc1d to a1c8923 Compare October 26, 2016 20:59
@dperny
Copy link
Copy Markdown
Collaborator Author

dperny commented Oct 26, 2016

@aaronlehmann @aluzzardi updated, PTAL

@aaronlehmann
Copy link
Copy Markdown
Collaborator

LGTM

@aaronlehmann
Copy link
Copy Markdown
Collaborator

Merging this to make way for additional changes.

@aaronlehmann aaronlehmann merged commit 056b833 into moby:master Oct 27, 2016
@dperny dperny deleted the support_windows_named_pipe branch May 3, 2019 18:51
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.

5 participants