From 2d8d4d8efaa0d718e9aa8fd2c63a8bdb08d87f88 Mon Sep 17 00:00:00 2001 From: Daniel Mellado Date: Thu, 7 May 2026 14:24:51 +0200 Subject: [PATCH] Add new fields to ThanosQuerierConfig Port ThanosQuerierConfig fields from the CMO ConfigMap API to the ClusterMonitoring CRD. LogLevel reuses the existing LogLevel enum (Error, Warn, Info, Debug). EnableRequestLogging and EnableCORS use a new ThanosQuerierToggle string enum (Enabled, Disabled) following the Kubernetes API convention of avoiding *bool fields. Signed-off-by: Daniel Mellado --- .../ClusterMonitoringConfig.yaml | 134 ++++++++++++++++++ config/v1alpha1/types_cluster_monitoring.go | 41 ++++++ ...ig-operator_01_clustermonitorings.crd.yaml | 43 ++++++ .../ClusterMonitoringConfig.yaml | 43 ++++++ .../zz_generated.swagger_doc_generated.go | 3 + .../generated_openapi/zz_generated.openapi.go | 21 +++ ...ig-operator_01_clustermonitorings.crd.yaml | 43 ++++++ 7 files changed, 328 insertions(+) diff --git a/config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml b/config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml index bd27fd8dad3..5750b40df85 100644 --- a/config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml +++ b/config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml @@ -1181,6 +1181,9 @@ tests: kind: ClusterMonitoring spec: thanosQuerierConfig: + logLevel: "Debug" + enableRequestLogging: "Enabled" + enableCORS: "Disabled" nodeSelector: kubernetes.io/os: linux resources: @@ -1201,6 +1204,9 @@ tests: kind: ClusterMonitoring spec: thanosQuerierConfig: + logLevel: "Debug" + enableRequestLogging: "Enabled" + enableCORS: "Disabled" nodeSelector: kubernetes.io/os: linux resources: @@ -1434,6 +1440,134 @@ tests: topologyKey: topology.kubernetes.io/zone whenUnsatisfiable: DoNotSchedule expectedError: "Duplicate value" + - name: Should accept ThanosQuerierConfig with logLevel set to Error + initial: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + logLevel: "Error" + expected: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + logLevel: "Error" + - name: Should accept ThanosQuerierConfig with logLevel set to Warn + initial: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + logLevel: "Warn" + expected: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + logLevel: "Warn" + - name: Should accept ThanosQuerierConfig with logLevel set to Info + initial: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + logLevel: "Info" + expected: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + logLevel: "Info" + - name: Should accept ThanosQuerierConfig with logLevel set to Debug + initial: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + logLevel: "Debug" + expected: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + logLevel: "Debug" + - name: Should reject ThanosQuerierConfig with invalid logLevel + initial: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + logLevel: "InvalidLevel" + expectedError: 'spec.thanosQuerierConfig.logLevel: Unsupported value: "InvalidLevel": supported values: "Error", "Warn", "Info", "Debug"' + - name: Should accept ThanosQuerierConfig with enableRequestLogging set to Enabled + initial: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + enableRequestLogging: "Enabled" + expected: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + enableRequestLogging: "Enabled" + - name: Should accept ThanosQuerierConfig with enableRequestLogging set to Disabled + initial: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + enableRequestLogging: "Disabled" + expected: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + enableRequestLogging: "Disabled" + - name: Should reject ThanosQuerierConfig with invalid enableRequestLogging + initial: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + enableRequestLogging: "InvalidValue" + expectedError: 'spec.thanosQuerierConfig.enableRequestLogging: Unsupported value: "InvalidValue": supported values: "Enabled", "Disabled"' + - name: Should accept ThanosQuerierConfig with enableCORS set to Enabled + initial: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + enableCORS: "Enabled" + expected: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + enableCORS: "Enabled" + - name: Should accept ThanosQuerierConfig with enableCORS set to Disabled + initial: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + enableCORS: "Disabled" + expected: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + enableCORS: "Disabled" + - name: Should reject ThanosQuerierConfig with invalid enableCORS + initial: | + apiVersion: config.openshift.io/v1alpha1 + kind: ClusterMonitoring + spec: + thanosQuerierConfig: + enableCORS: "InvalidValue" + expectedError: 'spec.thanosQuerierConfig.enableCORS: Unsupported value: "InvalidValue": supported values: "Enabled", "Disabled"' - name: Should be able to create MonitoringPluginConfig with valid resources initial: | apiVersion: config.openshift.io/v1alpha1 diff --git a/config/v1alpha1/types_cluster_monitoring.go b/config/v1alpha1/types_cluster_monitoring.go index 4dbfb126812..14a749bce4c 100644 --- a/config/v1alpha1/types_cluster_monitoring.go +++ b/config/v1alpha1/types_cluster_monitoring.go @@ -2381,6 +2381,35 @@ type TelemeterClientConfig struct { // At least one field must be specified; an empty thanosQuerierConfig object is not allowed. // +kubebuilder:validation:MinProperties=1 type ThanosQuerierConfig struct { + // logLevel defines the verbosity of logs emitted by Thanos Querier. + // logLevel is optional. + // Allowed values are Error, Warn, Info, and Debug. + // When set to Error, only errors will be logged. + // When set to Warn, both warnings and errors will be logged. + // When set to Info, general information, warnings, and errors will all be logged. + // When set to Debug, detailed debugging information will be logged. + // When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + // The current default value is `Info`. + // +optional + LogLevel LogLevel `json:"logLevel,omitempty"` + // enableRequestLogging controls whether all incoming HTTP requests are logged by Thanos Querier. + // enableRequestLogging is optional. + // Valid values are "Enabled" and "Disabled". + // When set to "Enabled", every request received by Thanos Querier is logged with method, path, and response status. + // When set to "Disabled", request logging is turned off. + // When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + // The current default value is "Disabled". + // +optional + EnableRequestLogging ThanosQuerierToggle `json:"enableRequestLogging,omitempty"` + // enableCORS controls whether Thanos Querier sets CORS headers allowing access from any origin. + // enableCORS is optional. + // Valid values are "Enabled" and "Disabled". + // When set to "Enabled", CORS headers are added to responses, allowing cross-origin requests from any domain. + // When set to "Disabled", no CORS headers are added. + // When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + // The current default value is "Disabled". + // +optional + EnableCORS ThanosQuerierToggle `json:"enableCORS,omitempty"` // nodeSelector defines the nodes on which the Pods are scheduled. // nodeSelector is optional. // @@ -2449,6 +2478,18 @@ type ThanosQuerierConfig struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` } +// ThanosQuerierToggle is a string type for Thanos Querier feature toggles. +// Valid values are "Enabled" and "Disabled". +// +kubebuilder:validation:Enum=Enabled;Disabled +type ThanosQuerierToggle string + +const ( + // ThanosQuerierToggleEnabled enables the feature. + ThanosQuerierToggleEnabled ThanosQuerierToggle = "Enabled" + // ThanosQuerierToggleDisabled disables the feature. + ThanosQuerierToggleDisabled ThanosQuerierToggle = "Disabled" +) + // AuditProfile defines the audit log level for the Metrics Server. // +kubebuilder:validation:Enum=None;Metadata;Request;RequestResponse type AuditProfile string diff --git a/config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings.crd.yaml b/config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings.crd.yaml index 6c184ff5b4d..6a0963269c7 100644 --- a/config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings.crd.yaml +++ b/config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitorings.crd.yaml @@ -5888,6 +5888,49 @@ spec: When set, at least one field must be specified within thanosQuerierConfig. minProperties: 1 properties: + enableCORS: + description: |- + enableCORS controls whether Thanos Querier sets CORS headers allowing access from any origin. + enableCORS is optional. + Valid values are "Enabled" and "Disabled". + When set to "Enabled", CORS headers are added to responses, allowing cross-origin requests from any domain. + When set to "Disabled", no CORS headers are added. + When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + The current default value is "Disabled". + enum: + - Enabled + - Disabled + type: string + enableRequestLogging: + description: |- + enableRequestLogging controls whether all incoming HTTP requests are logged by Thanos Querier. + enableRequestLogging is optional. + Valid values are "Enabled" and "Disabled". + When set to "Enabled", every request received by Thanos Querier is logged with method, path, and response status. + When set to "Disabled", request logging is turned off. + When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + The current default value is "Disabled". + enum: + - Enabled + - Disabled + type: string + logLevel: + description: |- + logLevel defines the verbosity of logs emitted by Thanos Querier. + logLevel is optional. + Allowed values are Error, Warn, Info, and Debug. + When set to Error, only errors will be logged. + When set to Warn, both warnings and errors will be logged. + When set to Info, general information, warnings, and errors will all be logged. + When set to Debug, detailed debugging information will be logged. + When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + The current default value is `Info`. + enum: + - Error + - Warn + - Info + - Debug + type: string nodeSelector: additionalProperties: type: string diff --git a/config/v1alpha1/zz_generated.featuregated-crd-manifests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml b/config/v1alpha1/zz_generated.featuregated-crd-manifests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml index 407415920fd..d090e446214 100644 --- a/config/v1alpha1/zz_generated.featuregated-crd-manifests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml +++ b/config/v1alpha1/zz_generated.featuregated-crd-manifests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml @@ -5888,6 +5888,49 @@ spec: When set, at least one field must be specified within thanosQuerierConfig. minProperties: 1 properties: + enableCORS: + description: |- + enableCORS controls whether Thanos Querier sets CORS headers allowing access from any origin. + enableCORS is optional. + Valid values are "Enabled" and "Disabled". + When set to "Enabled", CORS headers are added to responses, allowing cross-origin requests from any domain. + When set to "Disabled", no CORS headers are added. + When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + The current default value is "Disabled". + enum: + - Enabled + - Disabled + type: string + enableRequestLogging: + description: |- + enableRequestLogging controls whether all incoming HTTP requests are logged by Thanos Querier. + enableRequestLogging is optional. + Valid values are "Enabled" and "Disabled". + When set to "Enabled", every request received by Thanos Querier is logged with method, path, and response status. + When set to "Disabled", request logging is turned off. + When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + The current default value is "Disabled". + enum: + - Enabled + - Disabled + type: string + logLevel: + description: |- + logLevel defines the verbosity of logs emitted by Thanos Querier. + logLevel is optional. + Allowed values are Error, Warn, Info, and Debug. + When set to Error, only errors will be logged. + When set to Warn, both warnings and errors will be logged. + When set to Info, general information, warnings, and errors will all be logged. + When set to Debug, detailed debugging information will be logged. + When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + The current default value is `Info`. + enum: + - Error + - Warn + - Info + - Debug + type: string nodeSelector: additionalProperties: type: string diff --git a/config/v1alpha1/zz_generated.swagger_doc_generated.go b/config/v1alpha1/zz_generated.swagger_doc_generated.go index ae91964235b..97be2f21e25 100644 --- a/config/v1alpha1/zz_generated.swagger_doc_generated.go +++ b/config/v1alpha1/zz_generated.swagger_doc_generated.go @@ -698,6 +698,9 @@ func (TelemeterClientConfig) SwaggerDoc() map[string]string { var map_ThanosQuerierConfig = map[string]string{ "": "ThanosQuerierConfig provides configuration options for the Thanos Querier component that runs in the `openshift-monitoring` namespace. At least one field must be specified; an empty thanosQuerierConfig object is not allowed.", + "logLevel": "logLevel defines the verbosity of logs emitted by Thanos Querier. logLevel is optional. Allowed values are Error, Warn, Info, and Debug. When set to Error, only errors will be logged. When set to Warn, both warnings and errors will be logged. When set to Info, general information, warnings, and errors will all be logged. When set to Debug, detailed debugging information will be logged. When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. The current default value is `Info`.", + "enableRequestLogging": "enableRequestLogging controls whether all incoming HTTP requests are logged by Thanos Querier. enableRequestLogging is optional. Valid values are \"Enabled\" and \"Disabled\". When set to \"Enabled\", every request received by Thanos Querier is logged with method, path, and response status. When set to \"Disabled\", request logging is turned off. When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. The current default value is \"Disabled\".", + "enableCORS": "enableCORS controls whether Thanos Querier sets CORS headers allowing access from any origin. enableCORS is optional. Valid values are \"Enabled\" and \"Disabled\". When set to \"Enabled\", CORS headers are added to responses, allowing cross-origin requests from any domain. When set to \"Disabled\", no CORS headers are added. When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. The current default value is \"Disabled\".", "nodeSelector": "nodeSelector defines the nodes on which the Pods are scheduled. nodeSelector is optional.\n\nWhen omitted, this means the user has no opinion and the platform is left to choose reasonable defaults. These defaults are subject to change over time. The current default value is `kubernetes.io/os: linux`. When specified, nodeSelector must contain at least 1 entry and must not contain more than 10 entries.", "resources": "resources defines the compute resource requests and limits for the Thanos Querier container. resources is optional.\n\nWhen omitted, this means the user has no opinion and the platform is left to choose reasonable defaults. These defaults are subject to change over time. Requests cannot exceed limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ This is a simplified API that maps to Kubernetes ResourceRequirements. The current default values are:\n resources:\n - name: cpu\n request: 5m\n - name: memory\n request: 12Mi\nMaximum length for this list is 5. Minimum length for this list is 1. Each resource name must be unique within this list.", "tolerations": "tolerations defines tolerations for the pods. tolerations is optional.\n\nWhen omitted, this means the user has no opinion and the platform is left to choose reasonable defaults. These defaults are subject to change over time. Defaults are empty/unset. Maximum length for this list is 10. Minimum length for this list is 1.", diff --git a/openapi/generated_openapi/zz_generated.openapi.go b/openapi/generated_openapi/zz_generated.openapi.go index 2aa177bbfc1..f4802c8b7e3 100644 --- a/openapi/generated_openapi/zz_generated.openapi.go +++ b/openapi/generated_openapi/zz_generated.openapi.go @@ -26486,6 +26486,27 @@ func schema_openshift_api_config_v1alpha1_ThanosQuerierConfig(ref common.Referen Description: "ThanosQuerierConfig provides configuration options for the Thanos Querier component that runs in the `openshift-monitoring` namespace. At least one field must be specified; an empty thanosQuerierConfig object is not allowed.", Type: []string{"object"}, Properties: map[string]spec.Schema{ + "logLevel": { + SchemaProps: spec.SchemaProps{ + Description: "logLevel defines the verbosity of logs emitted by Thanos Querier. logLevel is optional. Allowed values are Error, Warn, Info, and Debug. When set to Error, only errors will be logged. When set to Warn, both warnings and errors will be logged. When set to Info, general information, warnings, and errors will all be logged. When set to Debug, detailed debugging information will be logged. When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. The current default value is `Info`.", + Type: []string{"string"}, + Format: "", + }, + }, + "enableRequestLogging": { + SchemaProps: spec.SchemaProps{ + Description: "enableRequestLogging controls whether all incoming HTTP requests are logged by Thanos Querier. enableRequestLogging is optional. Valid values are \"Enabled\" and \"Disabled\". When set to \"Enabled\", every request received by Thanos Querier is logged with method, path, and response status. When set to \"Disabled\", request logging is turned off. When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. The current default value is \"Disabled\".", + Type: []string{"string"}, + Format: "", + }, + }, + "enableCORS": { + SchemaProps: spec.SchemaProps{ + Description: "enableCORS controls whether Thanos Querier sets CORS headers allowing access from any origin. enableCORS is optional. Valid values are \"Enabled\" and \"Disabled\". When set to \"Enabled\", CORS headers are added to responses, allowing cross-origin requests from any domain. When set to \"Disabled\", no CORS headers are added. When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. The current default value is \"Disabled\".", + Type: []string{"string"}, + Format: "", + }, + }, "nodeSelector": { SchemaProps: spec.SchemaProps{ Description: "nodeSelector defines the nodes on which the Pods are scheduled. nodeSelector is optional.\n\nWhen omitted, this means the user has no opinion and the platform is left to choose reasonable defaults. These defaults are subject to change over time. The current default value is `kubernetes.io/os: linux`. When specified, nodeSelector must contain at least 1 entry and must not contain more than 10 entries.", diff --git a/payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml b/payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml index 6c184ff5b4d..6a0963269c7 100644 --- a/payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml +++ b/payload-manifests/crds/0000_10_config-operator_01_clustermonitorings.crd.yaml @@ -5888,6 +5888,49 @@ spec: When set, at least one field must be specified within thanosQuerierConfig. minProperties: 1 properties: + enableCORS: + description: |- + enableCORS controls whether Thanos Querier sets CORS headers allowing access from any origin. + enableCORS is optional. + Valid values are "Enabled" and "Disabled". + When set to "Enabled", CORS headers are added to responses, allowing cross-origin requests from any domain. + When set to "Disabled", no CORS headers are added. + When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + The current default value is "Disabled". + enum: + - Enabled + - Disabled + type: string + enableRequestLogging: + description: |- + enableRequestLogging controls whether all incoming HTTP requests are logged by Thanos Querier. + enableRequestLogging is optional. + Valid values are "Enabled" and "Disabled". + When set to "Enabled", every request received by Thanos Querier is logged with method, path, and response status. + When set to "Disabled", request logging is turned off. + When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + The current default value is "Disabled". + enum: + - Enabled + - Disabled + type: string + logLevel: + description: |- + logLevel defines the verbosity of logs emitted by Thanos Querier. + logLevel is optional. + Allowed values are Error, Warn, Info, and Debug. + When set to Error, only errors will be logged. + When set to Warn, both warnings and errors will be logged. + When set to Info, general information, warnings, and errors will all be logged. + When set to Debug, detailed debugging information will be logged. + When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time. + The current default value is `Info`. + enum: + - Error + - Warn + - Info + - Debug + type: string nodeSelector: additionalProperties: type: string