Skip to content
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 pkg/queue/sharedmain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func buildServer(ctx context.Context, env config, transport http.RoundTripper, p
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 @@ -26,13 +26,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 @@ -230,6 +232,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