Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skonto committed Sep 18, 2024
1 parent 14e7754 commit 129f2eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/reconciler/autoscaling/hpa/keda_hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
13 changes: 5 additions & 8 deletions test/e2e/autoscale_custom_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build e2e
// +build e2e

/*
Copyright 2024 The Knative Authors
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.")
Expand Down

0 comments on commit 129f2eb

Please sign in to comment.