Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
79d020c
Add design spec for conditional init() execution in busybox binary
janisz Apr 13, 2026
ce0bf8d
Add implementation plan for conditional init() execution
janisz Apr 13, 2026
99f16b5
feat: create central/app package structure
janisz Apr 13, 2026
391316f
docs: analyze sensor → central import chains
janisz Apr 13, 2026
6834046
feat: establish app/ structure for config-controller
janisz Apr 13, 2026
29b615f
fix: move admission-control init() to explicit initialization
janisz Apr 13, 2026
2cf4237
refactor: add GraphQL loader init structure (stub)
janisz Apr 13, 2026
2af5b79
refactor: add compliance init structure (stub)
janisz Apr 13, 2026
eb3f1e0
refactor: move Central metrics from init() to explicit registration
janisz Apr 13, 2026
bdfdc77
refactor: move sensor metrics init() to explicit initialization
janisz Apr 13, 2026
2287e20
docs: add verification report and architecture guide
janisz Apr 13, 2026
0449ea6
docs: Phase 5 low-hanging fruit analysis and migration plan
janisz Apr 13, 2026
8b5a49f
docs: add busybox-scoped Phase 5 recommendations
janisz Apr 13, 2026
eca4ef0
docs: add heap profile component labeling fix
janisz Apr 13, 2026
d3de83e
feat: add component labeling for heap/CPU profiles
janisz Apr 13, 2026
987c76a
docs: update heap profile labeling doc with implementation details
janisz Apr 13, 2026
82a6968
refactor: minimize metrics init diff by keeping logic in metrics pack…
janisz Apr 13, 2026
c78f077
chore: remove documentation files
janisz Apr 13, 2026
93f7842
refactor: remove app/init.go files, call metrics.Init directly from a…
janisz Apr 13, 2026
db6b9d5
fix: update metric Init() comments to reference app.go
janisz Apr 13, 2026
f1a6ada
refactor: migrate GraphQL loaders and compliance checks to explicit I…
janisz Apr 13, 2026
6744213
refactor: rename init() to register*() in kubernetes compliance checks
janisz Apr 13, 2026
9b30c56
refactor: rename init() to Register*() in hipaa_164 compliance checks
janisz Apr 13, 2026
f24eb46
refactor: rename init() to Register*() in nist80053 compliance checks
janisz Apr 13, 2026
668c7ef
refactor: rename init() to Register*() in nist800-190 compliance checks
janisz Apr 13, 2026
0a704c0
refactor: rename init() to Register*() in pcidss32 compliance checks
janisz Apr 13, 2026
b84cb73
refactor: replace blank imports with explicit Init() calls in complia…
janisz Apr 13, 2026
3b1086c
refactor: rename init() to Register*() in central hipaa_164 complianc…
janisz Apr 13, 2026
530b499
refactor: rename init() to Register*() in central nist800-190 complia…
janisz Apr 13, 2026
f487fd3
refactor: rename init() to Register*() in central nist80053 complianc…
janisz Apr 13, 2026
4e8afdd
refactor: rename init() to Register*() in central pcidss32 compliance…
janisz Apr 13, 2026
f8083d4
refactor: rename init() to Init() in central remote compliance checks
janisz Apr 13, 2026
4c0dbf7
refactor: replace blank imports with explicit Init() in central compl…
janisz Apr 13, 2026
998006c
refactor: rename init() to Register*() in all notifier factories
janisz Apr 13, 2026
3ab5d12
refactor: rename init() to Register*() in compliance standards metadata
janisz Apr 13, 2026
5dfcdc9
refactor: rename init() to Register*() in external backup plugins
janisz Apr 13, 2026
26ed417
refactor: migrate init() to explicit Init() pattern and centralize pr…
janisz Apr 14, 2026
e9f029f
fix: break import cycle in sensor telemetry gatherers
janisz Apr 14, 2026
4eb3d12
fix: resolve golangci-lint failures from init() migration
janisz Apr 14, 2026
51425e9
fix: expand gochecknoinits exclusion to cover all legacy directories
janisz Apr 14, 2026
441a472
refactor: migrate init() to explicit Init() pattern across all compon…
janisz Apr 14, 2026
d62a670
refactor: migrate init() to explicit Init() in roxctl, sensor, tools,…
janisz Apr 14, 2026
a7c0386
style: fix gofmt formatting in volume converter files
janisz Apr 14, 2026
0d397c9
config: add pkg/images/enricher/metadata.go to gochecknoinits exclusion
janisz Apr 14, 2026
0cb5d2a
refactor: migrate migrator init() to explicit Register() pattern
janisz Apr 14, 2026
6fceb99
refactor: migrate remaining 9 pkg/ init() functions to explicit Init()
janisz Apr 14, 2026
dd31084
refactor: unexport centralRun - only used within main package
janisz Apr 14, 2026
aeee0e4
fix: apply critical fixes from split PRs to main branch
janisz Apr 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: add GraphQL loader init structure (stub)
Establishes initGraphQL() in central/app/init.go. Full migration of
GraphQL loader init() functions deferred to separate PR.

Documents migration strategy in docs/graphql-loader-init-migration.md.

Part of ROX-33958.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
  • Loading branch information
janisz and claude committed Apr 13, 2026
commit 2cf423711f2b81b3f868fe898f8f879d1deafa97
3 changes: 3 additions & 0 deletions central/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ func Run() {
premain.StartMain()

// Component-specific initialization will be added in Phase 3
initMetrics()
initCompliance()
initGraphQL()
}
65 changes: 63 additions & 2 deletions central/app/init.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,65 @@
package app

// Component-specific initialization functions will be added in Phase 3.
// This file is created now to establish the structure.
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/stackrox/rox/central/metrics"
)

func initMetrics() {
prometheus.MustRegister(
metrics.PipelinePanicCounter,
metrics.GraphQLOperationHistogramVec,
metrics.GraphQLQueryHistogramVec,
metrics.IndexOperationHistogramVec,
metrics.SensorEventQueueCounterVec,
metrics.ResourceProcessedCounterVec,
metrics.TotalNetworkFlowsReceivedCounter,
metrics.TotalNetworkEndpointsReceivedCounter,
metrics.TotalExternalPoliciesGauge,
metrics.CurrentExternalPolicies,
metrics.SensorEventDurationHistogramVec,
metrics.RiskProcessingHistogramVec,
metrics.DatastoreFunctionDurationHistogramVec,
metrics.FunctionSegmentDurationHistogramVec,
metrics.K8sObjectProcessingDuration,
metrics.PostgresOperationHistogramVec,
metrics.AcquireDBConnHistogramVec,
metrics.ClusterMetricsNodeCountGaugeVec,
metrics.ClusterMetricsCPUCapacityGaugeVec,
metrics.TotalOrphanedPLOPCounter,
metrics.ProcessQueueLengthGauge,
metrics.SensorEventsDeduperCounter,
metrics.SensorConnectedCounter,
metrics.GrpcMaxMessageSize,
metrics.GrpcSentSize,
metrics.GrpcLastMessageSizeSent,
metrics.GrpcLastMessageSizeReceived,
metrics.GrpcError,
metrics.DeploymentEnhancementRoundTripDuration,
metrics.ReprocessorDurationGauge,
metrics.SignatureVerificationReprocessorDurationGauge,
metrics.PruningDurationHistogramVec,
metrics.StoreCacheOperationHistogramVec,
metrics.MsgToSensorNotSentCounter,
)
}

// initCompliance registers all compliance checks.
func initCompliance() {
// Import side-effect: pkg/compliance/checks registers all standard checks via init()
// We consolidate that registration here by calling the registration function explicitly
// This is handled by importing central/compliance/checks/remote which calls MustRegisterChecks

// The actual registration is done via the package import
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
// Future work: refactor compliance/checks to use explicit registration
}

// initGraphQL registers all GraphQL type loaders.
func initGraphQL() {
// GraphQL loaders registration
// Each loader registers itself via RegisterTypeFactory in their init() functions

// Similar to compliance checks, this requires refactoring the loader registration
// to be explicit rather than init()-based
// Stub for now - full migration in separate PR
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

These helpers do not remove the busybox init cost yet.

Both functions are stubs, and the comments explicitly say the real registration still happens through package-import side effects. In the consolidated binary, those init() paths still run before dispatch, so non-central components will continue paying the compliance/GraphQL initialization cost this PR is trying to isolate.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@central/app/init.go` around lines 47 - 65, The stub initCompliance and
initGraphQL still rely on package init() side-effects so the unwanted
initialization cost remains; replace the implicit side-effect imports by calling
explicit registration functions during central startup: in initCompliance call
the concrete registration routine (e.g.,
compliance/checks/remote.MustRegisterChecks or equivalent exported
RegisterAllChecks function) instead of relying on package init(), and in
initGraphQL invoke the GraphQL loader registration entrypoint (the
package-exported function that performs RegisterTypeFactory for all loaders)
rather than importing packages for side effects; remove any blank (_) imports
that trigger init() and ensure initCompliance and initGraphQL perform the
explicit calls in the central init path.

51 changes: 51 additions & 0 deletions docs/graphql-loader-init-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# GraphQL Loader Init Migration

## Current State
- ~15 GraphQL loader files in central/graphql/resolvers/loaders/
- Each has init() calling RegisterTypeFactory()
- Loaders: cluster_cves, componentsV2, deployments, images, namespaces, etc.

## Migration Strategy
Phase 3.3 establishes initGraphQL() stub in central/app/init.go

Future work (separate PR):
1. Refactor loaders package to export registration function
2. Call registration from central/app/init.go initGraphQL()
3. Remove init() from all loader files

## Files affected:
- central/graphql/resolvers/loaders/cluster_cves.go
- central/graphql/resolvers/loaders/componentsV2.go
- central/graphql/resolvers/loaders/context.go
- central/graphql/resolvers/loaders/deployments.go
- central/graphql/resolvers/loaders/factory.go
- central/graphql/resolvers/loaders/image_cves_v2.go
- central/graphql/resolvers/loaders/images.go
- central/graphql/resolvers/loaders/images_v2.go
- central/graphql/resolvers/loaders/list_deployments.go
- central/graphql/resolvers/loaders/namespaces.go
- central/graphql/resolvers/loaders/node_components.go
- central/graphql/resolvers/loaders/node_cves.go
- central/graphql/resolvers/loaders/nodes.go
- central/graphql/resolvers/loaders/policies.go
- central/graphql/resolvers/loaders/utils.go

## RegisterTypeFactory Pattern
Each loader file follows this pattern:

```go
var deploymentLoaderType = reflect.TypeOf(storage.Deployment{})

func init() {
RegisterTypeFactory(reflect.TypeOf(storage.Deployment{}), func() interface{} {
return NewDeploymentLoader(datastore.Singleton(), deploymentsView.Singleton())
})
}
```

## Future Migration Approach
1. Create central/graphql/resolvers/loaders/register.go with exported RegisterAllLoaders() function
2. Move all RegisterTypeFactory calls into RegisterAllLoaders()
3. Call RegisterAllLoaders() from central/app/init.go initGraphQL()
4. Remove init() functions from individual loader files
5. Verify GraphQL queries still work in integration tests