diff --git a/Documentation/api.md b/Documentation/api.md index 75ec8cea90..eebb266bfb 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -22,7 +22,6 @@ Configuring Cluster Monitoring is optional. If the config does not exist or is e * [AlertmanagerMainConfig](#alertmanagermainconfig) * [AlertmanagerUserWorkloadConfig](#alertmanageruserworkloadconfig) * [ClusterMonitoringConfiguration](#clustermonitoringconfiguration) -* [K8sPrometheusAdapter](#k8sprometheusadapter) * [KubeStateMetricsConfig](#kubestatemetricsconfig) * [MetricsServerConfig](#metricsserverconfig) * [MonitoringPluginConfig](#monitoringpluginconfig) @@ -143,22 +142,6 @@ The `ClusterMonitoringConfiguration` resource defines settings that customize th [Back to TOC](#table-of-contents) -## K8sPrometheusAdapter - -#### Description - -The `K8sPrometheusAdapter` resource defines settings for the Prometheus Adapter component. This is deprecated config, setting this has no effect and will be removed in a future version. - -| Property | Type | Description | -| -------- | ---- | ----------- | -| audit | *Audit | Defines the audit configuration used by the Prometheus Adapter instance. Possible profile values are: `metadata`, `request`, `requestresponse`, and `none`. The default value is `metadata`. | -| nodeSelector | map[string]string | Defines the nodes on which the pods are scheduled. | -| resources | *[v1.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcerequirements-v1-core) | Defines resource requests and limits for the PrometheusAdapter container. | -| tolerations | [][v1.Toleration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#toleration-v1-core) | Defines tolerations for the pods. | -| topologySpreadConstraints | []v1.TopologySpreadConstraint | Defines a pod's topology spread constraints. | - -[Back to TOC](#table-of-contents) - ## KubeStateMetricsConfig #### Description diff --git a/Documentation/openshiftdocs/index.adoc b/Documentation/openshiftdocs/index.adoc index 7dcc4dc7bd..1ea2340b4b 100644 --- a/Documentation/openshiftdocs/index.adoc +++ b/Documentation/openshiftdocs/index.adoc @@ -42,7 +42,6 @@ The configuration file itself is always defined under the `config.yaml` key in t * link:modules/alertmanagermainconfig.adoc[AlertmanagerMainConfig] * link:modules/alertmanageruserworkloadconfig.adoc[AlertmanagerUserWorkloadConfig] * link:modules/clustermonitoringconfiguration.adoc[ClusterMonitoringConfiguration] -* link:modules/k8sprometheusadapter.adoc[K8sPrometheusAdapter] * link:modules/kubestatemetricsconfig.adoc[KubeStateMetricsConfig] * link:modules/metricsserverconfig.adoc[MetricsServerConfig] * link:modules/monitoringpluginconfig.adoc[MonitoringPluginConfig] diff --git a/Documentation/openshiftdocs/modules/k8sprometheusadapter.adoc b/Documentation/openshiftdocs/modules/k8sprometheusadapter.adoc deleted file mode 100644 index f48b9bd643..0000000000 --- a/Documentation/openshiftdocs/modules/k8sprometheusadapter.adoc +++ /dev/null @@ -1,30 +0,0 @@ -// DO NOT EDIT THE CONTENT IN THIS FILE. It is automatically generated from the - // source code for the Cluster Monitoring Operator. Any changes made to this - // file will be overwritten when the content is re-generated. If you wish to - // make edits, read the docgen utility instructions in the source code for the - // CMO. - :_content-type: ASSEMBLY - -== K8sPrometheusAdapter - -=== Description - -The `K8sPrometheusAdapter` resource defines settings for the Prometheus Adapter component. This is deprecated config, setting this has no effect and will be removed in a future version. - - -[options="header"] -|=== -| Property | Type | Description -|audit|*Audit|Defines the audit configuration used by the Prometheus Adapter instance. Possible profile values are: `metadata`, `request`, `requestresponse`, and `none`. The default value is `metadata`. - -|nodeSelector|map[string]string|Defines the nodes on which the pods are scheduled. - -|resources|*v1.ResourceRequirements|Defines resource requests and limits for the PrometheusAdapter container. - -|tolerations|[]v1.Toleration|Defines tolerations for the pods. - -|topologySpreadConstraints|[]v1.TopologySpreadConstraint|Defines a pod's topology spread constraints. - -|=== - -link:../index.adoc[Back to TOC] diff --git a/pkg/manifests/config.go b/pkg/manifests/config.go index 657cc8e5e8..cdf2a0773f 100644 --- a/pkg/manifests/config.go +++ b/pkg/manifests/config.go @@ -603,19 +603,6 @@ func (c *Config) LoadEnforcedBodySizeLimit(pcr PodCapacityReader, ctx context.Co return nil } -func (c *Config) checkAlertmanagerVersion() error { - if c.ClusterMonitoringConfiguration == nil || c.ClusterMonitoringConfiguration.PrometheusK8sConfig == nil { - return nil - } - - for _, amConfig := range c.ClusterMonitoringConfiguration.PrometheusK8sConfig.AlertmanagerConfigs { - if alertmanagerV1(amConfig.APIVersion) { - return fmt.Errorf("%w: found in prometheusK8s.additionalAlertmanagerConfigs", errAlertmanagerV1NotSupported) - } - } - return nil -} - func (c *Config) Precheck() error { if c.ClusterMonitoringConfiguration.PrometheusK8sConfig.CollectionProfile != FullCollectionProfile && !c.CollectionProfilesFeatureGateEnabled { return fmt.Errorf("%w: collectionProfiles is currently a TechPreview feature behind the \"MetricsCollectionProfiles\" feature-gate, to be able to use a profile different from the default (\"full\") please enable it first", ErrConfigValidation) @@ -635,21 +622,6 @@ func (c *Config) Precheck() error { } } - // Highlight deprecated config fields. - var d float64 - if c.ClusterMonitoringConfiguration.K8sPrometheusAdapter != nil { - klog.Infof("k8sPrometheusAdapter is a deprecated config use metricsServer instead") - d = 1 - } - // Prometheus-Adapter is replaced with Metrics Server by default from 4.16 - metrics.DeprecatedConfig.WithLabelValues("openshift-monitoring/cluster-monitoring-config", "k8sPrometheusAdapter", "4.16").Set(d) - - // TODO: remove after 4.19 - // Only to assist with the migration to Prometheus 3; fail early if Alertmanager v1 is still in use. - if err := c.checkAlertmanagerVersion(); err != nil { - return err - } - return nil } diff --git a/pkg/manifests/config_test.go b/pkg/manifests/config_test.go index 923a390e40..da38794cee 100644 --- a/pkg/manifests/config_test.go +++ b/pkg/manifests/config_test.go @@ -20,8 +20,6 @@ import ( "os" "testing" - "github.com/openshift/cluster-monitoring-operator/pkg/metrics" - prom_testutil "github.com/prometheus/client_golang/prometheus/testutil" "github.com/stretchr/testify/require" ) @@ -801,44 +799,6 @@ func TestCollectionProfilePreCheck(t *testing.T) { } } -func TestDeprecatedConfig(t *testing.T) { - for _, tc := range []struct { - name string - config string - expectedMetricValue float64 - }{ - { - name: "setting a field in k8sPrometheusAdapter", - config: `k8sPrometheusAdapter: - resources: - requests: - cpu: 1m - memory: 20Mi - `, - expectedMetricValue: 1, - }, - { - name: "k8sPrometheusAdapter nil", - config: `k8sPrometheusAdapter: - `, - expectedMetricValue: 0, - }, - { - name: "no config set", - config: "", - expectedMetricValue: 0, - }, - } { - t.Run(tc.name, func(t *testing.T) { - c, err := NewConfigFromString(tc.config, true) - require.NoError(t, err) - err = c.Precheck() - require.NoError(t, err) - require.Equal(t, tc.expectedMetricValue, prom_testutil.ToFloat64(metrics.DeprecatedConfig)) - }) - } -} - // TestUnsupportedAlertmanagerVersion is a temp test // TODO: remove after 4.19 // Only to assist with the migration to Prometheus 3; fail early if Alertmanager v1 is still in use. diff --git a/pkg/manifests/types.go b/pkg/manifests/types.go index ad06174ba7..2974088781 100644 --- a/pkg/manifests/types.go +++ b/pkg/manifests/types.go @@ -43,8 +43,6 @@ type ClusterMonitoringConfiguration struct { UserWorkload *UserWorkloadConfig `json:"userWorkload,omitempty"` // OmitFromDoc HTTPConfig *HTTPConfig `json:"http,omitempty"` - // OmitFromDoc: `K8sPrometheusAdapter` defines settings for the Prometheus Adapter component. - K8sPrometheusAdapter *K8sPrometheusAdapter `json:"k8sPrometheusAdapter,omitempty"` // `MetricsServer` defines settings for the MetricsServer component. MetricsServerConfig *MetricsServerConfig `json:"metricsServer,omitempty"` // `KubeStateMetricsConfig` defines settings for the `kube-state-metrics` agent. @@ -118,26 +116,6 @@ type AlertmanagerMainConfig struct { VolumeClaimTemplate *monv1.EmbeddedPersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"` } -// The `K8sPrometheusAdapter` resource defines settings for the Prometheus Adapter component. -// This is deprecated config, setting this has no effect and will be removed in a future version. -// TODO: Remove this in 4.19. We should block upgrades till config is been removed -type K8sPrometheusAdapter struct { - // Defines the audit configuration used by the Prometheus Adapter instance. - // Possible profile values are: `metadata`, `request`, `requestresponse`, and `none`. - // The default value is `metadata`. - Audit *Audit `json:"audit,omitempty"` - // Defines the nodes on which the pods are scheduled. - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - // Defines resource requests and limits for the PrometheusAdapter container. - Resources *v1.ResourceRequirements `json:"resources,omitempty"` - // Defines tolerations for the pods. - Tolerations []v1.Toleration `json:"tolerations,omitempty"` - // Defines a pod's topology spread constraints. - TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` - // OmitFromDoc: Defines dedicated service monitors. - DedicatedServiceMonitors *DedicatedServiceMonitors `json:"dedicatedServiceMonitors,omitempty"` -} - // The `MetricsServerConfig` resource defines settings for the Metrics Server component. type MetricsServerConfig struct { // Defines the audit configuration used by the Metrics Server instance. diff --git a/test/e2e/config_test.go b/test/e2e/config_test.go index 171ba853ed..d54aafa207 100644 --- a/test/e2e/config_test.go +++ b/test/e2e/config_test.go @@ -874,38 +874,6 @@ monitoringPlugin: } } -func TestClusterMonitoringDeprecatedConfig(t *testing.T) { - metricName := "cluster_monitoring_operator_deprecated_config_in_use" - checkMetricValue := func(value float64) { - t.Helper() - f.PrometheusK8sClient.WaitForQueryReturn( - t, 5*time.Minute, fmt.Sprintf(`%s{configmap="openshift-monitoring/cluster-monitoring-config", field="k8sPrometheusAdapter", deprecation_version="4.16"}`, metricName), - func(v float64) error { - if v != value { - return fmt.Errorf("expected %s to be of value %f.", metricName, value) - } - return nil - }, - ) - } - // No deprecated config should have been used. - checkMetricValue(0) - - // Set a field for k8sPrometheusAdapter. - data := ` -k8sPrometheusAdapter: - audit: - profile: Request` - f.MustCreateOrUpdateConfigMap(t, f.BuildCMOConfigMap(t, data)) - checkMetricValue(1) - - // The metric should be reset to 0. - data = ` -k8sPrometheusAdapter:` - f.MustCreateOrUpdateConfigMap(t, f.BuildCMOConfigMap(t, data)) - checkMetricValue(0) -} - // checks that the toleration is present // this toleration will match all so will not affect rolling out workloads func expectTolerationsEqual(exp int) framework.PodAssertion {