Skip to content

Commit

Permalink
fix net/http caching of broken persistent connections
Browse files Browse the repository at this point in the history
The net/http transport code is currently broken, it keeps broken
persistent connections in the cache if a write error happens during
h2 handshake.

This is documented in the upstream bug at:
golang/go#40213

The problem occurs because in the "go" compiler the http2 code is
imported into http as a bundle, with an additional "http2" prefix
applied.  This messes up the erringRoundTripper handling because
the name doesn't match.

The solution is to have the "go" compiler look for an interface
instead, so we add a new dummy function that doesn't actually do
anything and then the "go" compiler can check whether the specified
RoundTripper implements the dummy function.

Specifically for Kubernetes we need to update the http2 code in the
"vendor" subdirectory.  A separate change is being made in the "go"
compiler.

Partial-Bug: 1887438
Depends-On: https://review.opendev.org/c/starlingx/compile/+/780669
Signed-off-by: Chris Friesen <[email protected]>
Change-Id: I95dcbda879973524cd23b2a374537a675ce9435f
  • Loading branch information
cbf123 committed Mar 29, 2021
1 parent 14f15bc commit 9c8d4bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go
index aeac7d8..ec18648 100644
--- a/vendor/golang.org/x/net/http2/transport.go
+++ b/vendor/golang.org/x/net/http2/transport.go
@@ -2404,6 +2404,7 @@ func strSliceContains(ss []string, s string) bool {

type erringRoundTripper struct{ err error }

+func (rt erringRoundTripper) IsHTTP2ErringRoundtripper() {}
func (rt erringRoundTripper) RoundTrip(*http.Request) (*http.Response, error) { return nil, rt.err }

// gzipReader wraps a response body so it can lazily
6 changes: 6 additions & 0 deletions kubernetes/kubernetes/centos/kubernetes.spec
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Source33: genmanpages.sh

Patch1: 0001-Fix-pagesize-check-to-allow-for-options-already-endi.patch
Patch2: kubelet-service-remove-docker-dependency.patch
Patch3: fix_http2_erringroundtripper_handling.patch

# It obsoletes cadvisor but needs its source code (literally integrated)
Obsoletes: cadvisor
Expand Down Expand Up @@ -838,6 +839,7 @@ Kubernetes client tools like kubectl
%setup -q -n %{con_repo}-%{con_commit} -T -b 1
%setup -q -n %{repo}-%{commit}
%patch1 -p1
%patch3 -p1

# copy contrib folder
mkdir contrib
Expand Down Expand Up @@ -873,6 +875,10 @@ export KUBE_EXTRA_GOPATH=$(pwd)/Godeps/_workspace
%ifarch ppc64le
export GOLDFLAGS='-linkmode=external'
%endif

# uncomment these two lines to build unoptimized binaries for debugging.
# export GOLDFLAGS=""
# export GOGCFLAGS="-N -l"
make WHAT="cmd/kube-proxy cmd/kube-apiserver cmd/kube-controller-manager cmd/kubelet cmd/kubeadm cmd/kube-scheduler cmd/kubectl"

# convert md to man
Expand Down

0 comments on commit 9c8d4bb

Please sign in to comment.