refactor: migrate GraphQL loaders + establish central/app infrastructure#19984
Draft
refactor: migrate GraphQL loaders + establish central/app infrastructure#19984
Conversation
Convert GraphQL loaders from package-level init() to explicit Init() and establish central/app package for component initialization. Changes: - central/graphql/resolvers/loaders/*: 15+ loader files init() → Register*() - central/graphql/resolvers/*: ~50 resolver files with import updates - central/app/app.go: create Run() with component-specific initialization - central/app/init.go: create initGraphQL(), initCompliance() stubs - central/main.go: add profiling.SetComponentLabel(binaryName) in dispatcher - central/main.go: call app.Run() before CentralRun() With busybox consolidation, GraphQL loaders were registering for all components. This change makes loader registration conditional - only central registers GraphQL loaders. Infrastructure changes: - Establishes central/app pattern for explicit initialization - Centralizes profiling component labeling in main dispatcher - Removes proxy initialization from init() to app logic Expected impact: - Prevents 15+ GraphQL loader registrations in non-central components - Proper component labeling in heap/CPU profiles (central, sensor, etc.) - Foundation for future init() migrations Files changed: 68 (15 loaders + 50 resolvers + 3 central/app + main.go) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Skipping CI for Draft Pull Request. |
…changes) - Remove metrics.Init() (belongs in metrics PR) - Remove compliance, notifiers, backup Init() calls (belong in other PRs) - Remove initComponentLogic (belongs in remaining PR) - Remove central/app/init.go (belongs in remaining PR) This PR only introduces GraphQL loaders infrastructure.
456bba3 to
c1d2c6a
Compare
The profiling changes belong in a different PR. This PR only adds GraphQL loaders.
Contributor
🚀 Build Images ReadyImages are ready for commit 99c6ae0. To use with deploy scripts: export MAIN_IMAGE_TAG=4.11.x-647-g99c6ae0881 |
Move Init() call from getBuilder() to package init() to prevent deadlock. Problem: getBuilder() called Init() inside once.Do(), but Init() calls registerXXXSchema() functions which call getBuilder(), creating a circular dependency that deadlocked on sync.Once. Solution: Add package init() that calls Init(), and remove Init() call from getBuilder(). Also change Schema() to call getBuilder().Render() instead of builderInstance.Render() to ensure builder is initialized. This matches the original master pattern where each schema file had init() that called getBuilder(). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #19984 +/- ##
==========================================
+ Coverage 49.56% 49.62% +0.06%
==========================================
Files 2764 2767 +3
Lines 208442 208642 +200
==========================================
+ Hits 103323 103548 +225
+ Misses 97464 97453 -11
+ Partials 7655 7641 -14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
janisz
added a commit
that referenced
this pull request
Apr 15, 2026
This commit applies all the critical fixes discovered while splitting ROX-34074 into smaller PRs: **1. GraphQL schema deadlock fix (from PR #19984)** - Moved Init() call from getBuilder() to package-level init() - Changed Schema() to call getBuilder().Render() instead of builderInstance - Prevents circular dependency: getBuilder() calls Init() which calls registerXXXSchema() which calls getBuilder() **2. Proto file restoration (from PR #19983)** - Restored ReprocessDeployments.skip_cache_flush field from master - This field was added in ROX-33339 (#19840) but accidentally removed when creating the init migration branch - Required for central/reprocessor code to compile **3. Search packages init() restoration (from PR #19983)** - Restored init() to pkg/search/enumregistry and pkg/search/options - These are foundational packages used everywhere (central, sensor, roxctl, tests) - Converting them to explicit Init() broke all tests that don't call central/app/init.go - These packages justify init() because they're pure data structure setup with no component-specific logic **4. Package initialization order fix (central/search/service)** - Made categoryToOptionsMultimap lazy-initialized with sync.Once - Previous eager initialization during package init caused nil pointer dereference because it ran before pkg/search init() completed - Now uses getCategoryToOptionsMultimap() to ensure safe initialization **5. Updated .golangci.yml exclusions** - Added pkg/search/enumregistry/enum_registry.go - Added pkg/search/options.go - These are justified init() cases per pkg/PKG_INIT_MIGRATION.md **Test results:** - GraphQL schema validation: ✓ PASS - Compliance aggregation: ✓ PASS - Central reprocessor: ✓ Compiles Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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
Convert GraphQL loaders from package-level init() to explicit Init() and establish central/app package for component initialization.
With busybox consolidation, GraphQL loaders were registering for all components. This change makes loader registration conditional - only central registers GraphQL loaders.
Refs:
User-facing documentation
Testing and quality
Automated testing
How I validated my change
change me!