Skip to content

Commit

Permalink
Ensure probes from the autoscaler are not passed to the user-container (
Browse files Browse the repository at this point in the history
#13506)

The autoscaler sends a probe to detect the activator is in the data
path. This probe was inadvertently passed to the user container which
was preventing scale to 0.

Co-authored-by: dprotaso <[email protected]>
  • Loading branch information
knative-prow-robot and dprotaso authored Nov 24, 2022
1 parent c0af4d0 commit 92f942c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/queue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func buildServer(ctx context.Context, env config, probeContainer func() bool, st
drainer := &pkghandler.Drainer{
QuietPeriod: drainSleepDuration,
// Add Activator probe header to the drainer so it can handle probes directly from activator
HealthCheckUAPrefixes: []string{netheader.ActivatorUserAgent},
HealthCheckUAPrefixes: []string{netheader.ActivatorUserAgent, netheader.AutoscalingUserAgent},
Inner: composedHandler,
HealthCheck: health.ProbeHandler(probeContainer, tracingEnabled),
}
Expand Down
36 changes: 35 additions & 1 deletion test/e2e/autoscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ import (
"time"

"golang.org/x/sync/errgroup"
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"

netcfg "knative.dev/networking/pkg/config"
"knative.dev/pkg/system"
pkgtest "knative.dev/pkg/test"
"knative.dev/serving/pkg/apis/autoscaling"
"knative.dev/serving/pkg/networking"
revnames "knative.dev/serving/pkg/reconciler/revision/resources/names"
"knative.dev/serving/pkg/reconciler/serverlessservice/resources/names"
"knative.dev/serving/pkg/resources"
rtesting "knative.dev/serving/pkg/testing/v1"
Expand Down Expand Up @@ -224,6 +226,38 @@ func TestTargetBurstCapacityMinusOne(t *testing.T) {
}
}

// Explicitly setting this should cause the revision to scale down after ~10s
func TestTargetBurstCapacityZero(t *testing.T) {
t.Parallel()

ctx := SetupSvc(t, autoscaling.KPA, autoscaling.Concurrency, 10 /* target concurrency*/, targetUtilization,
rtesting.WithConfigAnnotations(map[string]string{
autoscaling.TargetBurstCapacityKey: "0",
autoscaling.WindowAnnotationKey: "10s", // scale faster
}))

test.EnsureTearDown(t, ctx.Clients(), ctx.Names())

deploymentName := revnames.Deployment(ctx.resources.Revision)

t.Log("waiting for scale down")
err := pkgtest.WaitForDeploymentState(
context.Background(),
ctx.Clients().KubeClient,
deploymentName,
func(d *appsv1.Deployment) (bool, error) {
return d.Status.ReadyReplicas == 0, nil
},
"DeploymentIsScaledDown",
test.ServingFlags.TestNamespace,
time.Minute,
)

if err != nil {
t.Error(err)
}
}

func TestFastScaleToZero(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 92f942c

Please sign in to comment.