Skip to content

Deflake certificate-shim controller register tests - #9254

Merged
cert-manager-prow[bot] merged 2 commits into
cert-manager:masterfrom
wallrj:fix-9249-ingress-shim-queue-flake
Nov 23, 2026
Merged

cert-manager-prow[bot] merged 2 commits into
cert-manager:masterfrom
wallrj:fix-9249-ingress-shim-queue-flake

Conversation

@wallrj

@wallrj wallrj commented Sep 1, 2026

Copy link
Copy Markdown
Member

Fixes #9249

The Test_controller_Register test in pkg/controller/certificate-shim/ingresses shut its workqueue down on a fixed 50ms timer, so on a loaded CI node the shared informers had not always delivered the expected event before the queue was drained (seen on #9211). The queue is now shut down shortly after the expected key arrives — the short delay only exists to catch unexpected extra keys — with wait.ForeverTestTimeout as a backstop so a broken handler fails the test rather than hanging it. The timer dated from #4149.

While verifying the fix with go test -race -count=20 ./pkg/controller/certificate-shim/..., the race detector flagged the sibling listenerset test (added in #8394): it polls the mock workqueue's callsToAdd slice while the informer goroutines are still appending to it. The gateways test has the same unsynchronised read plus its own fixed 50ms sleep before asserting. Both siblings now guard the mock with a mutex, wait generously for the expected Add calls to arrive, and only then apply the original short grace period for unexpected extras.

The listenerset test keeps its Subset assertion rather than an exact comparison: the order of Add calls across different informers is not deterministic, and a late Gateway Added event can legitimately enqueue a duplicate key via the parent index (controller.go#L89-L110).

Verified with go test -race -count=20 on all three packages: ingresses, gateways and listenerset all pass.

with claude fable-5

@cert-manager-prow

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@cert-manager-prow cert-manager-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Sep 1, 2026
@cert-manager-prow cert-manager-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 1, 2026
@wallrj

wallrj commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

/kind flake

@cert-manager-prow cert-manager-prow Bot added the kind/flake Categorizes issue or PR as related to a flaky test. label Sep 4, 2026
@wallrj
wallrj marked this pull request as ready for review September 4, 2026 15:47
@cert-manager-prow cert-manager-prow Bot removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Sep 4, 2026
@wallrj

wallrj commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

/release-note-none

@cert-manager-prow cert-manager-prow Bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Sep 4, 2026
@hjoshi123

Copy link
Copy Markdown
Collaborator

/retest

The ingresses test shut its workqueue down on a fixed 50ms timer,
so on a loaded CI node the shared informers had not always delivered
the expected event before the queue was drained. Shut the queue down
shortly after the expected key arrives instead, with a generous
backstop so a broken handler fails rather than hangs.

The gateways and listenerset sibling tests had the same fixed 50ms
window, and both read the mock workqueue's callsToAdd slice while the
informer goroutines were still appending to it -- a data race that
go test -race catches in the listenerset package. Guard the mock with
a mutex, and wait generously for the expected Add calls before the
final assertion.

Fixes cert-manager#9249

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: Richard Wall <[email protected]>
@wallrj

wallrj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

The pull-cert-manager-master-e2e-v1-37 failure is unrelated to this PR, which only changes unit tests under pkg/controller/certificate-shim.

Evidence

All 70 failed specs in the build log are ACME conformance tests (HTTP01 and DNS01), and every one timed out at the 600s spec limit. Nothing outside the ACME suites failed, so the ACME test environment broke for that whole run. The sibling job pull-cert-manager-master-e2e-v1-37-upgrade passed on the same commit.

/retest

[Claude Fable 5]

@wallrj
wallrj requested a review from lunarwhite November 20, 2026 21:06
The parent-Gateway case waited only 2 seconds for the lister to see
ls-3. A loaded CI node can take longer to deliver the Add event, which
fails the test although the controller is correct. Use
wait.ForeverTestTimeout, as the other waits in this test do.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Richard Wall <[email protected]>
@wallrj
wallrj force-pushed the fix-9249-ingress-shim-queue-flake branch from 93cb1e7 to 2d47bd7 Compare November 20, 2026 21:14

@lunarwhite lunarwhite left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@cert-manager-prow cert-manager-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Nov 23, 2026
@wallrj

wallrj commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

/approve

@cert-manager-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lunarwhite, wallrj

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

The pull request process is described 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

@cert-manager-prow cert-manager-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 23, 2026
@cert-manager-prow
cert-manager-prow Bot merged commit c4e175e into cert-manager:master Nov 23, 2026
6 checks passed
@wallrj
wallrj deleted the fix-9249-ingress-shim-queue-flake branch November 23, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/flake Categorizes issue or PR as related to a flaky test. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky unit test: certificate-shim Test_controller_Register shuts its queue down on a fixed 50ms timer

3 participants