Skip to content

net/http: k8s spdy TestUpgradeResponse broken in Go 1.11 #26161

@rsc

Description

@rsc

Trying "make test" in Kubernetes with Go 1.11, and ran into a problem in one test.
(All the other unit tests pass, so that's something!)

Note that the test doesn't use hardly any Kubernetes stuff (this is a very low-level package in the Kubernetes graph), so it can be run standalone on Mac etc., using plain go tools:

Using Go 1.10 everything is OK:

$ go get k8s.io/apimachinery/pkg/util/httpstream/spdy
$ go1.10 test k8s.io/apimachinery/pkg/util/httpstream/spdy -v
=== RUN   TestConnectionCloseIsImmediateThroughAProxy
--- PASS: TestConnectionCloseIsImmediateThroughAProxy (0.00s)
=== RUN   TestRoundTripAndNewConnection
=== RUN   TestRoundTripAndNewConnection/redirect_=_false
2018/06/30 11:40:26 http: TLS handshake error from 127.0.0.1:54578: remote error: tls: bad certificate
2018/06/30 11:40:26 http: TLS handshake error from 127.0.0.1:54601: remote error: tls: bad certificate
2018/06/30 11:40:26 http: TLS handshake error from 127.0.0.1:54614: remote error: tls: bad certificate
2018/06/30 11:40:26 [001] WARN: Error copying to client: read tcp 127.0.0.1:54605->127.0.0.1:54602: read: connection reset by peer
2018/06/30 11:40:26 [001] WARN: Error copying to client: read tcp 127.0.0.1:54592->127.0.0.1:54589: read: connection reset by peer
=== RUN   TestRoundTripAndNewConnection/redirect_=_true
2018/06/30 11:40:26 [001] WARN: Error copying to client: read tcp 127.0.0.1:54568->127.0.0.1:54565: read: connection reset by peer
2018/06/30 11:40:26 [001] WARN: Error copying to client: read tcp 127.0.0.1:54564->127.0.0.1:54561: read: connection reset by peer
2018/06/30 11:40:26 http: TLS handshake error from 127.0.0.1:54622: remote error: tls: bad certificate
2018/06/30 11:40:26 http: TLS handshake error from 127.0.0.1:54625: remote error: tls: bad certificate
2018/06/30 11:40:26 http: TLS handshake error from 127.0.0.1:54652: remote error: tls: bad certificate
2018/06/30 11:40:26 [001] WARN: Error copying to client: write tcp 127.0.0.1:54664->127.0.0.1:54665: write: broken pipe
2018/06/30 11:40:26 [001] WARN: Error copying to client: read tcp 127.0.0.1:54662->127.0.0.1:54659: read: connection reset by peer
2018/06/30 11:40:26 [001] WARN: Error copying to client: readfrom tcp 127.0.0.1:54639->127.0.0.1:54640: read tcp 127.0.0.1:54641->127.0.0.1:54638: read: connection reset by peer
--- PASS: TestRoundTripAndNewConnection (0.20s)
    --- PASS: TestRoundTripAndNewConnection/redirect_=_false (0.17s)
    --- PASS: TestRoundTripAndNewConnection/redirect_=_true (0.04s)
=== RUN   TestRoundTripRedirects
2018/06/30 11:40:26 [001] WARN: Error copying to client: write tcp 127.0.0.1:54627->127.0.0.1:54628: write: broken pipe
=== RUN   TestRoundTripRedirects/with_0_redirects
=== RUN   TestRoundTripRedirects/with_1_redirects
=== RUN   TestRoundTripRedirects/with_10_redirects
=== RUN   TestRoundTripRedirects/with_11_redirects
--- PASS: TestRoundTripRedirects (0.01s)
    --- PASS: TestRoundTripRedirects/with_0_redirects (0.00s)
    --- PASS: TestRoundTripRedirects/with_1_redirects (0.00s)
    --- PASS: TestRoundTripRedirects/with_10_redirects (0.00s)
    --- PASS: TestRoundTripRedirects/with_11_redirects (0.00s)
=== RUN   TestUpgradeResponse
--- PASS: TestUpgradeResponse (0.00s)
PASS
ok  	k8s.io/apimachinery/pkg/util/httpstream/spdy	0.271s
$

Using recent master (257d6c4, Thu Jun 28):

$ go test k8s.io/apimachinery/pkg/util/httpstream/spdy -v
=== RUN   TestConnectionCloseIsImmediateThroughAProxy
--- PASS: TestConnectionCloseIsImmediateThroughAProxy (0.00s)
=== RUN   TestRoundTripAndNewConnection
=== RUN   TestRoundTripAndNewConnection/redirect_=_false
2018/06/30 11:42:21 http: TLS handshake error from 127.0.0.1:54784: remote error: tls: bad certificate
2018/06/30 11:42:21 http: TLS handshake error from 127.0.0.1:54792: remote error: tls: bad certificate
2018/06/30 11:42:21 http: TLS handshake error from 127.0.0.1:54801: remote error: tls: bad certificate
2018/06/30 11:42:21 [001] WARN: Error copying to client: write tcp 127.0.0.1:54813->127.0.0.1:54814: write: broken pipe
2018/06/30 11:42:21 [001] WARN: Error copying to client: read tcp 127.0.0.1:54777->127.0.0.1:54774: read: connection reset by peer
=== RUN   TestRoundTripAndNewConnection/redirect_=_true
2018/06/30 11:42:21 http: TLS handshake error from 127.0.0.1:54828: remote error: tls: bad certificate
2018/06/30 11:42:21 http: TLS handshake error from 127.0.0.1:54831: remote error: tls: bad certificate
2018/06/30 11:42:21 http: TLS handshake error from 127.0.0.1:54857: remote error: tls: bad certificate
2018/06/30 11:42:21 [001] WARN: Error copying to client: write tcp 127.0.0.1:54859->127.0.0.1:54860: write: broken pipe
--- PASS: TestRoundTripAndNewConnection (0.24s)
    --- PASS: TestRoundTripAndNewConnection/redirect_=_false (0.20s)
    --- PASS: TestRoundTripAndNewConnection/redirect_=_true (0.04s)
=== RUN   TestRoundTripRedirects
=== RUN   TestRoundTripRedirects/with_0_redirects
=== RUN   TestRoundTripRedirects/with_1_redirects
=== RUN   TestRoundTripRedirects/with_10_redirects
=== RUN   TestRoundTripRedirects/with_11_redirects
--- PASS: TestRoundTripRedirects (0.03s)
    --- PASS: TestRoundTripRedirects/with_0_redirects (0.00s)
    --- PASS: TestRoundTripRedirects/with_1_redirects (0.00s)
    --- PASS: TestRoundTripRedirects/with_10_redirects (0.00s)
    --- PASS: TestRoundTripRedirects/with_11_redirects (0.02s)
=== RUN   TestUpgradeResponse
--- FAIL: TestUpgradeResponse (0.00s)
    upgrade_test.go:82: 3: unexpected non-nil err from client.Do: Get http://127.0.0.1:54909: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x80\x03\x00\a\x00\x00\x00\b\x00\x00\x00\x00\x00\x00\x00\x00"
FAIL
FAIL	k8s.io/apimachinery/pkg/util/httpstream/spdy	0.326s
$ 

That test is sending an HTTP request header that includes:

Connection: Upgrade
Upgrade: SPDY/3.1

The server is sending back a header with WriteHeader and then hijacks the connection.

The test expects the client to get back a 101 (switching protocols) response.
Instead it gets this error.

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions