Skip to content

feat: add ROX_LOGGING_TO_FILE to disable file logging#20019

Draft
davdhacs wants to merge 1 commit intomasterfrom
davdhacs/pr1c-logging-env
Draft

feat: add ROX_LOGGING_TO_FILE to disable file logging#20019
davdhacs wants to merge 1 commit intomasterfrom
davdhacs/pr1c-logging-env

Conversation

@davdhacs
Copy link
Copy Markdown
Contributor

Description

Add ROX_LOGGING_TO_FILE environment variable (default: true) to control whether log output is written to files. When set to false, all file-based logging is disabled — only stdout/stderr output remains.

In container environments where the container runtime captures stdout, file logging is redundant. Disabling it eliminates file handles, lumberjack goroutines, and disk I/O.

Changes

  • New env var ROX_LOGGING_TO_FILE in pkg/env/logging.go
  • Skip addOutput(&config, LoggingPath) when disabled
  • Default: true (backward compatible)

Measurements

  • Goroutines: -30 when disabled (all lumberjack rotation watchers)
  • Disk I/O: eliminated when disabled
  • Memory: ~10 MB potential savings (no file buffers)

Depends on the zap sampling change (#19997, merged).

User-facing documentation

Testing and quality

  • the change is production ready
  • CI results are inspected

Automated testing

  • modified existing tests

How I validated my change

  • Verified ROX_LOGGING_TO_FILE=false eliminates file-logging goroutines
  • Verified default behavior (true) is unchanged
  • Deployed on live GKE test cluster

AI-assisted.

@openshift-ci
Copy link
Copy Markdown

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

🚀 Build Images Ready

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

export MAIN_IMAGE_TAG=4.11.x-658-g6a491e93d3

@davdhacs davdhacs force-pushed the davdhacs/pr1c-logging-env branch from 04599bb to 7069b96 Compare April 15, 2026 14:17
@davdhacs davdhacs force-pushed the davdhacs/pr1c-logging-env branch 2 times, most recently from 5f95e8d to 88f5846 Compare April 15, 2026 14:50
Each logger that writes to a file spawns a lumberjack goroutine for
log rotation. With ~30 loggers writing to /var/log/stackrox/log.txt,
that's 30 idle goroutines + 30 independent file handles to the same
file. In container environments, logs go to stdout and are collected
by the container runtime — file logging is unnecessary overhead.

Set ROX_LOGGING_TO_FILE=false to disable file logging, saving:
- 30 goroutines and their stacks
- File I/O overhead
- lumberjack rotation processing

Default is true (unchanged behavior) for backward compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@davdhacs davdhacs force-pushed the davdhacs/pr1c-logging-env branch from 88f5846 to 6a491e9 Compare April 15, 2026 15:21
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.61%. Comparing base (4d2d701) to head (6a491e9).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20019      +/-   ##
==========================================
- Coverage   49.61%   49.61%   -0.01%     
==========================================
  Files        2765     2765              
  Lines      208628   208650      +22     
==========================================
+ Hits       103509   103513       +4     
- Misses      97462    97479      +17     
- Partials     7657     7658       +1     
Flag Coverage Δ
go-unit-tests 49.61% <100.00%> (-0.01%) ⬇️

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.

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