MON-4565: Add enableUserAlertmanagerConfig to ClusterMonitoring API#2855
MON-4565: Add enableUserAlertmanagerConfig to ClusterMonitoring API#2855marioferh wants to merge 1 commit into
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@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. DetailsIn response to this:
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. |
📝 WalkthroughWalkthroughThis 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)
✅ Passed checks (9 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 Comment |
|
Hello @marioferh! Some important instructions when contributing to openshift/api: |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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>
cbaa523 to
5c694c6
Compare
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (5)
config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings.crd.yamlis excluded by!**/zz_generated.crd-manifests/*config/v1alpha1/zz_generated.featuregated-crd-manifests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yamlis excluded by!**/zz_generated.featuregated-crd-manifests/**config/v1alpha1/zz_generated.swagger_doc_generated.gois excluded by!**/zz_generated*openapi/generated_openapi/zz_generated.openapi.gois excluded by!openapi/**,!**/zz_generated*openapi/openapi.jsonis excluded by!openapi/**
📒 Files selected for processing (3)
config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yamlconfig/v1alpha1/types_cluster_monitoring.gopayload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml
| - 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 |
There was a problem hiding this comment.
🛠️ 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.
| - 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"' |
There was a problem hiding this comment.
🛠️ 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"` |
There was a problem hiding this comment.
should this be moved to AlertmanagerCustomConfig instead?
|
@marioferh: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
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.