Skip to content

Fix flaky TestMinScaleAnnotationChange by waiting for scale convergence#16668

Open
brucearctor wants to merge 1 commit into
knative:mainfrom
brucearctor:fix-flaky-minscale-annotation-test
Open

Fix flaky TestMinScaleAnnotationChange by waiting for scale convergence#16668
brucearctor wants to merge 1 commit into
knative:mainfrom
brucearctor:fix-flaky-minscale-annotation-test

Conversation

@brucearctor

Copy link
Copy Markdown

What

Fix the recurring flaky TestMinScaleAnnotationChange e2e test by adding a waitForDesiredScale call before ensureDesiredScale.

Why

The test calls ensureDesiredScale (which asserts scale 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. If the scale is briefly at 0 during KPA convergence, ensureDesiredScale catches that transient state and hard-fails.

This has been auto-reported as flaky twice and auto-closed both times without a real fix:

Fix

Add waitForDesiredScale (polls up to 3 min for convergence) before ensureDesiredScale (asserts stability for 30s). This matches the pattern already used in the annotation-change loop body (line 443), which does not exhibit this flake.

Other call sites

Lines 134, 203, 308, and 341 in the same file have the same ensureDesiredScale-without-convergence-wait pattern. These could also be flaky but are not currently failing. Happy to fix those in a follow-up PR if maintainers agree.

/kind bug

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 (knative#16527, knative#16653)
and auto-closed both times without a real fix.

Fixes: knative#16653
@knative-prow knative-prow Bot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 22, 2026
@knative-prow

knative-prow Bot commented Jul 22, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: brucearctor
Once this PR has been reviewed and has the lgtm label, please assign dsimansk for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow
knative-prow Bot requested review from dprotaso, dsimansk and skonto July 22, 2026 04:49
@knative-prow knative-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jul 22, 2026
@knative-prow

knative-prow Bot commented Jul 22, 2026

Copy link
Copy Markdown

Welcome @brucearctor! It looks like this is your first PR to knative/serving 🎉

@knative-prow knative-prow Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 22, 2026
@knative-prow

knative-prow Bot commented Jul 22, 2026

Copy link
Copy Markdown

Hi @brucearctor. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@linkvt

linkvt commented Jul 22, 2026

Copy link
Copy Markdown
Member

/ok-to-test

@knative-prow knative-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 22, 2026
@brucearctor

Copy link
Copy Markdown
Author

@linkvt -- the build job in the kind-e2e workflow is failing across PRs (e.g. #16668, #16655) with Get "https://registry.local:5000/v2/": http: server gave HTTP response to HTTPS client. Looks like ko is trying HTTPS despite the *.local insecure override in go-containerregistry. Might be a ko version / registry:3.0.0 interaction. Happy to dig in if helpful.

@linkvt

linkvt commented Jul 22, 2026

Copy link
Copy Markdown
Member

Sure! It just seems like your change shouldn't have caused this and other recent PRs dont fail, I thought we usually pin all versions.
Maybe a flake, even if the error doesnt sound like one...

/retest

@brucearctor

Copy link
Copy Markdown
Author

Thanks for the retest @linkvt! Same failure on retry — looks persistent, not a flake.

I dug in a bit:

  • The build job in kind-e2e.yaml starts registry:3.0.0 on port 5000 (HTTP, no TLS)
  • ko resolve then tries to push via HTTPS → Get "https://registry.local:5000/v2/": http: server gave HTTP response to HTTPS client
  • go-containerregistry has a *.local → HTTP override, but something in the current ko version (setup-ko@v0.9) seems to not be honoring it
  • Same failure on PR Bump the github-actions group across 1 directory with 3 updates #16655 (dependabot) — not specific to this PR

This is probably a #productivity / CI infra issue. Happy to file a separate issue if that would be helpful.

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.29%. Comparing base (dbce551) to head (61a6415).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16668   +/-   ##
=======================================
  Coverage   80.29%   80.29%           
=======================================
  Files         217      217           
  Lines       13568    13568           
=======================================
  Hits        10895    10895           
  Misses       2308     2308           
  Partials      365      365           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@linkvt

linkvt commented Jul 22, 2026

Copy link
Copy Markdown
Member

@brucearctor I created PR #16669 to work around the issue, CI passes and the PR now waits for a maintainer review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants