ROX-33043: Fix Profile informer startup panic#18921
Draft
Conversation
…le dispatcher Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Skipping CI for Draft Pull Request. |
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The lazy initialization of
complianceOperatorTailoredProfileDispatcherinForComplianceOperatorTailoredProfilesis not concurrency-safe; if this is ever called from multiple goroutines, consider guarding it with async.Onceor a mutex, or document clearly that it is only called during single-threaded startup. - Since
ForComplianceOperatorTailoredProfilesnow takes acache.GenericLister, it may be worth adding a defensivenilcheck (with a clear error or panic) to fail fast if it is ever accidentally invoked without a validprofileLister.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The lazy initialization of `complianceOperatorTailoredProfileDispatcher` in `ForComplianceOperatorTailoredProfiles` is not concurrency-safe; if this is ever called from multiple goroutines, consider guarding it with a `sync.Once` or a mutex, or document clearly that it is only called during single-threaded startup.
- Since `ForComplianceOperatorTailoredProfiles` now takes a `cache.GenericLister`, it may be worth adding a defensive `nil` check (with a clear error or panic) to fail fast if it is ever accidentally invoked without a valid `profileLister`.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Description
The DynamicSharedInformerFactory creates Informers lazily when
ForResourceis first called (see FromResource and NewFilteredDynamicInformer). Previously, we calledForResource().Lister()early during initialization to pass the profileLister to the DispatcherRegistry constructor. This caused the Profile informer to be created too early, before we could call SetTransform, leading to panics in dev builds (see #17395).This PR fixes the issue by:
profileListercreation to happen at the same time as the ProfileInformer()is createdForComplianceOperatorTailoredProfileswhen first needed, receiving the profileLister as a parameter instead of duringregistry construction
This ensures the Profile informer is only created when we're ready to Start it.
User-facing documentation
Testing and quality
Automated testing
How I validated my change