From 9c8d4bbcfb0d2b84bfc17276f4afa906b8e97686 Mon Sep 17 00:00:00 2001 From: Chris Friesen Date: Wed, 15 Jul 2020 19:45:24 -0400 Subject: [PATCH] fix net/http caching of broken persistent connections 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: https://github.com/golang/go/issues/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 Change-Id: I95dcbda879973524cd23b2a374537a675ce9435f --- .../fix_http2_erringroundtripper_handling.patch | 12 ++++++++++++ kubernetes/kubernetes/centos/kubernetes.spec | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 kubernetes/kubernetes/centos/files/fix_http2_erringroundtripper_handling.patch diff --git a/kubernetes/kubernetes/centos/files/fix_http2_erringroundtripper_handling.patch b/kubernetes/kubernetes/centos/files/fix_http2_erringroundtripper_handling.patch new file mode 100644 index 00000000..921378c2 --- /dev/null +++ b/kubernetes/kubernetes/centos/files/fix_http2_erringroundtripper_handling.patch @@ -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 diff --git a/kubernetes/kubernetes/centos/kubernetes.spec b/kubernetes/kubernetes/centos/kubernetes.spec index dd91b17e..2f66ccec 100644 --- a/kubernetes/kubernetes/centos/kubernetes.spec +++ b/kubernetes/kubernetes/centos/kubernetes.spec @@ -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 @@ -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 @@ -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