Skip to content

feat: config property to set watched namespaces - #3613

Open
csviri wants to merge 1 commit into
operator-framework:mainfrom
csviri:watched-namespaces
Open

feat: config property to set watched namespaces#3613
csviri wants to merge 1 commit into
operator-framework:mainfrom
csviri:watched-namespaces

Conversation

@csviri

@csviri csviri commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Adds josdk.controller.<name>.namespaces to ConfigLoader, which was
previously the only way of configuring watched namespaces that was not
available from an external configuration source.

The value is a comma-separated list; entries are trimmed and blank ones
ignored. The special values JOSDK_ALL_NAMESPACES and JOSDK_WATCH_CURRENT
are supported but, as everywhere else, only on their own. Validation
happens while building the consumer, so an invalid value fails at wiring
time rather than at reconciliation time.

Signed-off-by: Attila Mészáros a_meszaros@apple.com

Summary by CodeRabbit

  • New Features

    • Added support for configuring watched namespaces through the josdk.controller.<name>.namespaces property.
    • Supports individual or comma-separated namespaces, with whitespace trimming and blank entries ignored.
    • Added options to watch all namespaces or only the operator’s current namespace.
    • Namespace settings can replace annotation-based defaults and remain adjustable at runtime.
  • Documentation

    • Added configuration guidance, supported values, validation rules, and usage examples for watched namespaces.

Adds `josdk.controller.<name>.namespaces` to ConfigLoader, which was
previously the only way of configuring watched namespaces that was not
available from an external configuration source.

The value is a comma-separated list; entries are trimmed and blank ones
ignored. The special values JOSDK_ALL_NAMESPACES and JOSDK_WATCH_CURRENT
are supported but, as everywhere else, only on their own. Validation
happens while building the consumer, so an invalid value fails at wiring
time rather than at reconciliation time.

Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Copilot AI lite review requested due to automatic review settings September 11, 2026 10:44
@openshift-ci
openshift-ci Bot requested review from metacosm and xstefank September 11, 2026 10:44
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 7b5d79e6-0d8b-4e2a-a004-c5138ecd7206

📥 Commits

Reviewing files that changed from the base of the PR and between 39af5f0 and 9080d2f.

📒 Files selected for processing (4)
  • docs/content/en/docs/documentation/operations/configuration.md
  • operator-framework/src/main/java/io/javaoperatorsdk/operator/config/loader/ConfigLoader.java
  • operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/configloader/ConfigLoaderIT.java
  • operator-framework/src/test/java/io/javaoperatorsdk/operator/config/loader/ConfigLoaderTest.java

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change adds controller-level watched namespace configuration. ConfigLoader parses and validates the namespaces property, applies it to informer configuration, and documents the supported values. Unit and integration tests cover parsing, validation, isolation, and application.

Changes

Controller namespace configuration

Layer / File(s) Summary
Namespace property parsing and application
operator-framework/src/main/java/io/javaoperatorsdk/operator/config/loader/ConfigLoader.java
ConfigLoader reads the controller namespaces property, trims and filters entries, validates special values, and applies the result through settingNamespaces.
Namespace parsing validation
operator-framework/src/test/java/io/javaoperatorsdk/operator/config/loader/ConfigLoaderTest.java
Tests cover defaults, single and multiple namespaces, trimming, special namespace values, invalid input, and controller-name isolation.
Integration coverage and configuration documentation
operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/configloader/ConfigLoaderIT.java, docs/content/en/docs/documentation/operations/configuration.md
Integration tests verify that configured namespaces replace the default all-namespaces watch. Documentation describes the property and its supported values.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ConfigLoader
  participant ControllerConfigurationOverrider
  participant InformerConfiguration
  ConfigLoader->>ConfigLoader: Read and parse controller namespaces
  ConfigLoader->>ControllerConfigurationOverrider: Apply settingNamespaces(namespaces)
  ControllerConfigurationOverrider->>InformerConfiguration: Update watched namespace settings
Loading

Merge Risk: ⚪ Minimal · up to 9080d

The new controller namespace configuration is parsed, validated, applied, and documented consistently, with coverage for default, special, invalid, and multi-controller cases.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 3 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a configuration property for setting watched namespaces.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copilot AI left a comment

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.

🟢 Approval recommended

No unresolved review issues were identified.

Pull request overview

Adds external configuration for controller watched namespaces via josdk.controller.<name>.namespaces.

Changes:

  • Parses, trims, and validates comma-separated namespaces.
  • Supports JOSDK_ALL_NAMESPACES and JOSDK_WATCH_CURRENT.
  • Adds unit, integration, and documentation coverage.
File summaries
File Description
operator-framework/src/test/java/io/javaoperatorsdk/operator/config/loader/ConfigLoaderTest.java Tests namespace configuration behavior.
operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/configloader/ConfigLoaderIT.java Verifies configuration wiring.
operator-framework/src/main/java/io/javaoperatorsdk/operator/config/loader/ConfigLoader.java Implements namespace parsing and validation.
docs/content/en/docs/documentation/operations/configuration.md Documents the new property and supported values.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Consumer<ControllerConfigurationOverrider<R>> buildNamespacesConsumer(String prefix) {
final var key = prefix + NAMESPACES_SUFFIX;
final var value = configProvider.getValue(key, String.class);
if (value.isEmpty()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe trim as early return?

Comment on lines +566 to +572
java.util.function.Consumer<
io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider<
io.fabric8.kubernetes.api.model.ConfigMap>>
consumer) {
var overrider =
io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider.override(
baseControllerConfig());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

import is not possible?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants