summaryrefslogtreecommitdiff
path: root/vendor/k8s.io/apimachinery/pkg/util/net
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2020-12-09 09:17:32 +0000
committerDaniel J Walsh <dwalsh@redhat.com>2020-12-09 06:05:03 -0500
commit37fbf28d74927b959b36ceade7fde3402ea08e05 (patch)
treed053b6a2fd3e05946bbf71134d80efcb9a8a449c /vendor/k8s.io/apimachinery/pkg/util/net
parentdd295f297b6dd51d22c64c75f4ef4f80f953bbde (diff)
downloadpodman-37fbf28d74927b959b36ceade7fde3402ea08e05.tar.gz
podman-37fbf28d74927b959b36ceade7fde3402ea08e05.tar.bz2
podman-37fbf28d74927b959b36ceade7fde3402ea08e05.zip
Bump k8s.io/apimachinery from 0.19.4 to 0.20.0
Bumps [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) from 0.19.4 to 0.20.0. - [Release notes](https://github.com/kubernetes/apimachinery/releases) - [Commits](https://github.com/kubernetes/apimachinery/compare/v0.19.4...v0.20.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/k8s.io/apimachinery/pkg/util/net')
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/net/http.go51
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/net/port_range.go2
2 files changed, 51 insertions, 2 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/util/net/http.go b/vendor/k8s.io/apimachinery/pkg/util/net/http.go
index 945886c43..ba63d02df 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/net/http.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/net/http.go
@@ -33,6 +33,7 @@ import (
"regexp"
"strconv"
"strings"
+ "time"
"unicode"
"unicode/utf8"
@@ -132,13 +133,61 @@ func SetTransportDefaults(t *http.Transport) *http.Transport {
if s := os.Getenv("DISABLE_HTTP2"); len(s) > 0 {
klog.Infof("HTTP2 has been explicitly disabled")
} else if allowsHTTP2(t) {
- if err := http2.ConfigureTransport(t); err != nil {
+ if err := configureHTTP2Transport(t); err != nil {
klog.Warningf("Transport failed http2 configuration: %v", err)
}
}
return t
}
+func readIdleTimeoutSeconds() int {
+ ret := 30
+ // User can set the readIdleTimeout to 0 to disable the HTTP/2
+ // connection health check.
+ if s := os.Getenv("HTTP2_READ_IDLE_TIMEOUT_SECONDS"); len(s) > 0 {
+ i, err := strconv.Atoi(s)
+ if err != nil {
+ klog.Warningf("Illegal HTTP2_READ_IDLE_TIMEOUT_SECONDS(%q): %v."+
+ " Default value %d is used", s, err, ret)
+ return ret
+ }
+ ret = i
+ }
+ return ret
+}
+
+func pingTimeoutSeconds() int {
+ ret := 15
+ if s := os.Getenv("HTTP2_PING_TIMEOUT_SECONDS"); len(s) > 0 {
+ i, err := strconv.Atoi(s)
+ if err != nil {
+ klog.Warningf("Illegal HTTP2_PING_TIMEOUT_SECONDS(%q): %v."+
+ " Default value %d is used", s, err, ret)
+ return ret
+ }
+ ret = i
+ }
+ return ret
+}
+
+func configureHTTP2Transport(t *http.Transport) error {
+ t2, err := http2.ConfigureTransports(t)
+ if err != nil {
+ return err
+ }
+ // The following enables the HTTP/2 connection health check added in
+ // https://github.com/golang/net/pull/55. The health check detects and
+ // closes broken transport layer connections. Without the health check,
+ // a broken connection can linger too long, e.g., a broken TCP
+ // connection will be closed by the Linux kernel after 13 to 30 minutes
+ // by default, which caused
+ // https://github.com/kubernetes/client-go/issues/374 and
+ // https://github.com/kubernetes/kubernetes/issues/87615.
+ t2.ReadIdleTimeout = time.Duration(readIdleTimeoutSeconds()) * time.Second
+ t2.PingTimeout = time.Duration(pingTimeoutSeconds()) * time.Second
+ return nil
+}
+
func allowsHTTP2(t *http.Transport) bool {
if t.TLSClientConfig == nil || len(t.TLSClientConfig.NextProtos) == 0 {
// the transport expressed no NextProto preference, allow
diff --git a/vendor/k8s.io/apimachinery/pkg/util/net/port_range.go b/vendor/k8s.io/apimachinery/pkg/util/net/port_range.go
index 7b6eca893..42ecffcca 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/net/port_range.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/net/port_range.go
@@ -130,7 +130,7 @@ func (*PortRange) Type() string {
}
// ParsePortRange parses a string of the form "min-max", inclusive at both
-// ends, and initializs a new PortRange from it.
+// ends, and initializes a new PortRange from it.
func ParsePortRange(value string) (*PortRange, error) {
pr := &PortRange{}
err := pr.Set(value)