Skip to content

test(webhook): fix envtest cache race behind flaky main CI - #39

Merged
mmatloka merged 1 commit into
mainfrom
fix/webhook-envtest-cache-race
Nov 13, 2026
Merged

mmatloka merged 1 commit into
mainfrom
fix/webhook-envtest-cache-race

Conversation

@mmatloka

Copy link
Copy Markdown
Contributor

Summary

  • ci on main failed in TestEnvtestRBWebhook_IdentityCollision_Rejected after build(deps): bump github.com/twmb/franz-go/pkg/kmsg from 1.15.0 to 1.15.1 #37 merged; only go.mod/go.sum changed, so this is a test race, not a dependency regression.
  • The validators read through the manager's cached client. A create followed immediately by a conflicting create could race the informer: the second admission didn't yet see the first object — or, for role bindings, the referenced KafkaCluster, which the validator treats as "allow" — so the duplicate was admitted.
  • The envtest client is now wrapped (cacheSyncedClient) so Create returns only once the manager cache observes the object. Applied to all five webhook envtest environments; production code unchanged.

Test plan

  • go test -tags envtest -count=3 ./internal/operator/webhook/ (WSL, envtest 1.37.0): all tests pass in all 3 runs
  • CI envtest job green

The validators read through the manager's cached client, so a create
followed immediately by a conflicting create could race the informer:
the second admission didn't yet see the first object (or, for role
bindings, the referenced KafkaCluster) and was wrongly admitted. This
made TestEnvtestRBWebhook_IdentityCollision_Rejected flaky on main.

Wrap the envtest client so Create returns only once the manager cache
observes the new object.
@mmatloka
mmatloka merged commit fbb6e56 into main Nov 13, 2026
14 checks passed
@mmatloka
mmatloka deleted the fix/webhook-envtest-cache-race branch November 13, 2026 06:37
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.

1 participant