Skip to content

Use stdlib TLS dialer - #36687

Merged
vdemeester merged 1 commit into
moby:masterfrom
cpuguy83:remove_custom_tls_dialer
Jun 9, 2018
Merged

vdemeester merged 1 commit into
moby:masterfrom
cpuguy83:remove_custom_tls_dialer

Conversation

@cpuguy83

Copy link
Copy Markdown
Member

Since go1.8, the stdlib TLS net.Conn implementation implements the
CloseWrite() interface.

@cpuguy83
cpuguy83 requested a review from dnephin as a code owner March 24, 2018 18:54
@cpuguy83
cpuguy83 force-pushed the remove_custom_tls_dialer branch from 5421290 to 2ec7f9b Compare March 24, 2018 18:54
@cpuguy83
cpuguy83 force-pushed the remove_custom_tls_dialer branch 3 times, most recently from ee4763f to 7396048 Compare March 24, 2018 19:41

@boaz0 boaz0 left a comment

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.

LGTM 👍

@boaz0

boaz0 commented Mar 25, 2018

Copy link
Copy Markdown
Contributor

Um. On powerpc the test failed:

19:48:00 --- FAIL: TestTLSCloseWriter (0.00s)
19:48:00 panic: httptest: failed to listen on a port: listen tcp6 [::1]:0: socket: The requested service provider could not be loaded or initialized. [recovered]
19:48:00 	panic: httptest: failed to listen on a port: listen tcp6 [::1]:0: socket: The requested service provider could not be loaded or initialized.
19:48:00 
19:48:00 goroutine 135 [running]:
19:48:00 testing.tRunner.func1(0xc042337860)
19:48:00 	C:/go/src/testing/testing.go:711 +0x2d9
19:48:00 panic(0x99e2a0, 0xc0424392d0)
19:48:00 	C:/go/src/runtime/panic.go:491 +0x291
19:48:00 net/http/httptest.newLocalListener(0x180000, 0x0)
19:48:00 	C:/go/src/net/http/httptest/server.go:66 +0x205
19:48:00 net/http/httptest.NewUnstartedServer(0xd8ac40, 0xc0424392a0, 0xc042336001)
19:48:00 	C:/go/src/net/http/httptest/server.go:94 +0x2d
19:48:00 net/http/httptest.NewTLSServer(0xd8ac40, 0xc0424392a0, 0xd8448f)
19:48:00 	C:/go/src/net/http/httptest/server.go:161 +0x3c
19:48:00 github.com/docker/docker/client.TestTLSCloseWriter(0xc042337860)
19:48:00 	C:/go/src/github.com/docker/docker/client/hijack_test.go:22 +0xbb
19:48:00 testing.tRunner(0xc042337860, 0xaac8a8)
19:48:00 	C:/go/src/testing/testing.go:746 +0xd7
19:48:00 created by testing.(*T).Run
19:48:00 	C:/go/src/testing/testing.go:789 +0x2e5

@yongtang yongtang 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

@cpuguy83

Copy link
Copy Markdown
Member Author

Really strange powerpc failed like that now it's working but windows is failing the same way.

@cpuguy83

Copy link
Copy Markdown
Member Author

I'm going to assume it's hitting nodes without ipv6 or something.
I'm going to update the test with a manually configured server I can force it to use ipv4.

@cpuguy83
cpuguy83 force-pushed the remove_custom_tls_dialer branch from 7396048 to 5e82141 Compare March 26, 2018 14:23
@codecov

codecov Bot commented Mar 26, 2018 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@5cb95f6). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master   #36687   +/-   ##
=========================================
  Coverage          ?   35.03%           
=========================================
  Files             ?      608           
  Lines             ?    44965           
  Branches          ?        0           
=========================================
  Hits              ?    15754           
  Misses            ?    27106           
  Partials          ?     2105

@cpuguy83

Copy link
Copy Markdown
Member Author

hijack_test.go:27: assertion failed: error is not nil: listen tcp4 127.0.0.1:0: socket: The requested service provider could not be loaded or initialized.

😡

@boaz0

boaz0 commented Mar 26, 2018

Copy link
Copy Markdown
Contributor

Super odd!

@cpuguy83

cpuguy83 commented May 7, 2018

Copy link
Copy Markdown
Member Author

The one CI I want to run won't actually run. Just sitting there:

18:54:52 INFO: Docker info of control daemon
18:54:52 
18:54:52 Containers: 0
18:54:52  Running: 0
18:54:52  Paused: 0
18:54:52  Stopped: 0
18:54:52 Images: 7
18:54:52 Server Version: master-dockerproject-2018-03-18
18:54:52 Storage Driver: windowsfilter
18:54:52  Windows: 
18:54:52 Logging Driver: json-file
18:54:52 Plugins:
18:54:52  Volume: local
18:54:52  Network: ics l2bridge l2tunnel nat null overlay transparent
18:54:52  Log: awslogs etwlogs fluentd gelf json-file logentries splunk syslog
18:54:52 Swarm: inactive
18:54:52 Default Isolation: process
18:54:52 Kernel Version: 10.0 14393 (14393.2125.amd64fre.rs1_release.180301-2139)
18:54:52 Operating System: Windows Server 2016 Datacenter Version 1607 (OS Build 14393.2125)
18:54:52 OSType: windows
18:54:52 Architecture: x86_64
18:54:52 CPUs: 4
18:54:52 Total Memory: 14GiB
18:54:52 Name: jenkins-rs1-7
18:54:52 ID: SVRR:JK6X:JQU5:FHMB:27UY:JJ5F:7WTR:TBXC:J6OF:5X57:OWBA:QRFA
18:54:52 Docker Root Dir: D:\control
18:54:52 Debug Mode (client): false
18:54:52 Debug Mode (server): false
18:54:52 Registry: https://index.docker.io/v1/
18:54:52 Labels:
18:54:52 Experimental: false
18:54:52 Insecure Registries:
18:54:52  127.0.0.0/8
18:54:52 Live Restore Enabled: false
18:54:52 
18:54:52 
18:54:52 INFO: Commit hash is 0a9988b61
18:54:52 INFO: Nuke-Everything...
18:54:52 INFO: Container count on control daemon to delete is 0

@thaJeztah thaJeztah 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

@cpuguy83
cpuguy83 force-pushed the remove_custom_tls_dialer branch 3 times, most recently from af807c5 to 7fb456c Compare May 8, 2018 15:17
@cpuguy83

cpuguy83 commented May 8, 2018

Copy link
Copy Markdown
Member Author

Ok... I have no idea why Windows will not listen on a TCP port.
Is there some security policy involved? Should I just skip the test on Windows?

@cpuguy83

cpuguy83 commented May 8, 2018

Copy link
Copy Markdown
Member Author

I've tried ports in different ranges, it's trying thousands of ports on each test run.

@thaJeztah

Copy link
Copy Markdown
Member

ping @johnstep @salah-khan

@thaJeztah thaJeztah assigned johnstep and unassigned dnephin Jun 6, 2018
@johnstep

johnstep commented Jun 7, 2018 •

Copy link
Copy Markdown
Member

TestTLSCloseWriter fails on Windows when the following line is run first, which can happen even if TestNegotiateAPIVersionEmpty starts later because the failing test pauses and continues:
https://github.com/moby/moby/blob/7fb456cfa719c02b41926a29d9bc70b4a1e33abc/client/client_test.go#L197

$ go test .\client -v -run 'TLS'
=== RUN   TestTLSCloseWriter
=== PAUSE TestTLSCloseWriter
=== CONT  TestTLSCloseWriter
--- PASS: TestTLSCloseWriter (0.01s)
PASS
ok      github.com/docker/docker/client (cached)

$ go test .\client -v -run 'TLS|VersionEmpty'
=== RUN   TestNegotiateAPIVersionEmpty
--- PASS: TestNegotiateAPIVersionEmpty (0.00s)
=== RUN   TestTLSCloseWriter
=== PAUSE TestTLSCloseWriter
=== CONT  TestTLSCloseWriter
--- FAIL: TestTLSCloseWriter (2.17s)
        hijack_test.go:64: assertion failed: error is not nil: listen tcp4 127.0.0.1:9999: socket: The requested service provider could not be loaded or initialized.
FAIL
FAIL    github.com/docker/docker/client 2.236s

It also passes when all tests run except for TestNegotiateAPIVersionEmpty.

It looks like PatchAll should clean up the environment after the test. @dnephin @vdemeester, any idea why this environment stuff might be leading to issues in tests run later?

@dnephin

dnephin commented Jun 7, 2018

Copy link
Copy Markdown
Member

Yes, it looks like there is a problem with that line. It should be deferring the return value of PatchAll. There's a missing () at the end of the line. Right now it's doing nothing for the test, then setting the environment after the test is done.

Does TestTLSCloseWriter depend on the value of DOCKER_API_VERSION ? I guess it should patch as well if an unexpected value can break the test.

@johnstep

johnstep commented Jun 8, 2018

Copy link
Copy Markdown
Member

Thanks, that makes sense.

TestTLSCloseWriter does not depend on the value of DOCKER_API_VERSION but does require that the standard SystemRoot environment variables is set. On Windows, clearing the entire environment is almost always a bad idea as program code and system libraries use some of them.

@johnstep

johnstep commented Jun 8, 2018

Copy link
Copy Markdown
Member

This should pass on Windows once #37236 is merged.

Since go1.8, the stdlib TLS net.Conn implementation implements the
`CloseWrite()` interface.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
thaJeztah force-pushed the remove_custom_tls_dialer branch from 7fb456c to 2ac277a Compare June 8, 2018 21:25
@thaJeztah

Copy link
Copy Markdown
Member

rebased to trigger CI

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