Repository navigation
Conversation
registerInformer deduplicates by interface identity, but client-go's typed informer factories return a new typedSharedIndexInformer wrapper for every Informer() call around the same cached underlying informer, and two such wrappers of one informer compare unequal. When callers obtain Informer() more than once from the same typed informer group and register each result, both wrappers are appended and RunInformers runs the underlying informer twice concurrently. sharedIndexInformer.RunWithContext does not tolerate that: its HasStarted guard is checked before the construction closure that sets s.started, so two concurrent Runs both proceed, racing the controller and FIFO construction against the stop path and eventually panicking with "close of closed channel" when both Runs close s.synced. Deduplicate on the underlying informer instead: every sharedIndexInformer owns its indexer from construction, so informers backed by the same underlying informer report the same indexer. Observed downstream, where a plugin registers a second wrapper of the namespace and CSV informers and the unit suite (go test -race) intermittently fails with three data races between RunWithContext frames followed by that panic: https://prow.ci.openshift.org/view/gs/test-platform-results-public/pr-logs/pull/openshift_operator-framework-olm/1396/pull-ci-openshift-operator-framework-olm-main-unit-olm/2115505456544747520 Signed-off-by: grokspawn <jordan@nimblewidget.com>
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
registerInformerdeduplicates informers by interface identity. That is no longer sufficient with client-go's typed informer factories: everyInformer()call returns a newtypedSharedIndexInformerwrapper around the same factory-cached underlying informer, and two such wrappers of one informer compare unequal. When a caller registers two wrappers of one informer, both are appended andRunInformersruns the underlying informer twice concurrently.sharedIndexInformer.RunWithContextdoes not tolerate a double Run: theHasStarted()guard is checked before the construction closure that setss.started, so two concurrent Runs both proceed, racings.controllerand FIFO construction against the stop path, and both Runs' shutdown goroutinesclose(s.synced)— ending in:Observed downstream (OpenShift CI,
go test -race -count=1): a downstream plugin registers a second wrapper of the namespace and CSV informer groups, and thepkg/controller/operators/olmsuite intermittently fails with three data races betweenRunWithContextframes followed by that panic:https://prow.ci.openshift.org/view/gs/test-platform-results-public/pr-logs/pull/openshift_operator-framework-olm/1396/pull-ci-openshift-operator-framework-olm-main-unit-olm/2115505456544747520
Stack signature of the double Run (two Run goroutines created by the
go informer.Run(...)loop inRunInformers, both insidetypedSharedIndexInformer[*corev1.Namespace].Run):Fix
Deduplicate on the underlying informer rather than wrapper identity: every
sharedIndexInformerowns its indexer from construction, so informers backed by the same underlying informer report the sameGetIndexer()value. Registration now skips an informer whose indexer is already registered.Verified against the failing downstream configuration: with this change, an operator whose setup registers two wrappers each of the namespace and CSV informers registers 17 informers with 17 unique underlying informers (previously 19 registered / 17 unique), and the duplicate
Run— and with it the race and panic — cannot occur.Test
TestRegisterInformerDeduplicatesTypedWrappersbuilds onecache.NewSharedIndexInformer, wraps it twice withcache.NewTypedSharedIndexInformer, registers both wrappers and asserts a single registration.Notes
Informer()twice from one typed informer group and registering each result is a natural use of the client-go API surface.sharedIndexInformer.RunWithContext's check-then-set start guard could also be hardened in client-go, but running an informer twice is caller error; deduplicating at registration is the correct fix on our side.