@@ -1301,19 +1301,19 @@ func (c *TargetConfigReconciler) manageConfigMap(descheduler *deschedulerv1.Kube
1301
1301
}
1302
1302
}
1303
1303
1304
- if descheduler . Spec . ProfileCustomizations != nil && descheduler . Spec . ProfileCustomizations . DevActualUtilizationProfile != "" {
1304
+ if c . isPrometheusAsMetricsProviderForProfiles ( descheduler ) {
1305
1305
// detect the prometheus server url
1306
1306
route , err := c .routeRouteLister .Routes ("openshift-monitoring" ).Get ("prometheus-k8s" )
1307
1307
if err != nil {
1308
- return nil , false , fmt .Errorf ("unable to get openshift-monitoring/prometheus-k8s route: %v" , err )
1308
+ return nil , true , fmt .Errorf ("unable to get openshift-monitoring/prometheus-k8s route: %v" , err )
1309
1309
}
1310
1310
if len (route .Status .Ingress ) == 0 {
1311
- return nil , false , fmt .Errorf ("No ingress found in openshift-monitoring/prometheus-k8s route" )
1311
+ return nil , true , fmt .Errorf ("No ingress found in openshift-monitoring/prometheus-k8s route" )
1312
1312
}
1313
1313
if route .Status .Ingress [0 ].Host == "" {
1314
- return nil , false , fmt .Errorf ("Host for status.ingress[0] in openshift-monitoring/prometheus-k8s route is empty" )
1314
+ return nil , true , fmt .Errorf ("Host for status.ingress[0] in openshift-monitoring/prometheus-k8s route is empty" )
1315
1315
}
1316
- err = c .checkNamepsaceMonitoringLabel ()
1316
+ err = c .checkNamespaceMonitoringLabel ()
1317
1317
if err != nil {
1318
1318
return nil , false , err
1319
1319
}
@@ -1640,7 +1640,7 @@ func (c *TargetConfigReconciler) eventHandler() cache.ResourceEventHandler {
1640
1640
}
1641
1641
}
1642
1642
1643
- func (c * TargetConfigReconciler ) checkNamepsaceMonitoringLabel () error {
1643
+ func (c * TargetConfigReconciler ) checkNamespaceMonitoringLabel () error {
1644
1644
operatorNamespace , err := c .namespaceLister .Get (operatorclient .OperatorNamespace )
1645
1645
if err != nil {
1646
1646
klog .ErrorS (err , "error fetching operator namespace" )
@@ -1714,3 +1714,14 @@ func (c *TargetConfigReconciler) isSoftTainterNeeded(descheduler *deschedulerv1.
1714
1714
}
1715
1715
return leftoverSoftTaints , nil
1716
1716
}
1717
+
1718
+ // isPrometheusAsMetricsProviderForProfiles returns true when at least a profile that by default relies on PrometheusMetrics is in use
1719
+ // or the user is explicitly configuring DevActualUtilizationProfile profile customization
1720
+ func (c * TargetConfigReconciler ) isPrometheusAsMetricsProviderForProfiles (descheduler * deschedulerv1.KubeDescheduler ) bool {
1721
+ if descheduler != nil &&
1722
+ (slices .Contains (descheduler .Spec .Profiles , deschedulerv1 .RelieveAndMigrate ) ||
1723
+ (descheduler .Spec .ProfileCustomizations != nil && descheduler .Spec .ProfileCustomizations .DevActualUtilizationProfile != "" )) {
1724
+ return true
1725
+ }
1726
+ return false
1727
+ }
0 commit comments