Skip to content

Commit 9b69f7d

Browse files
tiraboschiingvagabund
authored andcommitted
BUG: always configure metricsProviders with RelieveAndMigrate
RelieveAndMigrate is now (after #510) trying to consume by default a Prometheous query so metricsProviders should always appear in the descheduler configuration when RelieveAndMigrate profile is in use, even without any profileCustomizations. Signed-off-by: Simone Tiraboschi <[email protected]>
1 parent 3b9603a commit 9b69f7d

10 files changed

+297
-7
lines changed

pkg/operator/target_config_reconciler.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,19 +1301,19 @@ func (c *TargetConfigReconciler) manageConfigMap(descheduler *deschedulerv1.Kube
13011301
}
13021302
}
13031303

1304-
if descheduler.Spec.ProfileCustomizations != nil && descheduler.Spec.ProfileCustomizations.DevActualUtilizationProfile != "" {
1304+
if c.isPrometheusAsMetricsProviderForProfiles(descheduler) {
13051305
// detect the prometheus server url
13061306
route, err := c.routeRouteLister.Routes("openshift-monitoring").Get("prometheus-k8s")
13071307
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)
13091309
}
13101310
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")
13121312
}
13131313
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")
13151315
}
1316-
err = c.checkNamepsaceMonitoringLabel()
1316+
err = c.checkNamespaceMonitoringLabel()
13171317
if err != nil {
13181318
return nil, false, err
13191319
}
@@ -1640,7 +1640,7 @@ func (c *TargetConfigReconciler) eventHandler() cache.ResourceEventHandler {
16401640
}
16411641
}
16421642

1643-
func (c *TargetConfigReconciler) checkNamepsaceMonitoringLabel() error {
1643+
func (c *TargetConfigReconciler) checkNamespaceMonitoringLabel() error {
16441644
operatorNamespace, err := c.namespaceLister.Get(operatorclient.OperatorNamespace)
16451645
if err != nil {
16461646
klog.ErrorS(err, "error fetching operator namespace")
@@ -1714,3 +1714,14 @@ func (c *TargetConfigReconciler) isSoftTainterNeeded(descheduler *deschedulerv1.
17141714
}
17151715
return leftoverSoftTaints, nil
17161716
}
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

Comments
 (0)