Skip to content

MON-4565: Add enableUserAlertmanagerConfig to ClusterMonitoring API#2855

Open
marioferh wants to merge 1 commit into
openshift:masterfrom
marioferh:alertmanager_enableUserAlertmanagerConfig
Open

MON-4565: Add enableUserAlertmanagerConfig to ClusterMonitoring API#2855
marioferh wants to merge 1 commit into
openshift:masterfrom
marioferh:alertmanager_enableUserAlertmanagerConfig

Conversation

@marioferh
Copy link
Copy Markdown
Contributor

Restore parity with the cluster-monitoring-config ConfigMap field that was removed from AlertmanagerConfig during API review (#2148). When true, the platform Alertmanager in openshift-monitoring discovers AlertmanagerConfig resources in user-defined namespaces; this only applies when user-workload Alertmanager is not enabled. Omitted means false, matching the ConfigMap default.

Includes CRD/OpenAPI codegen and an integration test for the new field.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 21, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 21, 2026

@marioferh: This pull request references MON-4565 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Restore parity with the cluster-monitoring-config ConfigMap field that was removed from AlertmanagerConfig during API review (#2148). When true, the platform Alertmanager in openshift-monitoring discovers AlertmanagerConfig resources in user-defined namespaces; this only applies when user-workload Alertmanager is not enabled. Omitted means false, matching the ConfigMap default.

Includes CRD/OpenAPI codegen and an integration test for the new field.

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

📝 Walkthrough

Walkthrough

This PR replaces the prior boolean-style flag with an enum field named userAlertmanagerConfigSelection on AlertmanagerConfig (type UserAlertmanagerConfigSelection with values Selectable and None). The CRD is updated to include the new optional enum property with documentation and default behavior when omitted. Tests are added to verify that a Create with Selectable is accepted and preserved and that an unsupported value (Enabled) is rejected with the expected validation error.

🚥 Pre-merge checks | ✅ 9 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title refers to 'enableUserAlertmanagerConfig' but the changeset implements 'userAlertmanagerConfigSelection' as an enum field, not a boolean. The title is misleading about the actual implementation. Update the title to reflect the enum-based implementation, e.g., 'MON-4565: Add userAlertmanagerConfigSelection enum to ClusterMonitoring API' to accurately describe the field type.
Description check ⚠️ Warning The description mentions 'enableUserAlertmanagerConfig' as a boolean field matching the ConfigMap behavior, but the actual implementation uses 'userAlertmanagerConfigSelection' as a string enum with 'Selectable' and 'None' values. Update the description to clarify that the field is 'userAlertmanagerConfigSelection' (an enum) rather than 'enableUserAlertmanagerConfig' (a boolean), explaining the enum values and their meanings.
Microshift Test Compatibility ⚠️ Warning New Ginkgo e2e tests use config.openshift.io API (ClusterMonitoring) which is unavailable on MicroShift without any apigroup tag or MicroShift skip protection. Add [apigroup:config.openshift.io] tag to test names or use [Skipped:MicroShift] label, or implement runtime IsMicroShiftCluster() check to skip incompatible API tests.
✅ Passed checks (9 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Stable And Deterministic Test Names ✅ Passed All test names are stable and deterministic. The two test cases added contain no dynamic values, generated identifiers, timestamps, or other information that would change between test runs.
Test Structure And Quality ✅ Passed PR adds YAML test specs, not Ginkgo code, making check inapplicable. Generated tests follow patterns: single responsibility, cleanup, timeouts, assertion messages, consistency.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Tests validate CRD schema for userAlertmanagerConfigSelection field in envtest. They do not assume multiple nodes—only validate API schema without pod scheduling or topology constraints.
Topology-Aware Scheduling Compatibility ✅ Passed PR adds only API type definitions, CRD schemas, and tests. No deployment manifests, operator code, or controllers with scheduling constraints are modified or introduced.
Ote Binary Stdout Contract ✅ Passed PR adds only YAML test cases and type definitions with no process-level code that could write non-JSON stdout; existing test infrastructure properly redirects logging to GinkgoWriter.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR adds YAML declarative test cases, not Ginkgo e2e tests. These schema validation tests contain no networking code, IPv4 assumptions, or external connectivity.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Error: build linters: unable to load custom analyzer "kubeapilinter": tools/_output/bin/kube-api-linter.so, plugin: not implemented
The command is terminated due to an error: build linters: unable to load custom analyzer "kubeapilinter": tools/_output/bin/kube-api-linter.so, plugin: not implemented


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

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 21, 2026

Hello @marioferh! Some important instructions when contributing to openshift/api:
API design plays an important part in the user experience of OpenShift and as such API PRs are subject to a high level of scrutiny to ensure they follow our best practices. If you haven't already done so, please review the OpenShift API Conventions and ensure that your proposed changes are compliant. Following these conventions will help expedite the api review process for your PR.

@openshift-ci openshift-ci Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 21, 2026
@openshift-ci openshift-ci Bot requested review from JoelSpeed and everettraven May 21, 2026 08:09
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 21, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign joelspeed for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Restore parity with the cluster-monitoring-config ConfigMap field that
was removed from AlertmanagerConfig during API review (openshift#2148). When
true, the platform Alertmanager in openshift-monitoring discovers
AlertmanagerConfig resources in user-defined namespaces; this only
applies when user-workload Alertmanager is not enabled. Omitted means
false, matching the ConfigMap default.

Includes CRD/OpenAPI codegen and an integration test for the new field.

Co-authored-by: Cursor <cursoragent@cursor.com>
@marioferh marioferh force-pushed the alertmanager_enableUserAlertmanagerConfig branch from cbaa523 to 5c694c6 Compare May 21, 2026 09:05
Copy link
Copy Markdown

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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml`:
- Around line 21-39: Add a parallel test case for the other enum value by
duplicating the existing test named "Should accept
userAlertmanagerConfigSelection on alertmanagerConfig" and change the
alertmanagerConfig.userAlertmanagerConfigSelection value to "None" in both the
initial and expected YAML blocks; ensure the new test name reflects the change
(e.g., "Should accept userAlertmanagerConfigSelection None value on
alertmanagerConfig") and that the key userAlertmanagerConfigSelection appears
exactly as in the original so the test validates preservation of the "None"
enum.
- Around line 21-50: Add a new test case that verifies alertmanagerConfig can be
created without the optional field userAlertmanagerConfigSelection by adding an
entry named "Should accept alertmanagerConfig without
userAlertmanagerConfigSelection" that provides an initial ClusterMonitoring with
spec.alertmanagerConfig containing only deploymentMode: "DefaultConfig" and
expects the same object back; ensure you reference the alertmanagerConfig object
and the userAlertmanagerConfigSelection symbol so the test confirms omission is
accepted and defaults are handled.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: bb30ad99-c017-46cc-b23f-ec272ba53b23

📥 Commits

Reviewing files that changed from the base of the PR and between cbaa523 and 5c694c6.

⛔ Files ignored due to path filters (5)
  • config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings.crd.yaml is excluded by !**/zz_generated.crd-manifests/*
  • config/v1alpha1/zz_generated.featuregated-crd-manifests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • config/v1alpha1/zz_generated.swagger_doc_generated.go is excluded by !**/zz_generated*
  • openapi/generated_openapi/zz_generated.openapi.go is excluded by !openapi/**, !**/zz_generated*
  • openapi/openapi.json is excluded by !openapi/**
📒 Files selected for processing (3)
  • config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml
  • config/v1alpha1/types_cluster_monitoring.go
  • payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml

Comment on lines +21 to +39
- name: Should accept userAlertmanagerConfigSelection on alertmanagerConfig
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
userDefined:
mode: "Disabled"
alertmanagerConfig:
deploymentMode: "DefaultConfig"
userAlertmanagerConfigSelection: Selectable
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
userDefined:
mode: "Disabled"
alertmanagerConfig:
deploymentMode: "DefaultConfig"
userAlertmanagerConfigSelection: Selectable
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add test coverage for the "None" enum value.

The validation error on line 50 indicates that userAlertmanagerConfigSelection supports two values: "Selectable" and "None". Currently only "Selectable" is tested for acceptance. Add a similar test case that verifies "None" is also accepted and preserved.

📋 Proposed additional test case
    - name: Should accept userAlertmanagerConfigSelection None value on alertmanagerConfig
      initial: |
        apiVersion: config.openshift.io/v1alpha1
        kind: ClusterMonitoring
        spec:
          userDefined:
            mode: "Disabled"
          alertmanagerConfig:
            deploymentMode: "DefaultConfig"
            userAlertmanagerConfigSelection: None
      expected: |
        apiVersion: config.openshift.io/v1alpha1
        kind: ClusterMonitoring
        spec:
          userDefined:
            mode: "Disabled"
          alertmanagerConfig:
            deploymentMode: "DefaultConfig"
            userAlertmanagerConfigSelection: None
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml`
around lines 21 - 39, Add a parallel test case for the other enum value by
duplicating the existing test named "Should accept
userAlertmanagerConfigSelection on alertmanagerConfig" and change the
alertmanagerConfig.userAlertmanagerConfigSelection value to "None" in both the
initial and expected YAML blocks; ensure the new test name reflects the change
(e.g., "Should accept userAlertmanagerConfigSelection None value on
alertmanagerConfig") and that the key userAlertmanagerConfigSelection appears
exactly as in the original so the test validates preservation of the "None"
enum.

Comment on lines +21 to +50
- name: Should accept userAlertmanagerConfigSelection on alertmanagerConfig
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
userDefined:
mode: "Disabled"
alertmanagerConfig:
deploymentMode: "DefaultConfig"
userAlertmanagerConfigSelection: Selectable
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
userDefined:
mode: "Disabled"
alertmanagerConfig:
deploymentMode: "DefaultConfig"
userAlertmanagerConfigSelection: Selectable
- name: Should reject invalid userAlertmanagerConfigSelection on alertmanagerConfig
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
userDefined:
mode: "Disabled"
alertmanagerConfig:
deploymentMode: "DefaultConfig"
userAlertmanagerConfigSelection: Enabled
expectedError: 'spec.alertmanagerConfig.userAlertmanagerConfigSelection: Unsupported value: "Enabled": supported values: "Selectable", "None"'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add test coverage for optional field behavior.

Per the PR summary and AI-generated description, userAlertmanagerConfigSelection is an optional field. Add a test case that explicitly verifies an alertmanagerConfig object can be created without this field, confirming the optional behavior and default handling.

📋 Proposed additional test case
    - name: Should accept alertmanagerConfig without userAlertmanagerConfigSelection
      initial: |
        apiVersion: config.openshift.io/v1alpha1
        kind: ClusterMonitoring
        spec:
          userDefined:
            mode: "Disabled"
          alertmanagerConfig:
            deploymentMode: "DefaultConfig"
      expected: |
        apiVersion: config.openshift.io/v1alpha1
        kind: ClusterMonitoring
        spec:
          userDefined:
            mode: "Disabled"
          alertmanagerConfig:
            deploymentMode: "DefaultConfig"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml`
around lines 21 - 50, Add a new test case that verifies alertmanagerConfig can
be created without the optional field userAlertmanagerConfigSelection by adding
an entry named "Should accept alertmanagerConfig without
userAlertmanagerConfigSelection" that provides an initial ClusterMonitoring with
spec.alertmanagerConfig containing only deploymentMode: "DefaultConfig" and
expects the same object back; ensure you reference the alertmanagerConfig object
and the userAlertmanagerConfigSelection symbol so the test confirms omission is
accepted and defaults are handled.

// When omitted, the default value is None.
// +optional
// +kubebuilder:validation:Enum=Selectable;None
UserAlertmanagerConfigSelection UserAlertmanagerConfigSelection `json:"userAlertmanagerConfigSelection,omitempty"`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should this be moved to AlertmanagerCustomConfig instead?

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 21, 2026

@marioferh: all tests passed!

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.

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants