Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid adding gzip-encoding to requests implicitly #10691

Merged
merged 1 commit into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/activator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/queue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
13 changes: 2 additions & 11 deletions vendor/knative.dev/hack/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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[@]}"
Expand Down
7 changes: 6 additions & 1 deletion vendor/knative.dev/pkg/network/h2c.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 14 additions & 4 deletions vendor/knative.dev/pkg/network/transports.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,40 @@ 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
}

// NewProberTransport creates a RoundTripper that is useful for probing,
// 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())
}

// NewAutoTransport creates a RoundTripper that can use appropriate transport
// 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
Expand Down
4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down