Skip to content

ROX-33043: Fix Profile informer startup panic#18921

Draft
lvalerom wants to merge 1 commit intomasterfrom
lvm/rox-33043-fix-profile-informer-startup
Draft

ROX-33043: Fix Profile informer startup panic#18921
lvalerom wants to merge 1 commit intomasterfrom
lvm/rox-33043-fix-profile-informer-startup

Conversation

@lvalerom
Copy link
Contributor

@lvalerom lvalerom commented Feb 9, 2026

Description

The DynamicSharedInformerFactory creates Informers lazily when ForResource is first called (see FromResource and NewFilteredDynamicInformer). Previously, we called ForResource().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:

  1. Moving the profileLister creation to happen at the same time as the Profile Informer() is created
  2. Making the TailoredProfile dispatcher lazy-initialized - it's now created in ForComplianceOperatorTailoredProfiles when first needed, receiving the profileLister as a parameter instead of during
    registry construction

This ensures the Profile informer is only created when we're ready to Start it.

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  • CI
  • Run the integration tests multiple times manually

…le dispatcher

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci
Copy link

openshift-ci bot commented Feb 9, 2026

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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • 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.
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`.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant