Skip to content

refactor: migrate GraphQL loaders + establish central/app infrastructure#19984

Draft
janisz wants to merge 4 commits intomasterfrom
master-init-migration-graphql-foundation
Draft

refactor: migrate GraphQL loaders + establish central/app infrastructure#19984
janisz wants to merge 4 commits intomasterfrom
master-init-migration-graphql-foundation

Conversation

@janisz
Copy link
Copy Markdown
Contributor

@janisz janisz commented Apr 14, 2026

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

  • 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

change me!

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>
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 14, 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

…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.
@janisz janisz force-pushed the master-init-migration-graphql-foundation branch from 456bba3 to c1d2c6a Compare April 14, 2026 15:16
The profiling changes belong in a different PR. This PR only adds GraphQL loaders.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

🚀 Build Images Ready

Images 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
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 73.94366% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.62%. Comparing base (1e5acb2) to head (99c6ae0).
⚠️ Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
central/graphql/resolvers/loaders/init.go 0.00% 37 Missing ⚠️
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     
Flag Coverage Δ
go-unit-tests 49.62% <73.94%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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>
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