Skip to content

Conversation

@aayushchouhan09
Copy link
Member

@aayushchouhan09 aayushchouhan09 commented Dec 16, 2025

Describe the Problem

Currently, bucket capacity alert thresholds (80% and 95%) are hardcoded in PrometheusRule (in noobaa-operator). So, we made them configurable from noobaa CR and set the env vars which can be exported as metrics from noobaa core.

Explain the Changes

  1. Exported two metrics: bucket_low_capacity_threshold and bucket_no_capacity_threshold

Issues: Fixed #xxx / Gap #xxx

  1. JIRA: https://issues.redhat.com/browse/RHSTOR-7492
  2. Operator PR: Allow configurable threshold values for noobaa alerts noobaa-operator#1750

Testing Instructions:

  1. See instructions in the operator PR.
  • Doc added/updated
  • Tests added

Summary by CodeRabbit

  • New Features
    • Introduced configurable bucket capacity threshold settings to monitor low and no capacity states, customizable via environment variables with preset defaults (80% and 95%)
    • Added quota configuration option to define maximum objects limit with safe integer boundary protection
    • Expanded system monitoring and analytics capabilities with new Prometheus metrics for real-time bucket capacity threshold tracking and reporting

✏️ Tip: You can customize this high-level summary in your review settings.

…eshold and Noobaa_bucket_no_capacity_threshold

Signed-off-by: Aayush Chouhan <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Dec 16, 2025

Walkthrough

The changes add new bucket capacity threshold configuration options (BUCKET_LOW_CAPACITY_THRESHOLD and BUCKET_NO_CAPACITY_THRESHOLD) and a QUOTA_MAX_OBJECTS configuration to config.js, introduce corresponding Prometheus Gauge metrics in the core report, and update the stats aggregator to populate these metrics from environment-configured values.

Changes

Cohort / File(s) Summary
Configuration additions
config.js
Added three new configuration properties: BUCKET_LOW_CAPACITY_THRESHOLD (defaults to 80), BUCKET_NO_CAPACITY_THRESHOLD (defaults to 95), and QUOTA_MAX_OBJECTS (set to Number.MAX_SAFE_INTEGER), each pulled from corresponding environment variables.
Prometheus metrics
src/server/analytic_services/prometheus_reports/noobaa_core_report.js
Added two new Gauge metrics to NOOBAA_CORE_METRICS: bucket_low_capacity_threshold and bucket_no_capacity_threshold, both with auto-generated set methods and help text describing their purpose as percentage thresholds.
Metrics population
src/server/system_services/stats_aggregator.js
Added two lines to populate the new bucket capacity threshold metrics from config values during Prometheus metrics parsing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

  • Verify configuration defaults (80 and 95 percentages) are appropriate for intended use
  • Confirm environment variable names are consistent across config.js and stats_aggregator.js
  • Ensure new metrics are actually consumed by downstream monitoring/alerting systems

Possibly related PRs

Suggested labels

size/M

Suggested reviewers

  • liranmauda
  • naveenpaul1

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective: exporting bucket capacity threshold values as Prometheus metrics derived from environment variables.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@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: 0

🧹 Nitpick comments (1)
config.js (1)

624-627: Consider validating threshold values.

The threshold percentages accept any integer value without validation. Consider adding checks to ensure:

  • Both values are between 0 and 100
  • BUCKET_LOW_CAPACITY_THRESHOLD < BUCKET_NO_CAPACITY_THRESHOLD

Invalid thresholds could lead to incorrect alerting behavior in the operator's PrometheusRule.

Example validation:

 // Bucket capacity thresholds (percentage)
-config.BUCKET_LOW_CAPACITY_THRESHOLD = parseInt(process.env.BUCKET_LOW_CAPACITY_THRESHOLD, 10) || 80;
-config.BUCKET_NO_CAPACITY_THRESHOLD = parseInt(process.env.BUCKET_NO_CAPACITY_THRESHOLD, 10) || 95;
+const low_threshold = parseInt(process.env.BUCKET_LOW_CAPACITY_THRESHOLD, 10) || 80;
+const no_threshold = parseInt(process.env.BUCKET_NO_CAPACITY_THRESHOLD, 10) || 95;
+
+if (low_threshold < 0 || low_threshold > 100 || no_threshold < 0 || no_threshold > 100) {
+    throw new Error(`Bucket capacity thresholds must be between 0 and 100. Got LOW=${low_threshold}, NO=${no_threshold}`);
+}
+if (low_threshold >= no_threshold) {
+    throw new Error(`BUCKET_LOW_CAPACITY_THRESHOLD (${low_threshold}) must be less than BUCKET_NO_CAPACITY_THRESHOLD (${no_threshold})`);
+}
+
+config.BUCKET_LOW_CAPACITY_THRESHOLD = low_threshold;
+config.BUCKET_NO_CAPACITY_THRESHOLD = no_threshold;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a788fb and e4a1987.

📒 Files selected for processing (3)
  • config.js (2 hunks)
  • src/server/analytic_services/prometheus_reports/noobaa_core_report.js (1 hunks)
  • src/server/system_services/stats_aggregator.js (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: liranmauda
Repo: noobaa/noobaa-core PR: 9174
File: config.js:1044-1046
Timestamp: 2025-07-30T10:20:09.402Z
Learning: The NooBaa config.js file has a built-in environment variable override system via `load_config_env_overrides()` function. Any config property can be overridden using environment variables prefixed with `CONFIG_JS_`. For example, `CONFIG_JS_NC_HEALTH_BUCKETS_COUNT_LIMIT=10000` would override `config.NC_HEALTH_BUCKETS_COUNT_LIMIT`. The system handles type conversion automatically and provides consistent override patterns across all config values.
📚 Learning: 2025-07-30T10:20:09.402Z
Learnt from: liranmauda
Repo: noobaa/noobaa-core PR: 9174
File: config.js:1044-1046
Timestamp: 2025-07-30T10:20:09.402Z
Learning: The NooBaa config.js file has a built-in environment variable override system via `load_config_env_overrides()` function. Any config property can be overridden using environment variables prefixed with `CONFIG_JS_`. For example, `CONFIG_JS_NC_HEALTH_BUCKETS_COUNT_LIMIT=10000` would override `config.NC_HEALTH_BUCKETS_COUNT_LIMIT`. The system handles type conversion automatically and provides consistent override patterns across all config values.

Applied to files:

  • config.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: run-package-lock-validation
  • GitHub Check: Build Noobaa Image
  • GitHub Check: run-jest-unit-tests
🔇 Additional comments (3)
src/server/system_services/stats_aggregator.js (1)

1068-1070: LGTM! Threshold metrics correctly wired.

The bucket capacity threshold values are properly set from config and exported as Prometheus metrics using the auto-generated setters.

config.js (1)

1126-1126: Clarify relevance of QUOTA_MAX_OBJECTS.

The addition of QUOTA_MAX_OBJECTS is not mentioned in the PR objectives, which focus on bucket capacity thresholds. Is this configuration intentionally included in this PR, or should it be part of a separate change?

src/server/analytic_services/prometheus_reports/noobaa_core_report.js (1)

434-448: LGTM! Threshold metrics properly defined.

The new Gauge metrics for bucket capacity thresholds are correctly defined with generate_default_set: true, which will auto-generate the setter methods used by stats_aggregator. The help text clearly identifies these as percentage values.

@dannyzaken
Copy link
Member

@aayushchouhan09 I don't really understand this PR. Why do we need to pass an env from the operator to the core just to export it as a constant metric that is only used by another resource created by the operator? I believe we can come up with a simpler solution.

@aayushchouhan09
Copy link
Member Author

aayushchouhan09 commented Dec 22, 2025

@aayushchouhan09 I don't really understand this PR. Why do we need to pass an env from the operator to the core just to export it as a constant metric that is only used by another resource created by the operator? I believe we can come up with a simpler solution.

Thanks @dannyzaken
This make sense. The simple approach here is we can just directly update the PrometheusRule in ReconcilePrometheusRule() method in the operator PR also we can close this PR (as it is of no use).

I will update the operator PR with the changes (and will keep this PR open until we merge that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants