Skip to content

Commit 85fdad8

Browse files
authored
Merge pull request #469 from tiraboschi/rebase_upstream_descheduler
bump descheduler: consume up to date descheduler
2 parents a1542dc + 823b936 commit 85fdad8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1647
-733
lines changed

go.mod

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@ require (
2121
k8s.io/klog/v2 v2.130.1
2222
k8s.io/utils v0.0.0-20241210054802-24370beab758
2323
sigs.k8s.io/controller-tools v0.17.0
24-
sigs.k8s.io/descheduler v0.32.2
24+
sigs.k8s.io/descheduler v0.0.0-20250328160644-17b90969cf6e
2525
sigs.k8s.io/structured-merge-diff/v4 v4.4.2
2626
)
2727

28-
replace (
29-
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f
30-
sigs.k8s.io/descheduler => github.com/openshift/descheduler v0.5.1-0.20250303164104-5223499539f1
31-
)
28+
replace k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f
3229

3330
require (
3431
cel.dev/expr v0.18.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ github.com/openshift/build-machinery-go v0.0.0-20250211133638-a00a772ae1a2 h1:Pw
164164
github.com/openshift/build-machinery-go v0.0.0-20250211133638-a00a772ae1a2/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE=
165165
github.com/openshift/client-go v0.0.0-20250131180035-f7ec47e2d87a h1:duO3JMrUOqVx50QhzxvDeOYIwTNOB8/EEuRLPyvAMBg=
166166
github.com/openshift/client-go v0.0.0-20250131180035-f7ec47e2d87a/go.mod h1:Qw3ThpzVZ0bfTILpBNYg4LGyjtNxfyCiGh/uDLOOTP8=
167-
github.com/openshift/descheduler v0.5.1-0.20250303164104-5223499539f1 h1:p9kTHQnei1MuzjaLNZOL8Aql/q0lnDDj63ejfppRJhI=
168-
github.com/openshift/descheduler v0.5.1-0.20250303164104-5223499539f1/go.mod h1:YqnuvkQ1KO3kC7JxFXu42hpDBiskT/3VnhKYvzzzxHE=
169167
github.com/openshift/library-go v0.0.0-20250228164547-bad2d1bf3a37 h1:/YhxswjRkADbww682dqckHddV/AVfwQHFn/XTf2fjsk=
170168
github.com/openshift/library-go v0.0.0-20250228164547-bad2d1bf3a37/go.mod h1:GHwvopE5KXXCz4ULHp871sTPLLW+FB+hu/RIzlNwxx8=
171169
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
@@ -371,6 +369,8 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 h1:CPT0ExVicCzcp
371369
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
372370
sigs.k8s.io/controller-tools v0.17.0 h1:KaEQZbhrdY6J3zLBHplt+0aKUp8PeIttlhtF2UDo6bI=
373371
sigs.k8s.io/controller-tools v0.17.0/go.mod h1:SKoWY8rwGWDzHtfnhmOwljn6fViG0JF7/xmnxpklgjo=
372+
sigs.k8s.io/descheduler v0.0.0-20250328160644-17b90969cf6e h1:JXv44E29SM5+VLVtEnlGfcHVGcRihp4Z/3yI+HAFtvc=
373+
sigs.k8s.io/descheduler v0.0.0-20250328160644-17b90969cf6e/go.mod h1:hJIYUlRKbxjhT85eQLVk9kZlDnmtraAjkqxBvbYsdLA=
374374
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8=
375375
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo=
376376
sigs.k8s.io/kube-storage-version-migrator v0.0.6-0.20230721195810-5c8923c5ff96 h1:PFWFSkpArPNJxFX4ZKWAk9NSeRoZaXschn+ULa4xVek=

pkg/operator/target_config_reconciler.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -689,10 +689,13 @@ func lifecycleAndUtilizationProfile(profileCustomizations *deschedulerv1.Profile
689689
}
690690
query = strings.TrimPrefix(string(profileCustomizations.DevActualUtilizationProfile), "query:")
691691
}
692-
args.MetricsUtilization.Prometheus = nodeutilization.Prometheus{
693-
Query: query,
692+
args.MetricsUtilization = &nodeutilization.MetricsUtilization{
693+
Source: deschedulerapi.MetricsSource(v1alpha2.PrometheusMetrics),
694+
Prometheus: &nodeutilization.Prometheus{
695+
Query: query,
696+
},
694697
}
695-
resourceNames = []v1.ResourceName{nodeutilization.ResourceMetrics}
698+
resourceNames = []v1.ResourceName{nodeutilization.MetricResource}
696699
}
697700

698701
if err := defaultEvictorOverrides(profileCustomizations, &profile.PluginConfigs[3]); err != nil {
@@ -877,8 +880,11 @@ func (c *TargetConfigReconciler) manageConfigMap(descheduler *deschedulerv1.Kube
877880
return nil, false, fmt.Errorf("Host for status.ingress[0] in openshift-monitoring/prometheus-k8s route is empty")
878881
}
879882
klog.InfoS("Detecting prometheus server url", "url", route.Status.Ingress[0].Host)
880-
policy.Prometheus = v1alpha2.Prometheus{
881-
URL: "https://" + route.Status.Ingress[0].Host,
883+
policy.MetricsProviders = []v1alpha2.MetricsProvider{{
884+
Source: v1alpha2.PrometheusMetrics,
885+
Prometheus: &v1alpha2.Prometheus{
886+
URL: "https://" + route.Status.Ingress[0].Host,
887+
}},
882888
}
883889
}
884890

pkg/operator/target_config_reconciler_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/google/go-cmp/cmp"
1111
configv1 "github.com/openshift/api/config/v1"
12+
routev1 "github.com/openshift/api/route/v1"
1213
"github.com/openshift/library-go/pkg/operator/events"
1314
appsv1 "k8s.io/api/apps/v1"
1415
corev1 "k8s.io/api/core/v1"
@@ -63,6 +64,7 @@ func TestManageConfigMap(t *testing.T) {
6364
schedulerConfig *configv1.Scheduler
6465
want *corev1.ConfigMap
6566
descheduler *deschedulerv1.KubeDescheduler
67+
routes []runtime.Object
6668
err error
6769
forceDeployment bool
6870
}{
@@ -251,6 +253,35 @@ func TestManageConfigMap(t *testing.T) {
251253
Data: map[string]string{"policy.yaml": string(bindata.MustAsset("assets/longLifecycleWithLocalStorage.yaml"))},
252254
},
253255
},
256+
{
257+
name: "LongLifecycleWithMetrics",
258+
descheduler: &deschedulerv1.KubeDescheduler{
259+
Spec: deschedulerv1.KubeDeschedulerSpec{
260+
Profiles: []deschedulerv1.DeschedulerProfile{"LongLifecycle"},
261+
ProfileCustomizations: &deschedulerv1.ProfileCustomizations{
262+
DevActualUtilizationProfile: deschedulerv1.PrometheusCPUUsageProfile,
263+
},
264+
},
265+
},
266+
want: &corev1.ConfigMap{
267+
TypeMeta: metav1.TypeMeta{APIVersion: "v1", Kind: "ConfigMap"},
268+
Data: map[string]string{"policy.yaml": string(bindata.MustAsset("assets/longLifecycleWithMetrics.yaml"))},
269+
},
270+
routes: []runtime.Object{
271+
&routev1.Route{
272+
ObjectMeta: metav1.ObjectMeta{
273+
Namespace: "openshift-monitoring",
274+
Name: "prometheus-k8s",
275+
},
276+
Status: routev1.RouteStatus{Ingress: []routev1.RouteIngress{
277+
{
278+
Host: "prometheus-k8s-openshift-monitoring.apps.example.com",
279+
},
280+
},
281+
},
282+
},
283+
},
284+
},
254285
{
255286
name: "SoftTopologyAndDuplicates",
256287
descheduler: &deschedulerv1.KubeDescheduler{
@@ -458,7 +489,7 @@ func TestManageConfigMap(t *testing.T) {
458489

459490
openshiftConfigClient := fakeconfigv1client.NewSimpleClientset(tt.schedulerConfig)
460491
configInformers := configv1informers.NewSharedInformerFactory(openshiftConfigClient, 10*time.Minute)
461-
openshiftRouteClient := fakeroutev1client.NewSimpleClientset()
492+
openshiftRouteClient := fakeroutev1client.NewSimpleClientset(tt.routes...)
462493
routeInformers := routev1informers.NewSharedInformerFactory(openshiftRouteClient, 10*time.Minute)
463494

464495
scheme := runtime.NewScheme()

pkg/operator/testdata/assets/affinityAndTaintsWithNamespaces.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apiVersion: descheduler/v1alpha2
22
kind: DeschedulerPolicy
3-
metricsCollector: {}
43
profiles:
54
- name: AffinityAndTaints
65
pluginConfig:
@@ -47,6 +46,3 @@ profiles:
4746
sort:
4847
disabled: null
4948
enabled: null
50-
prometheus:
51-
authToken:
52-
secretReference: {}

pkg/operator/testdata/assets/highNodeUtilization.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apiVersion: descheduler/v1alpha2
22
kind: DeschedulerPolicy
3-
metricsCollector: {}
43
profiles:
54
- name: CompactAndScale
65
pluginConfig:
@@ -11,8 +10,6 @@ profiles:
1110
- hypershift
1211
- openshift
1312
- openshift-kube-scheduler
14-
metricsUtilization:
15-
prometheus: {}
1613
thresholds:
1714
cpu: 20
1815
memory: 20
@@ -42,6 +39,3 @@ profiles:
4239
sort:
4340
disabled: null
4441
enabled: null
45-
prometheus:
46-
authToken:
47-
secretReference: {}

pkg/operator/testdata/assets/highNodeUtilizationMinimal.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apiVersion: descheduler/v1alpha2
22
kind: DeschedulerPolicy
3-
metricsCollector: {}
43
profiles:
54
- name: CompactAndScale
65
pluginConfig:
@@ -11,8 +10,6 @@ profiles:
1110
- hypershift
1211
- openshift
1312
- openshift-kube-scheduler
14-
metricsUtilization:
15-
prometheus: {}
1613
thresholds:
1714
cpu: 10
1815
memory: 10
@@ -42,6 +39,3 @@ profiles:
4239
sort:
4340
disabled: null
4441
enabled: null
45-
prometheus:
46-
authToken:
47-
secretReference: {}

pkg/operator/testdata/assets/highNodeUtilizationModerate.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apiVersion: descheduler/v1alpha2
22
kind: DeschedulerPolicy
3-
metricsCollector: {}
43
profiles:
54
- name: CompactAndScale
65
pluginConfig:
@@ -11,8 +10,6 @@ profiles:
1110
- hypershift
1211
- openshift
1312
- openshift-kube-scheduler
14-
metricsUtilization:
15-
prometheus: {}
1613
thresholds:
1714
cpu: 30
1815
memory: 30
@@ -42,6 +39,3 @@ profiles:
4239
sort:
4340
disabled: null
4441
enabled: null
45-
prometheus:
46-
authToken:
47-
secretReference: {}

pkg/operator/testdata/assets/highNodeUtilizationWithNamespaces.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
apiVersion: descheduler/v1alpha2
22
kind: DeschedulerPolicy
3-
metricsCollector: {}
43
profiles:
54
- name: CompactAndScale
65
pluginConfig:
76
- args:
8-
metricsUtilization:
9-
prometheus: {}
107
thresholds:
118
cpu: 20
129
memory: 20
@@ -36,6 +33,3 @@ profiles:
3633
sort:
3734
disabled: null
3835
enabled: null
39-
prometheus:
40-
authToken:
41-
secretReference: {}

pkg/operator/testdata/assets/lifecycleAndUtilizationEvictPvcPodsConfig.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apiVersion: descheduler/v1alpha2
22
kind: DeschedulerPolicy
3-
metricsCollector: {}
43
profiles:
54
- name: LifecycleAndUtilization
65
pluginConfig:
@@ -30,8 +29,6 @@ profiles:
3029
- hypershift
3130
- openshift
3231
- openshift-kube-scheduler
33-
metricsUtilization:
34-
prometheus: {}
3532
targetThresholds:
3633
cpu: 50
3734
memory: 50
@@ -66,6 +63,3 @@ profiles:
6663
sort:
6764
disabled: null
6865
enabled: null
69-
prometheus:
70-
authToken:
71-
secretReference: {}

0 commit comments

Comments
 (0)