Skip to content

Commit

Permalink
Update client connections to try to use http2, except attach, exec, and
Browse files Browse the repository at this point in the history
port-forward which are customized
  • Loading branch information
Timothy St. Clair committed May 27, 2016
1 parent 786b798 commit 199e15a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/kubelet/client/kubelet_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down
20 changes: 18 additions & 2 deletions pkg/util/net/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 199e15a

Please sign in to comment.