Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

MON-4032: Add PrometheusOperatorAdmissionWebhookConfig to ClusterMonitoringSpec#2716

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

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

Conversation

@danielmellado
Copy link
Contributor

@danielmellado danielmellado commented Feb 18, 2026

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

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

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.

Copy link

coderabbitai bot commented Feb 18, 2026
edited by openshift-ci bot
Loading

No actionable comments were generated in the recent review. 🎉

i️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 3d20ace and 036e9b1.

⛔ Files ignored due to path filters (5)
  • config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-CustomNoUpgrade.crd.yaml is excluded by !**/zz_generated.crd-manifests/*
  • config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-DevPreviewNoUpgrade.crd.yaml is excluded by !**/zz_generated.crd-manifests/*
  • config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings-TechPreviewNoUpgrade.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/**
  • openapi/generated_openapi/zz_generated.openapi.go is excluded by !openapi/**
📒 Files selected for processing (7)
  • config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml
  • config/v1alpha1/types_cluster_monitoring.go
  • config/v1alpha1/zz_generated.deepcopy.go
  • config/v1alpha1/zz_generated.swagger_doc_generated.go
  • payload-manifests/crds/0000_10_config-operator_01_clustermonitorings-CustomNoUpgrade.crd.yaml
  • payload-manifests/crds/0000_10_config-operator_01_clustermonitorings-DevPreviewNoUpgrade.crd.yaml
  • payload-manifests/crds/0000_10_config-operator_01_clustermonitorings-TechPreviewNoUpgrade.crd.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/v1alpha1/zz_generated.deepcopy.go

📝 Walkthrough

Walkthrough

Adds a new optional field prometheusOperatorAdmissionWebhookConfig to ClusterMonitoringSpec (type PrometheusOperatorAdmissionWebhookConfig) to configure the Prometheus Operator admission webhook. Introduces the new exported type with resources and topologySpreadConstraints fields and kubebuilder validations, updates generated deepcopy and Swagger docs, extends CRD payloads (DevPreview/TechPreview/CustomNoUpgrade) to include the new schema (observed duplicated insertion in CRD), and adds tests covering valid and invalid webhook configurations.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'MON-4032: Add PrometheusOperatorAdmissionWebhookConfig to ClusterMonitoringSpec' accurately and specifically summarizes the main change, clearly identifying the new configuration struct being added.
Description check ✅ Passed The description is directly related to the changeset, providing context about the new PrometheusOperatorAdmissionWebhookConfig 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.

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

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

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.5.0)

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 openshift-ci bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Feb 18, 2026
Copy link

i 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

@danielmellado danielmellado force-pushed the prometheus-operator-admission-webhook-config branch from e88103a to 6a78f8c Compare February 18, 2026 11:51
Copy link

i 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]

i 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]

i 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;
```

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


Grey Divider

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

Grey Divider

Qodo Logo

Copy link
Contributor Author

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

openshift-ci-robot commented Feb 18, 2026
edited by openshift-ci bot
Loading

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

@danielmellado danielmellado force-pushed the prometheus-operator-admission-webhook-config branch from 6a78f8c to 3d20ace Compare February 23, 2026 10:28
...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 3d20ace to 036e9b1 Compare February 23, 2026 12:32
Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 23, 2026
Copy link

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-ovn
/test e2e-aws-ovn-hypershift
/test e2e-aws-ovn-hypershift-conformance
/test e2e-aws-ovn-techpreview
/test e2e-aws-serial-1of2
/test e2e-aws-serial-2of2
/test e2e-aws-serial-techpreview-1of2
/test e2e-aws-serial-techpreview-2of2
/test e2e-azure
/test e2e-gcp
/test e2e-upgrade
/test e2e-upgrade-out-of-change
/test minor-e2e-upgrade-minor

Copy link
Contributor

openshift-ci bot commented Feb 23, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: saschagrunert
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

Copy link
Contributor

PR needs rebase.

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.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 23, 2026
Copy link
Contributor

openshift-ci bot commented Feb 23, 2026

@danielmellado: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-serial-1of2 036e9b1 link true /test e2e-aws-serial-1of2
ci/prow/e2e-aws-ovn-hypershift 036e9b1 link true /test e2e-aws-ovn-hypershift
ci/prow/e2e-azure 036e9b1 link true /test e2e-azure
ci/prow/e2e-aws-ovn-hypershift-conformance 036e9b1 link true /test e2e-aws-ovn-hypershift-conformance

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

Reviewers

@everettraven everettraven Awaiting requested review from everettraven

@JoelSpeed JoelSpeed Awaiting requested review from JoelSpeed

@marioferh marioferh Awaiting requested review from marioferh

1 more reviewer

@saschagrunert saschagrunert saschagrunert approved these changes

Reviewers whose approvals may not affect merge requirements

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /