Skip to content

ROX-33958: Revert BusyBox-style binary consolidation for main image#19982

Merged
janisz merged 2 commits intomasterfrom
revert-19819-ROX-33958/resue-components
Apr 15, 2026
Merged

ROX-33958: Revert BusyBox-style binary consolidation for main image#19982
janisz merged 2 commits intomasterfrom
revert-19819-ROX-33958/resue-components

Conversation

@janisz
Copy link
Copy Markdown
Contributor

@janisz janisz commented Apr 14, 2026

After consolidation init functions fires for all components increasing memory usage. Before reapplying we need to convert init functions to explicit call in components code.

Reverts:

Copy link
Copy Markdown
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 found 2 issues, and left some high level feedback:

  • In central, authProviderBackendFactories is now initialized at package level using tlsconfig.ManagerInstance(), but the previous comment in startGRPCServer explicitly noted this should be done lazily at runtime to ensure required certificate files exist; consider keeping this initialization inside a function (e.g., startGRPCServer or a dedicated initializer) to avoid potential issues in environments/tests where certs are not yet available at import time.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In central, `authProviderBackendFactories` is now initialized at package level using `tlsconfig.ManagerInstance()`, but the previous comment in `startGRPCServer` explicitly noted this should be done lazily at runtime to ensure required certificate files exist; consider keeping this initialization inside a function (e.g., `startGRPCServer` or a dedicated initializer) to avoid potential issues in environments/tests where certs are not yet available at import time.

## Individual Comments

### Comment 1
<location path="central/main.go" line_range="238-243" />
<code_context>
 var (
 	log = logging.CreateLogger(logging.CurrentModule(), 0)

+	authProviderBackendFactories = map[string]authproviders.BackendFactoryCreator{
+		oidc.TypeName:                oidc.NewFactory,
+		"auth0":                      oidc.NewFactory, // legacy
+		saml.TypeName:                saml.NewFactory,
+		authProviderUserpki.TypeName: authProviderUserpki.NewFactoryFactory(tlsconfig.ManagerInstance()),
+		iap.TypeName:                 iap.NewFactory,
+	}
+
</code_context>
<issue_to_address>
**question (bug_risk):** Reintroducing package-level initialization for auth provider factories may re-create the original TLS dependency issue

The earlier comment in `startGRPCServer` noted that this must not run at package init because `tlsconfig.ManagerInstance()` depends on certificate files that may not exist for all entry points. Even without the BusyBox-style dispatcher, this still executes before `main()` can validate TLS config or handle errors. Consider constructing this map in `startGRPCServer` (or another explicit init function) so `ManagerInstance()` failures occur in a controlled part of startup and don’t affect tests or tools that merely import this package.
</issue_to_address>

### Comment 2
<location path="scripts/check-image-version.sh" line_range="6" />
<code_context>
 tmpfile="$(mktemp)"
 trap 'rm -f "${tmpfile}"' EXIT

-git grep -E -o -h '(stackrox|scanner)-(build|test)-[0-9]+\.[0-9]+\.[0-9].*' | grep -E -o '[0-9]+\.[0-9]+\.[0-9]' | sort -u >"$tmpfile"
+git grep -E -o -h '(stackrox|scanner)-(build|test)-[0-9]+\.[0-9]+\.[0-9]' | grep -E -o '[0-9]+\.[0-9]+\.[0-9]' | sort -u >"$tmpfile"

 if [[ "$( wc -w < "$tmpfile" )" -eq 1 ]]
</code_context>
<issue_to_address>
**question:** The updated grep might miss versions suffixed with extra metadata (e.g., -rc.1)

Because the regex now enforces the string to end at `X.Y.Z` and removes `.*`, tags like `stackrox-build-3.75.0-rc.1` will no longer be matched. If those tags must be supported, consider either restoring `.*` in the first grep and tightening the second, or updating the first pattern to allow an optional suffix after `X.Y.Z`.
</issue_to_address>

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.

Comment thread central/main.go
Comment thread scripts/check-image-version.sh
@janisz janisz requested review from dashrews78 and davdhacs April 14, 2026 12:33
@janisz janisz added the auto-retest PRs with this label will be automatically retested if prow checks fails label Apr 14, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • Refactor
    • Restructured internal architecture to deploy key components as standalone binaries rather than consolidated application modules.
    • Updated container images to include separate executable files for compliance, configuration control, database migration, sensor components, and administration utilities.

Walkthrough

This pull request decouples multiple components from a unified binary dispatch pattern where several applications (compliance, config-controller, migrator, roxctl, admission-control, kubernetes-sensor, upgrader, roxagent) shared a consolidated entry point via symlinks. Instead, each component now builds and deploys as an independent binary. The changes involve removing app/app.go dispatcher modules, relocating startup logic into each component's main.go, updating build recipes to compile separate binaries, and modifying container images to copy individual executables directly.

Changes

Cohort / File(s) Summary
Build Configuration
Makefile
Updated main-build-nodeps target to build individual Go entrypoints for compliance, config-controller, migrator, and sensor components alongside central/operator. Extended copy-go-binaries-to-image-dir to copy config-controller; replaced implicit symlink consolidation with explicit binary copying into image/rhel/bin/.
Central Application
central/main.go
Removed BusyBox-style dispatcher logic (filepath.Base switching), consolidated app imports, and direct centralRun() delegation. Moved auth provider backend factory initialization from per-server setup to package-level. Central now runs directly without dispatch.
Compliance Command
compliance/cmd/compliance/app/app.go, compliance/cmd/compliance/main.go
Deleted app.Run() dispatcher; moved node initialization, profiling setup, and compliance app construction into main.go with direct startup via c.Start().
Compliance Virtual Machines
compliance/virtualmachines/roxagent/app/app.go, compliance/virtualmachines/roxagent/main.go
Removed app.Run() signal handler and command executor; implemented signal handling and CLI execution directly in main() via cmd.RootCmd(ctx).Execute().
Config Controller
config-controller/app/app.go, config-controller/main.go
Deleted app.Run() containing full manager bootstrap; refactored complete controller-runtime setup (flags, TLS, manager creation, controller registration, health checks) into main.go with scheme initialization in init().
Container Images
image/rhel/Dockerfile, image/rhel/konflux.Dockerfile
Replaced symlink-based binary consolidation with explicit COPY commands for migrator, compliance, kubernetes-sensor, sensor-upgrader, admission-control, config-controller, roxagent into /stackrox/bin/. Simplified roxctl symlink strategy.
Migrator
migrator/app/app.go, migrator/main.go, migrator/upgrade.go, migrator/upgrade_test.go
Deleted app.Run() and orchestration logic; moved profiling, database bootstrapping, clone management, and upgrade execution into main.go. Changed upgrade.go and upgrade_test.go package from app to main.
Roxctl
roxctl/app/app.go, roxctl/main.go, roxctl/main_test.go
Removed app.Run() command executor; implemented Cobra command construction, help formatting, persistent hook patching, and user-agent setup directly in main.go with helper function getCommandPath().
Sensor Admission Control
sensor/admission-control/app/app.go, sensor/admission-control/certs.go, sensor/admission-control/main.go
Deleted full app.Run() bootstrapping (TLS, manager, metrics, watchers, gRPC); rebuilt startup in main() with explicit initialization, signal handling (graceful shutdown on first SIGTERM, forced exit on second), and inline manager/server/service wiring. Changed certs.go package to main.
Sensor Kubernetes
sensor/kubernetes/app/app.go, sensor/kubernetes/main.go
Removed app.Run() dispatcher and full sensor bootstrap; relocated memory limits to init(), Prometheus setup, signal loop, and sensor construction directly into main() with explicit Kubernetes client and central connection factory creation.
Sensor Upgrader
sensor/upgrader/app/app.go, sensor/upgrader/main.go
Deleted app.Run() and mainCmd() from app package; refactored version logging, flag parsing, config/context creation, and conditional workflow/metarunner execution into main() and new mainCmd() function.
Validation & Scripts
tools/roxvet/analyzers/validateimports/analyzer.go, scripts/check-image-version.sh
Removed allowlist entries for eight consolidated app packages from roxvet's import validator. Updated version extraction regex in check-image-version.sh to match strict X.Y.Z semantic versions only.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal and lacks details about the changes, testing, and validation required by the template. Critical sections like 'User-facing documentation' and 'Testing and quality' are incomplete, with only placeholder text 'change me!' in the validation section. Provide comprehensive details about the revert, explicitly explain why init functions need conversion, and complete all required template sections including testing validation and documentation updates.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately identifies the main change: reverting BusyBox-style binary consolidation for the main image. It is concise and specific.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert-19819-ROX-33958/resue-components

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
migrator/main.go (2)

30-41: Consider adding timeouts to the profiling HTTP server.

The HTTP server on :6060 lacks read/write timeouts, which could make it vulnerable to slowloris-style attacks. While this is an internal debug server, adding timeouts is a defensive practice.

💡 Suggested improvement
 func startProfilingServer() {
 	handler := http.NewServeMux()
 	for path, debugHandler := range routes.DebugRoutes {
 		handler.Handle(path, debugHandler)
 	}
-	srv := &http.Server{Addr: ":6060", Handler: handler}
+	srv := &http.Server{
+		Addr:         ":6060",
+		Handler:      handler,
+		ReadTimeout:  30 * time.Second,
+		WriteTimeout: 30 * time.Second,
+	}
 	go func() {
 		if err := srv.ListenAndServe(); err != nil {
 			log.WriteToStderrf("Closing profiling server: %v", err)
 		}
 	}()
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@migrator/main.go` around lines 30 - 41, The profiling server created in
startProfilingServer currently constructs srv := &http.Server{Addr: ":6060",
Handler: handler} without timeouts; update the server configuration (the srv
variable) to include sensible ReadTimeout, ReadHeaderTimeout, WriteTimeout (and
optionally IdleTimeout) values to mitigate slowloris-style attacks, then start
it the same way (ListenAndServe) while keeping the existing error handling and
use of routes.DebugRoutes and handler.

118-132: Redundant external database check.

The pgconfig.IsExternalDatabase() check on line 124 is redundant since ensureDatabaseExists() is only called when !pgconfig.IsExternalDatabase() on line 62. The function always returns nil for external databases due to the check at line 124, but this code path is unreachable.

♻️ Suggested simplification
 func ensureDatabaseExists() error {
 	sourceMap, adminConfig, err := pgconfig.GetPostgresConfig()
 	if err != nil {
 		return err
 	}

-	if !pgconfig.IsExternalDatabase() {
-		return retry.WithRetry(func() error {
-			return dbCheck(sourceMap, adminConfig)
-		}, retry.Tries(60), retry.BetweenAttempts(func(_ int) {
-			time.Sleep(5 * time.Second)
-		}))
-	}
-	return nil
+	return retry.WithRetry(func() error {
+		return dbCheck(sourceMap, adminConfig)
+	}, retry.Tries(60), retry.BetweenAttempts(func(_ int) {
+		time.Sleep(5 * time.Second)
+	}))
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@migrator/main.go` around lines 118 - 132, The function ensureDatabaseExists
currently re-checks pgconfig.IsExternalDatabase() redundantly and returns nil
for external DBs; remove that internal IsExternalDatabase() conditional and
always perform the retry.WithRetry call that invokes dbCheck using the sourceMap
and adminConfig from pgconfig.GetPostgresConfig(), returning any error from the
retry; in short, delete the inner external-database branch so
ensureDatabaseExists simply gets config (sourceMap, adminConfig) and runs
retry.WithRetry(... dbCheck ...) and returns its result.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/check-image-version.sh`:
- Line 6: The grep regex in scripts/check-image-version.sh truncates multi-digit
patch numbers; update both regexes used in the pipeline—the one inside the first
grep -E -o -h '(stackrox|scanner)-(build|test)-[0-9]+\.[0-9]+\.[0-9]' and the
subsequent grep -E -o '[0-9]+\.[0-9]+\.[0-9]'—to allow one-or-more digits for
the patch (use [0-9]+ for the patch segment), so versions like 4.6.10 are
captured fully (e.g., change the patch token to [0-9]+ in both places).

---

Nitpick comments:
In `@migrator/main.go`:
- Around line 30-41: The profiling server created in startProfilingServer
currently constructs srv := &http.Server{Addr: ":6060", Handler: handler}
without timeouts; update the server configuration (the srv variable) to include
sensible ReadTimeout, ReadHeaderTimeout, WriteTimeout (and optionally
IdleTimeout) values to mitigate slowloris-style attacks, then start it the same
way (ListenAndServe) while keeping the existing error handling and use of
routes.DebugRoutes and handler.
- Around line 118-132: The function ensureDatabaseExists currently re-checks
pgconfig.IsExternalDatabase() redundantly and returns nil for external DBs;
remove that internal IsExternalDatabase() conditional and always perform the
retry.WithRetry call that invokes dbCheck using the sourceMap and adminConfig
from pgconfig.GetPostgresConfig(), returning any error from the retry; in short,
delete the inner external-database branch so ensureDatabaseExists simply gets
config (sourceMap, adminConfig) and runs retry.WithRetry(... dbCheck ...) and
returns its result.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: f7362ae2-2e57-4803-a23a-568914ad742e

📥 Commits

Reviewing files that changed from the base of the PR and between 1e5acb2 and a2ec764.

📒 Files selected for processing (26)
  • Makefile
  • central/main.go
  • compliance/cmd/compliance/app/app.go
  • compliance/cmd/compliance/main.go
  • compliance/virtualmachines/roxagent/app/app.go
  • compliance/virtualmachines/roxagent/main.go
  • config-controller/app/app.go
  • config-controller/main.go
  • image/rhel/Dockerfile
  • image/rhel/konflux.Dockerfile
  • migrator/app/app.go
  • migrator/main.go
  • migrator/upgrade.go
  • migrator/upgrade_test.go
  • roxctl/app/app.go
  • roxctl/main.go
  • roxctl/main_test.go
  • scripts/check-image-version.sh
  • sensor/admission-control/app/app.go
  • sensor/admission-control/certs.go
  • sensor/admission-control/main.go
  • sensor/kubernetes/app/app.go
  • sensor/kubernetes/main.go
  • sensor/upgrader/app/app.go
  • sensor/upgrader/main.go
  • tools/roxvet/analyzers/validateimports/analyzer.go
💤 Files with no reviewable changes (10)
  • compliance/virtualmachines/roxagent/app/app.go
  • tools/roxvet/analyzers/validateimports/analyzer.go
  • migrator/app/app.go
  • roxctl/app/app.go
  • compliance/cmd/compliance/app/app.go
  • config-controller/app/app.go
  • sensor/upgrader/app/app.go
  • sensor/admission-control/app/app.go
  • sensor/kubernetes/app/app.go
  • roxctl/main_test.go

Comment thread scripts/check-image-version.sh Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 2.91262% with 100 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.61%. Comparing base (1e5acb2) to head (e1b6f93).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
migrator/main.go 0.00% 85 Missing ⚠️
roxctl/main.go 16.66% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19982      +/-   ##
==========================================
+ Coverage   49.56%   49.61%   +0.04%     
==========================================
  Files        2764     2765       +1     
  Lines      208442   208616     +174     
==========================================
+ Hits       103323   103500     +177     
+ Misses      97464    97460       -4     
- Partials     7655     7656       +1     
Flag Coverage Δ
go-unit-tests 49.61% <2.91%> (+0.04%) ⬆️

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

🚀 Build Images Ready

Images are ready for commit c6c06ec. To use with deploy scripts:

export MAIN_IMAGE_TAG=4.11.x-656-gc6c06eccfc

@janisz janisz enabled auto-merge (squash) April 14, 2026 12:45
@janisz janisz disabled auto-merge April 14, 2026 14:51
@janisz janisz force-pushed the revert-19819-ROX-33958/resue-components branch from 4d4fbf9 to a2ec764 Compare April 15, 2026 07:17
Signed-off-by: Tomasz Janiszewski <tomek@redhat.com>
@janisz janisz enabled auto-merge (squash) April 15, 2026 07:24
@janisz janisz disabled auto-merge April 15, 2026 07:24
@github-actions
Copy link
Copy Markdown
Contributor

/konflux-retest main-on-push

@github-actions
Copy link
Copy Markdown
Contributor

/konflux-retest operator-bundle-on-push

2 similar comments
@github-actions
Copy link
Copy Markdown
Contributor

/konflux-retest operator-bundle-on-push

@github-actions
Copy link
Copy Markdown
Contributor

/konflux-retest operator-bundle-on-push

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 15, 2026

@janisz: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/ocp-4-21-qa-e2e-tests e1b6f93 link false /test ocp-4-21-qa-e2e-tests
ci/prow/ocp-4-12-qa-e2e-tests e1b6f93 link false /test ocp-4-12-qa-e2e-tests

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@janisz janisz merged commit c6c06ec into master Apr 15, 2026
119 of 127 checks passed
@janisz janisz deleted the revert-19819-ROX-33958/resue-components branch April 15, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review area/admission-controller area/central area/helm area/roxctl area/sensor auto-retest PRs with this label will be automatically retested if prow checks fails coderabbit-review konflux-build Run Konflux in PR. Push commit to trigger it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants