Skip to content

Commit

Permalink
Merge c884d5a into 45afb29
Browse files Browse the repository at this point in the history
  • Loading branch information
julz committed Nov 30, 2020
2 parents 45afb29 + c884d5a commit 56631ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
15 changes: 10 additions & 5 deletions cmd/activator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,17 @@ func main() {

logger.Info("Starting the knative activator")

// Create the transport used by both the activator->QP probe and the proxy.
// It's important that the throttler and the activatorhandler share this
// transport so that throttler probe connections can be reused after probing
// (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)

// Start throttler.
throttler := activatornet.NewThrottler(ctx, env.PodIP)
go throttler.Run(ctx)
go throttler.Run(ctx, transport)

oct := tracing.NewOpenCensusTracer(tracing.WithExporterFull(networking.ActivatorServiceName, env.PodIP, logger))

Expand Down Expand Up @@ -165,12 +173,9 @@ func main() {
concurrencyReporter := activatorhandler.NewConcurrencyReporter(ctx, env.PodName, statCh)
go concurrencyReporter.Run(ctx.Done())

logger.Debugf("MaxIdleProxyConns: %d, MaxIdleProxyConnsPerHost: %d", env.MaxIdleProxyConns, env.MaxIdleProxyConnsPerHost)
proxyTransport := pkgnet.NewAutoTransport(env.MaxIdleProxyConns, env.MaxIdleProxyConnsPerHost)

// Create activation handler chain
// Note: innermost handlers are specified first, ie. the last handler in the chain will be executed first
var ah http.Handler = activatorhandler.New(ctx, throttler, proxyTransport)
var ah http.Handler = activatorhandler.New(ctx, throttler, transport)
ah = concurrencyReporter.Handler(ah)
ah = tracing.HTTPSpanMiddleware(ah)
ah = configStore.HTTPMiddleware(ah)
Expand Down
6 changes: 3 additions & 3 deletions pkg/activator/net/throttler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"math"
"math/rand"
"net/http"
"sort"
"sync"

Expand All @@ -38,7 +39,6 @@ import (
"knative.dev/pkg/controller"
"knative.dev/pkg/logging"
"knative.dev/pkg/logging/logkey"
"knative.dev/pkg/network"
"knative.dev/pkg/reconciler"
"knative.dev/serving/pkg/activator/util"
"knative.dev/serving/pkg/apis/serving"
Expand Down Expand Up @@ -496,8 +496,8 @@ func NewThrottler(ctx context.Context, ipAddr string) *Throttler {
}

// Run starts the throttler and blocks until the context is done.
func (t *Throttler) Run(ctx context.Context) {
rbm := newRevisionBackendsManager(ctx, network.AutoTransport)
func (t *Throttler) Run(ctx context.Context, probeTransport http.RoundTripper) {
rbm := newRevisionBackendsManager(ctx, probeTransport)
// Update channel is closed when ctx is done.
t.run(rbm.updates())
}
Expand Down

0 comments on commit 56631ac

Please sign in to comment.