Skip to content

test: stabilize customresourcesgate TestReconcile#976

Merged
phisco merged 1 commit intocrossplane:release-2.0from
phisco:fix/customresourcesgate-flake-release-2.0
Apr 17, 2026
Merged

test: stabilize customresourcesgate TestReconcile#976
phisco merged 1 commit intocrossplane:release-2.0from
phisco:fix/customresourcesgate-flake-release-2.0

Conversation

@phisco
Copy link
Copy Markdown
Contributor

@phisco phisco commented Apr 17, 2026

Description of your changes

Fixes a flake in TestReconcile/EstablishedCRDCallsGateTrue (and other subtests with multi-version fixtures) in pkg/reconciler/customresourcesgate.

The test normaliser sorted recorded gate.True / gate.False calls by GroupVersionKind.Kind only. Several fixtures contain multiple GVKs that share the same Kind but differ in Version (e.g. TestResource at v1alpha1 and v1beta1). Because the reconciler iterates a map[schema.GroupVersionKind]bool — whose iteration order is nondeterministic in Go — the resulting slice order is not stable, and the Kind-only sort cannot disambiguate entries, so the assertion becomes order-dependent and intermittently fails.

Sort on the full GVK (Group, Version, Kind) so the comparison is stable regardless of reconciler iteration order. This is a test-only change; reconciler behaviour is unchanged.

This has been blocking PRs #919 and #972 (and caused an unrelated flake observed in run #955, which predates the recent dep bumps).

This mirrors the fix already on main as part of 552d14c ("Upgrade controller-runtime to v0.21.0"), backported here for release-2.0.

I have:

  • Read and followed Crossplane's contribution process.
  • Run earthly +reviewable to ensure this PR is ready for review.

How has this code been tested

Ran go test -count=10 -race ./pkg/reconciler/customresourcesgate/... and the full TestReconcile/EstablishedCRDCallsGateTrue subtest 10/10 times under -race — all passing.

The TestReconcile subtests normalized recorded gate calls by sorting
only on GVK.Kind. Several fixtures contain multiple GVKs with identical
Kind but different Version (e.g. "TestResource" at v1alpha1 and v1beta1).
Combined with the nondeterministic map iteration in the reconciler, this
made the assertion order-dependent and the test intermittently flaky
(notably TestReconcile/EstablishedCRDCallsGateTrue).

Sort on the full GroupVersionKind (Group, Version, Kind) so the
comparison is stable regardless of the reconciler's iteration order.

This mirrors the fix already on main (552d14c), backported here for
release-2.0.

Signed-off-by: Philippe Scorsolini <5697904+phisco@users.noreply.github.com>
@phisco phisco requested a review from a team as a code owner April 17, 2026 15:14
@phisco phisco requested review from bobh66 and removed request for a team April 17, 2026 15:14
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 503a0124-12da-48cb-aded-03557231c148

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@phisco phisco merged commit 358522c into crossplane:release-2.0 Apr 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants