Skip to content

MON-4032: Add PrometheusOperatorAdmissionWebhookConfig to ClusterMonitoringSpec#2716

Open
danielmellado wants to merge 1 commit intoopenshift:masterfrom
danielmellado:prometheus-operator-admission-webhook-config
Open

MON-4032: Add PrometheusOperatorAdmissionWebhookConfig to ClusterMonitoringSpec#2716
danielmellado wants to merge 1 commit intoopenshift:masterfrom
danielmellado:prometheus-operator-admission-webhook-config

Conversation

@danielmellado
Copy link
Contributor

Add configuration options for the Prometheus Operator admission webhook
component in config/v1alpha1.

The new PrometheusOperatorAdmissionWebhookConfig struct supports:

  • resources: compute resource requests and limits
  • topologySpreadConstraints: pod distribution across topology domains

Signed-off-by: Daniel Mellado dmellado@fedoraproject.org

@openshift-ci-robot
Copy link

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
Copy link
Contributor

openshift-ci bot commented Feb 18, 2026

Hello @danielmellado! 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.

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a new optional field PrometheusOperatorAdmissionWebhookConfig to the ClusterMonitoringSpec API. The field enables configuration of the Prometheus Operator admission webhook component, including container resources and topology spread constraints. Changes include type definitions in the Go API, corresponding generated code (deepcopy and Swagger documentation methods), CRD manifest updates across multiple versions, and expanded test coverage validating resource configurations, topology constraints, and rejection scenarios.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description is directly related to the changeset, explaining the new configuration struct and its supported fields (resources and topologySpreadConstraints).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main change: adding PrometheusOperatorAdmissionWebhookConfig to ClusterMonitoringSpec, which is clearly reflected throughout all modified files.

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

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@openshift-ci openshift-ci bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Feb 18, 2026
@qodo-code-review
Copy link

ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan

Review Summary by Qodo

Add PrometheusOperatorAdmissionWebhookConfig to ClusterMonitoringSpec

✨ Enhancement 🧪 Tests 📝 Documentation

Grey Divider

Walkthroughs

Description
• Added PrometheusOperatorAdmissionWebhookConfig struct to ClusterMonitoringSpec with support
  for compute resource requests/limits and pod topology spread constraints
• Defined new configuration type with Resources and TopologySpreadConstraints fields, including
  comprehensive kubebuilder validation markers
• Generated all required Go code artifacts: OpenAPI schemas, Swagger documentation, and deepcopy
  methods
• Updated all CRD manifests (DevPreviewNoUpgrade, CustomNoUpgrade, TechPreviewNoUpgrade, and
  featuregated variants) across both config and payload directories with the new admission webhook
  configuration schema
• Added 10 comprehensive validation test cases covering valid configurations, edge cases, and error
  scenarios for the new admission webhook config
Diagram
flowchart LR
  A["ClusterMonitoringSpec"] -->|"adds field"| B["PrometheusOperatorAdmissionWebhookConfig"]
  B -->|"contains"| C["Resources"]
  B -->|"contains"| D["TopologySpreadConstraints"]
  E["types_cluster_monitoring.go"] -->|"defines"| B
  F["Generated Code"] -->|"includes"| G["OpenAPI Schema"]
  F -->|"includes"| H["Swagger Docs"]
  F -->|"includes"| I["DeepCopy Methods"]
  J["CRD Manifests"] -->|"updated with"| B
  K["Test Cases"] -->|"validates"| B
Loading

Grey Divider

File Changes

1. openapi/generated_openapi/zz_generated.openapi.go ✨ Enhancement +69/-1

Add OpenAPI schema for Prometheus Operator admission webhook config

• Added OpenAPI schema definition for PrometheusOperatorAdmissionWebhookConfig type
• Registered the new schema in the OpenAPI definitions map
• Updated ClusterMonitoringSpec schema to include prometheusOperatorAdmissionWebhookConfig field
 with detailed description
• Added PrometheusOperatorAdmissionWebhookConfig to the dependencies list for
 ClusterMonitoringSpec

openapi/generated_openapi/zz_generated.openapi.go


2. config/v1alpha1/zz_generated.swagger_doc_generated.go 📝 Documentation +11/-0

Add Swagger documentation for admission webhook configuration

• Added swagger documentation map for PrometheusOperatorAdmissionWebhookConfig struct
• Documented the resources field describing compute resource requests and limits
• Documented the topologySpreadConstraints field for pod distribution across topology domains
• Added field documentation to ClusterMonitoringSpec for the new admission webhook config

config/v1alpha1/zz_generated.swagger_doc_generated.go


3. config/v1alpha1/types_cluster_monitoring.go ✨ Enhancement +51/-0

Define PrometheusOperatorAdmissionWebhookConfig type and add to spec

• Added PrometheusOperatorAdmissionWebhookConfig field to ClusterMonitoringSpec struct
• Defined new PrometheusOperatorAdmissionWebhookConfig struct with Resources and
 TopologySpreadConstraints fields
• Added comprehensive comments documenting the admission webhook component and its configuration
 options
• Applied kubebuilder validation markers for field constraints (MinProperties, MaxItems, MinItems,
 list types)

config/v1alpha1/types_cluster_monitoring.go


View more (9)
4. config/v1alpha1/zz_generated.deepcopy.go ✨ Enhancement +31/-0

Generate deepcopy methods for admission webhook configuration

• Generated DeepCopyInto method for PrometheusOperatorAdmissionWebhookConfig struct
• Generated DeepCopy method for PrometheusOperatorAdmissionWebhookConfig struct
• Updated ClusterMonitoringSpec.DeepCopyInto to include deep copy of the new admission webhook
 config field

config/v1alpha1/zz_generated.deepcopy.go


5. config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-DevPreviewNoUpgrade.crd.yaml ⚙️ Configuration changes +278/-0

Add admission webhook config to DevPreviewNoUpgrade CRD manifest

• Added prometheusOperatorAdmissionWebhookConfig field to ClusterMonitoring CRD schema
• Defined resources property with ContainerResource items supporting CPU, memory, and HugePages
 constraints
• Defined topologySpreadConstraints property with Kubernetes TopologySpreadConstraint items
• Applied validation constraints including minProperties, maxItems, minItems, and list map keys

config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-DevPreviewNoUpgrade.crd.yaml


6. config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-CustomNoUpgrade.crd.yaml ⚙️ Configuration changes +278/-0

Add admission webhook config to CustomNoUpgrade CRD manifest

• Added prometheusOperatorAdmissionWebhookConfig field to ClusterMonitoring CRD schema
• Defined resources property with ContainerResource items supporting CPU, memory, and HugePages
 constraints
• Defined topologySpreadConstraints property with Kubernetes TopologySpreadConstraint items
• Applied validation constraints including minProperties, maxItems, minItems, and list map keys

config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-CustomNoUpgrade.crd.yaml


7. config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-TechPreviewNoUpgrade.crd.yaml ⚙️ Configuration changes +278/-0

Add admission webhook config to TechPreviewNoUpgrade CRD manifest

• Added prometheusOperatorAdmissionWebhookConfig field to ClusterMonitoring CRD schema
• Defined resources property with ContainerResource items supporting CPU, memory, and HugePages
 constraints
• Defined topologySpreadConstraints property with Kubernetes TopologySpreadConstraint items
• Applied validation constraints including minProperties, maxItems, minItems, and list map keys

config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-TechPreviewNoUpgrade.crd.yaml


8. config/v1alpha1/zz_generated.featuregated-crd-manifests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml ⚙️ Configuration changes +278/-0

Add admission webhook config to featuregated CRD manifest

• Added prometheusOperatorAdmissionWebhookConfig field to ClusterMonitoring CRD schema
• Defined resources property with ContainerResource items supporting CPU, memory, and HugePages
 constraints
• Defined topologySpreadConstraints property with Kubernetes TopologySpreadConstraint items
• Applied validation constraints including minProperties, maxItems, minItems, and list map keys

config/v1alpha1/zz_generated.featuregated-crd-manifests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml


9. payload-manifests/crds/0000_10_config-operator_01_clustermonitorings-DevPreviewNoUpgrade.crd.yaml ⚙️ Configuration changes +278/-0

Add admission webhook config to payload DevPreviewNoUpgrade CRD

• Added prometheusOperatorAdmissionWebhookConfig field to ClusterMonitoring CRD schema
• Defined resources property with ContainerResource items supporting CPU, memory, and HugePages
 constraints
• Defined topologySpreadConstraints property with Kubernetes TopologySpreadConstraint items
• Applied validation constraints including minProperties, maxItems, minItems, and list map keys

payload-manifests/crds/0000_10_config-operator_01_clustermonitorings-DevPreviewNoUpgrade.crd.yaml


10. payload-manifests/crds/0000_10_config-operator_01_clustermonitorings-CustomNoUpgrade.crd.yaml ⚙️ Configuration changes +278/-0

Add admission webhook config to payload CustomNoUpgrade CRD

• Added prometheusOperatorAdmissionWebhookConfig field to ClusterMonitoring CRD schema
• Defined resources property with ContainerResource items supporting CPU, memory, and HugePages
 constraints
• Defined topologySpreadConstraints property with Kubernetes TopologySpreadConstraint items
• Applied validation constraints including minProperties, maxItems, minItems, and list map keys

payload-manifests/crds/0000_10_config-operator_01_clustermonitorings-CustomNoUpgrade.crd.yaml


11. payload-manifests/crds/0000_10_config-operator_01_clustermonitorings-TechPreviewNoUpgrade.crd.yaml ⚙️ Configuration changes +278/-0

Add admission webhook config to payload TechPreviewNoUpgrade CRD

• Added prometheusOperatorAdmissionWebhookConfig field to ClusterMonitoring CRD schema
• Defined resources property with ContainerResource items supporting CPU, memory, and HugePages
 constraints
• Defined topologySpreadConstraints property with Kubernetes TopologySpreadConstraint items
• Applied validation constraints including minProperties, maxItems, minItems, and list map keys

payload-manifests/crds/0000_10_config-operator_01_clustermonitorings-TechPreviewNoUpgrade.crd.yaml


12. config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml 🧪 Tests +203/-3

Add PrometheusOperatorAdmissionWebhookConfig validation test cases

• Fixed whitespace formatting issues (trailing spaces) in existing test cases
• Added 10 new comprehensive test cases for prometheusOperatorAdmissionWebhookConfig covering
 valid configurations with resources and topologySpreadConstraints
• Added validation test cases to ensure proper error handling for empty objects, exceeding
 resource/constraint limits, invalid resource limits, and empty arrays
• Tests validate both individual and combined configurations of resources and
 topologySpreadConstraints fields

config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml


Grey Divider

Qodo Logo

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 18, 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 everettraven 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

…toringSpec

Add configuration options for the Prometheus Operator admission webhook
component in config/v1alpha1.

The new PrometheusOperatorAdmissionWebhookConfig struct supports:
- resources: compute resource requests and limits
- topologySpreadConstraints: pod distribution across topology domains

Signed-off-by: Daniel Mellado <dmellado@fedoraproject.org>
@danielmellado danielmellado force-pushed the prometheus-operator-admission-webhook-config branch from e88103a to 6a78f8c Compare February 18, 2026 11:51
@qodo-code-review
Copy link

ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (1) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. PrometheusOperatorAdmissionWebhookConfig missing FeatureGate 📘 Rule violation ✓ Correctness
Description
The new PrometheusOperatorAdmissionWebhookConfig TechPreview API type is missing the
+openshift:enable:FeatureGate=<FeatureGateName> marker on both the new field in
ClusterMonitoringSpec and the struct definition itself. No corresponding FeatureGate entry for
this type was added to features/features.go, violating the requirement that every new TechPreview
API type be explicitly gated.
Code

config/v1alpha1/types_cluster_monitoring.go[R518-523]

+// PrometheusOperatorAdmissionWebhookConfig provides configuration options for the admission webhook
+// component of Prometheus Operator that runs in the `openshift-monitoring` namespace. The admission
+// webhook validates PrometheusRule and AlertmanagerConfig objects, mutates PrometheusRule annotations,
+// and converts AlertmanagerConfig objects between API versions.
+// +kubebuilder:validation:MinProperties=1
+type PrometheusOperatorAdmissionWebhookConfig struct {
Evidence
PR Compliance ID 10 requires every new TechPreview API type to have a corresponding FeatureGate
entry in features/features.go and the +openshift:enable:FeatureGate=<FeatureGateName> marker.
The new PrometheusOperatorAdmissionWebhookConfig struct has neither marker nor a new FeatureGate
in features/features.go. The only FeatureGate marker in types_cluster_monitoring.go is on the
top-level ClusterMonitoring type (+openshift:enable:FeatureGate=ClusterMonitoringConfig), and
features/features.go only defines FeatureGateClusterMonitoringConfig with no new entry for this
webhook config type.

AGENTS.md
config/v1alpha1/types_cluster_monitoring.go[518-523]
config/v1alpha1/types_cluster_monitoring.go[102-109]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `PrometheusOperatorAdmissionWebhookConfig` TechPreview API type and its corresponding field on `ClusterMonitoringSpec` are missing the `+openshift:enable:FeatureGate=&lt;FeatureGateName&gt;` marker. No new FeatureGate entry was added to `features/features.go` for this type.

## Issue Context
Per the project&#x27;s TechPreview API policy (PR Compliance ID 10), every new TechPreview API type must be gated by a FeatureGate. The parent `ClusterMonitoring` type uses `+openshift:enable:FeatureGate=ClusterMonitoringConfig` (defined in `features/features.go`). If this new type is intended to be included under the same gate, add the marker explicitly to both the field and the struct. If a new separate gate is required, add a new entry to `features/features.go` and reference it in the markers.

## Fix Focus Areas
- config/v1alpha1/types_cluster_monitoring.go[102-109]
- config/v1alpha1/types_cluster_monitoring.go[518-523]
- features/features.go[524-525]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Missing nodeSelector and tolerations fields 🐞 Bug ⛯ Reliability
Description
PrometheusOperatorAdmissionWebhookConfig omits nodeSelector and tolerations fields that are
present in both PrometheusOperatorConfig and MetricsServerConfig. Without tolerations, the admission
webhook pod cannot be scheduled on nodes with required taints, potentially making it unschedulable
and blocking all PrometheusRule and AlertmanagerConfig operations.
Code

config/v1alpha1/types_cluster_monitoring.go[R523-559]

+type PrometheusOperatorAdmissionWebhookConfig struct {
+	// resources defines the compute resource requests and limits for the
+	// prometheus-operator-admission-webhook container.
+	// This includes CPU, memory and HugePages constraints to help control scheduling and resource usage.
+	// When not specified, defaults are used by the platform. Requests cannot exceed limits.
+	// This field is optional.
+	// More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
+	// This is a simplified API that maps to Kubernetes ResourceRequirements.
+	// Maximum length for this list is 10.
+	// Minimum length for this list is 1.
+	// Each resource name must be unique within this list.
+	// +optional
+	// +listType=map
+	// +listMapKey=name
+	// +kubebuilder:validation:MaxItems=10
+	// +kubebuilder:validation:MinItems=1
+	Resources []ContainerResource `json:"resources,omitempty"`
+	// topologySpreadConstraints defines rules for how admission webhook Pods should be distributed
+	// across topology domains such as zones, nodes, or other user-defined labels.
+	// topologySpreadConstraints is optional.
+	// This helps improve high availability and resource efficiency by avoiding placing
+	// too many replicas in the same failure domain.
+	//
+	// When omitted, this means no opinion and the platform is left to choose a default, which is subject to change over time.
+	// This field maps directly to the `topologySpreadConstraints` field in the Pod spec.
+	// Default is empty list.
+	// Maximum length for this list is 10.
+	// Minimum length for this list is 1.
+	// Entries must have unique topologyKey and whenUnsatisfiable pairs.
+	// +kubebuilder:validation:MaxItems=10
+	// +kubebuilder:validation:MinItems=1
+	// +listType=map
+	// +listMapKey=topologyKey
+	// +listMapKey=whenUnsatisfiable
+	// +optional
+	TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
+}
Evidence
PrometheusOperatorConfig and MetricsServerConfig both define NodeSelector and Tolerations fields for
pod scheduling control, but the new PrometheusOperatorAdmissionWebhookConfig only exposes Resources
and TopologySpreadConstraints. The admission webhook is a critical component — if nodes require
taints that the webhook pod cannot tolerate, the pod becomes unschedulable.

config/v1alpha1/types_cluster_monitoring.go[437-516]
config/v1alpha1/types_cluster_monitoring.go[518-559]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `PrometheusOperatorAdmissionWebhookConfig` struct is missing `nodeSelector` and `tolerations` fields that exist in the sibling config structs `PrometheusOperatorConfig` and `MetricsServerConfig`. Without these fields, users cannot control which nodes the admission webhook pod is scheduled on, and cannot add tolerations to allow scheduling on tainted nodes. Since the admission webhook validates all `PrometheusRule` and `AlertmanagerConfig` objects, an unschedulable webhook pod would block those operations cluster-wide.

## Issue Context
- `PrometheusOperatorConfig` (lines 437–516) defines `NodeSelector map[string]string` and `Tolerations []v1.Toleration`
- `MetricsServerConfig` (lines 349–432) defines the same fields
- `PrometheusOperatorAdmissionWebhookConfig` (lines 518–559) only defines `Resources` and `TopologySpreadConstraints`
- The CRD and OpenAPI generated files would also need to be regenerated

## Fix Focus Areas
- config/v1alpha1/types_cluster_monitoring.go[518-559]
- config/v1alpha1/zz_generated.deepcopy.go[1066-1094]
- config/v1alpha1/zz_generated.swagger_doc_generated.go[222-230]
- config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-CustomNoUpgrade.crd.yaml[1289-1566]
- config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-DevPreviewNoUpgrade.crd.yaml[1289-1566]
- config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-TechPreviewNoUpgrade.crd.yaml[1289-1566]
- config/v1alpha1/zz_generated.featuregated-crd-manifests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml[1289-1566]
- openapi/generated_openapi/zz_generated.openapi.go[24099-24157]
- config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml[354-553]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Missing duplicate resource name rejection test 🐞 Bug ✓ Correctness
Description
The new tests for prometheusOperatorAdmissionWebhookConfig.resources do not include a test case
for duplicate resource names, even though an equivalent test exists for
alertmanagerConfig.customConfig.resources and the CRD enforces uniqueness via
x-kubernetes-list-type: map. This leaves the uniqueness enforcement unvalidated for the new field.
Code

config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml[R456-553]

+    - name: Should reject PrometheusOperatorAdmissionWebhookConfig with too many resources
+      initial: |
+        apiVersion: config.openshift.io/v1alpha1
+        kind: ClusterMonitoring
+        spec:
+          prometheusOperatorAdmissionWebhookConfig:
+            resources:
+              - name: "cpu"
+                request: "100m"
+              - name: "memory"
+                request: "64Mi"
+              - name: "hugepages-2Mi"
+                request: "32Mi"
+              - name: "hugepages-1Gi"
+                request: "1Gi"
+              - name: "ephemeral-storage"
+                request: "1Gi"
+              - name: "nvidia.com/gpu"
+                request: "1"
+              - name: "example.com/foo"
+                request: "1"
+              - name: "example.com/bar"
+                request: "1"
+              - name: "example.com/baz"
+                request: "1"
+              - name: "example.com/qux"
+                request: "1"
+              - name: "example.com/quux"
+                request: "1"
+      expectedError: 'spec.prometheusOperatorAdmissionWebhookConfig.resources: Too many: 11: must have at most 10 items'
+    - name: Should reject PrometheusOperatorAdmissionWebhookConfig with limit less than request
+      initial: |
+        apiVersion: config.openshift.io/v1alpha1
+        kind: ClusterMonitoring
+        spec:
+          prometheusOperatorAdmissionWebhookConfig:
+            resources:
+              - name: "cpu"
+                request: "500m"
+                limit: "200m"
+      expectedError: 'spec.prometheusOperatorAdmissionWebhookConfig.resources[0]: Invalid value: "object": limit must be greater than or equal to request'
+    - name: Should reject PrometheusOperatorAdmissionWebhookConfig with too many topologySpreadConstraints
+      initial: |
+        apiVersion: config.openshift.io/v1alpha1
+        kind: ClusterMonitoring
+        spec:
+          prometheusOperatorAdmissionWebhookConfig:
+            topologySpreadConstraints:
+              - maxSkew: 1
+                topologyKey: "zone1"
+                whenUnsatisfiable: DoNotSchedule
+              - maxSkew: 1
+                topologyKey: "zone2"
+                whenUnsatisfiable: DoNotSchedule
+              - maxSkew: 1
+                topologyKey: "zone3"
+                whenUnsatisfiable: DoNotSchedule
+              - maxSkew: 1
+                topologyKey: "zone4"
+                whenUnsatisfiable: DoNotSchedule
+              - maxSkew: 1
+                topologyKey: "zone5"
+                whenUnsatisfiable: DoNotSchedule
+              - maxSkew: 1
+                topologyKey: "zone6"
+                whenUnsatisfiable: DoNotSchedule
+              - maxSkew: 1
+                topologyKey: "zone7"
+                whenUnsatisfiable: DoNotSchedule
+              - maxSkew: 1
+                topologyKey: "zone8"
+                whenUnsatisfiable: DoNotSchedule
+              - maxSkew: 1
+                topologyKey: "zone9"
+                whenUnsatisfiable: DoNotSchedule
+              - maxSkew: 1
+                topologyKey: "zone10"
+                whenUnsatisfiable: DoNotSchedule
+              - maxSkew: 1
+                topologyKey: "zone11"
+                whenUnsatisfiable: DoNotSchedule
+      expectedError: 'spec.prometheusOperatorAdmissionWebhookConfig.topologySpreadConstraints: Too many: 11: must have at most 10 items'
+    - name: Should reject PrometheusOperatorAdmissionWebhookConfig with empty topologySpreadConstraints array
+      initial: |
+        apiVersion: config.openshift.io/v1alpha1
+        kind: ClusterMonitoring
+        spec:
+          prometheusOperatorAdmissionWebhookConfig:
+            topologySpreadConstraints: []
+      expectedError: 'spec.prometheusOperatorAdmissionWebhookConfig.topologySpreadConstraints: Invalid value: 0: spec.prometheusOperatorAdmissionWebhookConfig.topologySpreadConstraints in body should have at least 1 items'
+    - name: Should reject PrometheusOperatorAdmissionWebhookConfig with empty resources array
+      initial: |
+        apiVersion: config.openshift.io/v1alpha1
+        kind: ClusterMonitoring
+        spec:
+          prometheusOperatorAdmissionWebhookConfig:
+            resources: []
+      expectedError: 'spec.prometheusOperatorAdmissionWebhookConfig.resources: Invalid value: 0: spec.prometheusOperatorAdmissionWebhookConfig.resources in body should have at least 1 items'
Evidence
The test file has a 'Should reject ContainerResource with duplicate names' test for
alertmanagerConfig.customConfig.resources (lines 21-36), but the new test block for
prometheusOperatorAdmissionWebhookConfig (lines 354-553 in the diff) covers only: valid resources,
valid topologySpreadConstraints, both fields, empty object, too many resources, limit < request, too
many topologySpreadConstraints, and empty arrays — but not duplicate resource names. The CRD sets
x-kubernetes-list-map-keys: [name] and x-kubernetes-list-type: map for this field, so the validation
exists but is untested.

config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml[21-36]
config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-CustomNoUpgrade.crd.yaml[1371-1373]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The test suite for `prometheusOperatorAdmissionWebhookConfig` is missing a test case that verifies duplicate resource names are rejected. The `resources` field uses `x-kubernetes-list-type: map` with `x-kubernetes-list-map-keys: [name]`, which enforces uniqueness at the API server level, but this behavior is not explicitly tested for the new field.

## Issue Context
- An equivalent test exists for `alertmanagerConfig.customConfig.resources` at lines 21-36 of the test YAML
- The new tests (lines 354-553 in the diff) cover many error cases but omit the duplicate-name scenario
- The CRD enforces uniqueness via `x-kubernetes-list-map-keys: [name]` and `x-kubernetes-list-type: map`

## Fix Focus Areas
- config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml[546-553]

Add the following test case after the existing rejection tests:
```yaml
- name: Should reject PrometheusOperatorAdmissionWebhookConfig with duplicate resource names
 initial: |
   apiVersion: config.openshift.io/v1alpha1
   kind: ClusterMonitoring
   spec:
     prometheusOperatorAdmissionWebhookConfig:
       resources:
         - name: &quot;cpu&quot;
           request: &quot;100m&quot;
         - name: &quot;cpu&quot;
           request: &quot;200m&quot;
 expectedError: &#x27;spec.prometheusOperatorAdmissionWebhookConfig.resources[1]: Duplicate value: map[string]interface {}{&quot;name&quot;:&quot;cpu&quot;}&#x27;
```

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 18, 2026

@danielmellado: 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.

@danielmellado
Copy link
Contributor Author

/cc @marioferh

@openshift-ci openshift-ci bot requested a review from marioferh February 18, 2026 12:28
@danielmellado danielmellado changed the title Add PrometheusOperatorAdmissionWebhookConfig to ClusterMonitoringSpec MON-4032: Add PrometheusOperatorAdmissionWebhookConfig to ClusterMonitoringSpec Feb 18, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 18, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 18, 2026

@danielmellado: This pull request references MON-4032 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 "4.22.0" version, but no target version was set.

Details

In response to this:

Add configuration options for the Prometheus Operator admission webhook
component in config/v1alpha1.

The new PrometheusOperatorAdmissionWebhookConfig struct supports:

  • resources: compute resource requests and limits
  • topologySpreadConstraints: pod distribution across topology domains

Signed-off-by: Daniel Mellado dmellado@fedoraproject.org

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.

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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments