diff --git a/pkg/reconciler/autoscaling/hpa/keda_hpa.go b/pkg/reconciler/autoscaling/hpa/keda_hpa.go index 6baa247..bd223ef 100644 --- a/pkg/reconciler/autoscaling/hpa/keda_hpa.go +++ b/pkg/reconciler/autoscaling/hpa/keda_hpa.go @@ -145,7 +145,7 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, pa *autoscalingv1alpha1. // as initialized until the current replicas are >= the min-scale value. if !pa.Status.IsScaleTargetInitialized() { ms := activeThreshold(ctx, pa) - if hpa.Status.CurrentReplicas >= int32(ms) || hpa.Status.CurrentReplicas == 0 { + if hpa.Status.CurrentReplicas >= int32(ms) { pa.Status.MarkScaleTargetInitialized() } } diff --git a/test/e2e/autoscale_custom_test.go b/test/e2e/autoscale_custom_test.go index 90c46f0..4d05de2 100644 --- a/test/e2e/autoscale_custom_test.go +++ b/test/e2e/autoscale_custom_test.go @@ -1,6 +1,3 @@ -//go:build e2e -// +build e2e - /* Copyright 2024 The Knative Authors @@ -123,7 +120,7 @@ func TestScaleToZero(t *testing.T) { t.Fatalf("Error collecting metrics by HPA: %v", err) } - assertAutoscaleUpToNumPods(ctx, targetPods*2, time.After(scaleUpTimeout), true /* quick */) + assertAutoscaleUpToNumPods(ctx, targetPods*2, time.After(scaleUpTimeout), true /* quick */, 0) // Set scale metric to zero ctxScale.names.URL.RawQuery = "scale=0" @@ -162,7 +159,7 @@ func TestScaleToZero(t *testing.T) { if err := waitForHPAReplicas(t, ctx.resources.Revision.Name, ctx.resources.Revision.Namespace, ctx.clients); err != nil { t.Fatalf("Error collecting metrics by HPA: %v", err) } - assertAutoscaleUpToNumPods(ctx, targetPods*2, time.After(scaleUpTimeout), true /* quick */) + assertAutoscaleUpToNumPods(ctx, targetPods*2, time.After(scaleUpTimeout), true /* quick */, 0) } func setupCustomHPASvc(t *testing.T, metric string, target int, annos map[string]string, svcName string) *TestContext { @@ -347,11 +344,11 @@ func assertCustomHPAAutoscaleUpToNumPods(ctx *TestContext, targetPods float64, d } } -func assertAutoscaleUpToNumPods(ctx *TestContext, targetPods float64, done <-chan time.Time, quick bool) { +func assertAutoscaleUpToNumPods(ctx *TestContext, targetPods float64, done <-chan time.Time, quick bool, num float64) { ctx.t.Helper() var grp errgroup.Group grp.Go(func() error { - return checkPodScale(ctx, targetPods, minPods, maxPods, done, quick) + return checkPodScale(ctx, targetPods, num, maxPods, done, quick) }) if err := grp.Wait(); err != nil { ctx.t.Fatal(err) @@ -380,7 +377,7 @@ func assertScaleDownToN(ctx *TestContext, n int) { ctx.t.Logf("The Revision should remain ready after scaling to %d.", n) if err := v1test.CheckRevisionState(ctx.clients.ServingClient, ctx.names.Revision, v1test.IsRevisionReady); err != nil { - ctx.t.Fatalf("The Revision %s did not stay Ready after scaling down to one: %v", ctx.names.Revision, err) + ctx.t.Fatalf("The Revision %s did not stay Ready after scaling down to zero: %v", ctx.names.Revision, err) } ctx.t.Logf("Scaled down.")