Update client connections to try to use http2, except attach, exec, and

port-forward which are customized
pull/6/head
Timothy St. Clair 2016-05-06 15:03:37 -05:00
parent 786b7989a0
commit 199e15ab64
2 changed files with 19 additions and 3 deletions

View File

@ -72,7 +72,7 @@ func MakeTransport(config *KubeletClientConfig) (http.RoundTripper, error) {
rt := http.DefaultTransport
if config.Dial != nil || tlsConfig != nil {
rt = utilnet.SetTransportDefaults(&http.Transport{
rt = utilnet.SetOldTransportDefaults(&http.Transport{
Dial: config.Dial,
TLSClientConfig: tlsConfig,
})

View File

@ -26,6 +26,9 @@ import (
"os"
"strconv"
"strings"
"github.com/golang/glog"
"golang.org/x/net/http2"
)
// IsProbableEOF returns true if the given error resembles a connection termination
@ -53,9 +56,9 @@ func IsProbableEOF(err error) bool {
var defaultTransport = http.DefaultTransport.(*http.Transport)
// SetTransportDefaults applies the defaults from http.DefaultTransport
// SetOldTransportDefaults applies the defaults from http.DefaultTransport
// for the Proxy, Dial, and TLSHandshakeTimeout fields if unset
func SetTransportDefaults(t *http.Transport) *http.Transport {
func SetOldTransportDefaults(t *http.Transport) *http.Transport {
if t.Proxy == nil || isDefault(t.Proxy) {
// http.ProxyFromEnvironment doesn't respect CIDRs and that makes it impossible to exclude things like pod and service IPs from proxy settings
// ProxierWithNoProxyCIDR allows CIDR rules in NO_PROXY
@ -70,6 +73,19 @@ func SetTransportDefaults(t *http.Transport) *http.Transport {
return t
}
// SetTransportDefaults applies the defaults from http.DefaultTransport
// for the Proxy, Dial, and TLSHandshakeTimeout fields if unset
func SetTransportDefaults(t *http.Transport) *http.Transport {
t = SetOldTransportDefaults(t)
// Allow HTTP2 clients but default off for now
if s := os.Getenv("ENABLE_HTTP2"); len(s) > 0 {
if err := http2.ConfigureTransport(t); err != nil {
glog.Warningf("Transport failed http2 configuration: %v", err)
}
}
return t
}
type RoundTripperWrapper interface {
http.RoundTripper
WrappedRoundTripper() http.RoundTripper