From a91a2908fdd0aded7f13c2816f61f5bc8ddfda1d Mon Sep 17 00:00:00 2001 From: Bruce Arctor <5032356+brucearctor@users.noreply.github.com> Date: Tue, 21 Jul 2026 21:48:15 -0700 Subject: [PATCH] Fix flaky TestMinScaleAnnotationChange by waiting for scale convergence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test calls ensureDesiredScale (which asserts stability for 30s) immediately after the Configuration reports Ready. However, the KPA reconciles scale asynchronously — the deployment may not have reached the target replica count yet when Ready is reported. Add a waitForDesiredScale call before ensureDesiredScale to first wait for the scale to converge (up to 3 min), then verify it holds steady. This matches the pattern already used in the for-loop body on line 443. This test has been auto-reported as flaky twice (#16527, #16653) and auto-closed both times without a real fix. Fixes: #16653 --- test/e2e/minscale_readiness_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/e2e/minscale_readiness_test.go b/test/e2e/minscale_readiness_test.go index a95599e6c8aa..ca9acf6bdfbe 100644 --- a/test/e2e/minscale_readiness_test.go +++ b/test/e2e/minscale_readiness_test.go @@ -418,6 +418,14 @@ func TestMinScaleAnnotationChange(t *testing.T) { serviceName := PrivateServiceName(t, clients, revName) revClient := clients.ServingClient.Revisions + // Wait for the KPA to reconcile and scale to converge before + // asserting stability. The Service can report Ready before the + // deployment has reached the desired replica count. + // See: https://github.com/knative/serving/issues/16653 + if lr, err := waitForDesiredScale(clients, serviceName, eq(minScale[0])); err != nil { + t.Fatalf("The revision %q never reached scale %d: last observed %d", revName, minScale[0], lr) + } + t.Log("Holding revision at minScale after becoming ready") if lr, ok := ensureDesiredScale(clients, t, serviceName, eq(minScale[0])); !ok { t.Fatalf("The revision %q observed scale %d < %d after becoming ready", revName, lr, minScale)