diff --git a/cmd/activator/main.go b/cmd/activator/main.go index 5b0e90198b2a..68e3ae46b9a9 100644 --- a/cmd/activator/main.go +++ b/cmd/activator/main.go @@ -139,7 +139,7 @@ func main() { // (via keep-alive) to send real requests, avoiding needing an extra // reconnect for the first request after the probe succeeds. logger.Debugf("MaxIdleProxyConns: %d, MaxIdleProxyConnsPerHost: %d", env.MaxIdleProxyConns, env.MaxIdleProxyConnsPerHost) - transport := pkgnet.NewAutoTransport(env.MaxIdleProxyConns, env.MaxIdleProxyConnsPerHost) + transport := pkgnet.NewProxyAutoTransport(env.MaxIdleProxyConns, env.MaxIdleProxyConnsPerHost) // Start throttler. throttler := activatornet.NewThrottler(ctx, env.PodIP) diff --git a/cmd/queue/main.go b/cmd/queue/main.go index 3ea930129b6d..52b4bc5c8b1d 100644 --- a/cmd/queue/main.go +++ b/cmd/queue/main.go @@ -309,7 +309,7 @@ func buildServer(ctx context.Context, env config, healthState *health.State, rp func buildTransport(env config, logger *zap.SugaredLogger, maxConns int) http.RoundTripper { // set max-idle and max-idle-per-host to same value since we're always proxying to the same host. - transport := pkgnet.NewAutoTransport(maxConns /* max-idle */, maxConns /* max-idle-per-host */) + transport := pkgnet.NewProxyAutoTransport(maxConns /* max-idle */, maxConns /* max-idle-per-host */) if env.TracingConfigBackend == tracingconfig.None { return transport diff --git a/go.mod b/go.mod index 8bd2e6e8d2f5..37d66327228e 100644 --- a/go.mod +++ b/go.mod @@ -53,8 +53,8 @@ require ( k8s.io/kube-openapi v0.0.0-20210113233702-8566a335510f k8s.io/utils v0.0.0-20210111153108-fddb29f9d009 // indirect knative.dev/caching v0.0.0-20210201195732-f8bed817dad1 - knative.dev/hack v0.0.0-20210120165453-8d623a0af457 + knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf knative.dev/networking v0.0.0-20210202173433-c069ad20a560 - knative.dev/pkg v0.0.0-20210130001831-ca02ef752ac6 + knative.dev/pkg v0.0.0-20210203171706-6045ed499615 sigs.k8s.io/yaml v1.2.0 ) diff --git a/go.sum b/go.sum index 608d41b9a3b0..d1d710d5e8b5 100644 --- a/go.sum +++ b/go.sum @@ -1293,10 +1293,14 @@ knative.dev/caching v0.0.0-20210201195732-f8bed817dad1 h1:cgLn/SJdX1/q0RV9qssJtg knative.dev/caching v0.0.0-20210201195732-f8bed817dad1/go.mod h1:YTyeMeeMzVkCsGLNuucs0Ui25BcR0iKUGQgef4cj4/o= knative.dev/hack v0.0.0-20210120165453-8d623a0af457 h1:jEBITgx/lQydGncM0uetpv/ZqawRzb2aSfEaYoMeDjM= knative.dev/hack v0.0.0-20210120165453-8d623a0af457/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= +knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf h1:u4cY4jr2LYvhoz/1HBWEPsMiLkm0HMdDTfmmw1RE8zE= +knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/networking v0.0.0-20210202173433-c069ad20a560 h1:7k0pMfVwtCuRUnuzoK2BN8r2SgBki+HG8cjjQPPFz3U= knative.dev/networking v0.0.0-20210202173433-c069ad20a560/go.mod h1:LFCHSswO9cLifBJtuipVzw4M+nPdvkR1t82U6YJdhCA= knative.dev/pkg v0.0.0-20210130001831-ca02ef752ac6 h1:HIACRvhv/4U7vcFTAakfqYJIlENCSGtTrZOwz/q/A00= knative.dev/pkg v0.0.0-20210130001831-ca02ef752ac6/go.mod h1:X4NPrCo8NK3hbDVan9Vm7mf5io3ZoINakAdrpSXVB08= +knative.dev/pkg v0.0.0-20210203171706-6045ed499615 h1:Ee0n+axzrQXWkJfGl91B5RRmB25R1plTfC7MDw3NxUU= +knative.dev/pkg v0.0.0-20210203171706-6045ed499615/go.mod h1:X4NPrCo8NK3hbDVan9Vm7mf5io3ZoINakAdrpSXVB08= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/vendor/knative.dev/hack/library.sh b/vendor/knative.dev/hack/library.sh index cf56962a81b4..25b3407e89f8 100644 --- a/vendor/knative.dev/hack/library.sh +++ b/vendor/knative.dev/hack/library.sh @@ -539,7 +539,8 @@ function go_update_deps() { export GO111MODULE=on export GOFLAGS="" - export GOSUMDB=off # Do not use the sum.golang.org service. + export GONOSUMDB="${GONOSUMDB:-},knative.dev/*" + export GONOPROXY="${GONOPROXY:-},knative.dev/*" echo "=== Update Deps for Golang" @@ -559,16 +560,6 @@ function go_update_deps() { if [[ $UPGRADE == 1 ]]; then group "Upgrading to ${VERSION}" - # From shell parameter expansion: - # ${parameter:+word} - # If parameter is null or unset, nothing is substituted, otherwise the expansion of word is substituted. - # -z is if the length of the string, so skip setting GOPROXY if GOPROXY is already set. - if [[ -z ${GOPROXY:+skip} ]]; then - export GOPROXY=direct - echo "Using 'GOPROXY=direct'." - else - echo "Respecting 'GOPROXY=${GOPROXY}'." - fi FLOATING_DEPS+=( $(run_go_tool knative.dev/test-infra/buoy buoy float ${REPO_ROOT_DIR}/go.mod --release ${VERSION} --domain ${DOMAIN}) ) if [[ ${#FLOATING_DEPS[@]} > 0 ]]; then echo "Floating deps to ${FLOATING_DEPS[@]}" diff --git a/vendor/knative.dev/pkg/network/h2c.go b/vendor/knative.dev/pkg/network/h2c.go index 73fabee977d7..f950b9c34fc2 100644 --- a/vendor/knative.dev/pkg/network/h2c.go +++ b/vendor/knative.dev/pkg/network/h2c.go @@ -41,8 +41,13 @@ func NewServer(addr string, h http.Handler) *http.Server { // to explicitly allow h2c (http2 without TLS) transport. // See https://github.com/golang/go/issues/14141 for more details. func NewH2CTransport() http.RoundTripper { + return newH2CTransport(false) +} + +func newH2CTransport(disableCompression bool) http.RoundTripper { return &http2.Transport{ - AllowHTTP: true, + AllowHTTP: true, + DisableCompression: disableCompression, DialTLS: func(netw, addr string, _ *tls.Config) (net.Conn, error) { return DialWithBackOff(context.Background(), netw, addr) diff --git a/vendor/knative.dev/pkg/network/transports.go b/vendor/knative.dev/pkg/network/transports.go index c37b99d57812..26ce82395760 100644 --- a/vendor/knative.dev/pkg/network/transports.go +++ b/vendor/knative.dev/pkg/network/transports.go @@ -94,13 +94,14 @@ func dialBackOffHelper(ctx context.Context, network, address string, bo wait.Bac return nil, fmt.Errorf("timed out dialing after %.2fs", elapsed.Seconds()) } -func newHTTPTransport(disableKeepAlives bool, maxIdle, maxIdlePerHost int) http.RoundTripper { +func newHTTPTransport(disableKeepAlives, disableCompression bool, maxIdle, maxIdlePerHost int) http.RoundTripper { transport := http.DefaultTransport.(*http.Transport).Clone() transport.DialContext = DialWithBackOff transport.DisableKeepAlives = disableKeepAlives transport.MaxIdleConns = maxIdle transport.MaxIdleConnsPerHost = maxIdlePerHost transport.ForceAttemptHTTP2 = false + transport.DisableCompression = disableCompression return transport } @@ -108,7 +109,7 @@ func newHTTPTransport(disableKeepAlives bool, maxIdle, maxIdlePerHost int) http. // since it will not cache connections. func NewProberTransport() http.RoundTripper { return newAutoTransport( - newHTTPTransport(true /*disable keep-alives*/, 0, 0 /*no caching*/), + newHTTPTransport(true /*disable keep-alives*/, false /*disable auto-compression*/, 0, 0 /*no caching*/), NewH2CTransport()) } @@ -116,8 +117,17 @@ func NewProberTransport() http.RoundTripper { // based on the request's HTTP version. func NewAutoTransport(maxIdle, maxIdlePerHost int) http.RoundTripper { return newAutoTransport( - newHTTPTransport(false /*disable keep-alives*/, maxIdle, maxIdlePerHost), - NewH2CTransport()) + newHTTPTransport(false /*disable keep-alives*/, false /*disable auto-compression*/, maxIdle, maxIdlePerHost), + newH2CTransport(false /*disable auto-compression*/)) +} + +// NewProxyAutoTransport creates a RoundTripper suitable for use by a reverse +// proxy. The returned transport uses HTTP or H2C based on the request's HTTP +// version. The transport has DisableCompression set to true. +func NewProxyAutoTransport(maxIdle, maxIdlePerHost int) http.RoundTripper { + return newAutoTransport( + newHTTPTransport(false /*disable keep-alives*/, true /*disable auto-compression*/, maxIdle, maxIdlePerHost), + newH2CTransport(true /*disable auto-compression*/)) } // AutoTransport uses h2c for HTTP2 requests and falls back to `http.DefaultTransport` for all others diff --git a/vendor/modules.txt b/vendor/modules.txt index 039cf7afef7d..9b085ec0f204 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1025,7 +1025,7 @@ knative.dev/caching/pkg/client/injection/informers/caching/v1alpha1/image/fake knative.dev/caching/pkg/client/injection/informers/factory knative.dev/caching/pkg/client/injection/informers/factory/fake knative.dev/caching/pkg/client/listers/caching/v1alpha1 -# knative.dev/hack v0.0.0-20210120165453-8d623a0af457 +# knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf ## explicit knative.dev/hack knative.dev/hack/shell @@ -1064,7 +1064,7 @@ knative.dev/networking/test/conformance/ingress knative.dev/networking/test/defaultsystem knative.dev/networking/test/test_images/grpc-ping/proto knative.dev/networking/test/types -# knative.dev/pkg v0.0.0-20210130001831-ca02ef752ac6 +# knative.dev/pkg v0.0.0-20210203171706-6045ed499615 ## explicit knative.dev/pkg/apiextensions/storageversion knative.dev/pkg/apiextensions/storageversion/cmd/migrate