@@ -97,20 +97,7 @@ func (s *KVCacheAwareScorer) Score(ctx *types.SchedulingContext, pods []types.Po
97
97
}
98
98
loggerDebug .Info ("Got pod scores" , "scores" , scores )
99
99
100
- if len (scores ) == 0 {
101
- loggerDebug .Info ("No scores found for pods" )
102
- return nil
103
- }
104
-
105
- podToKey := func (pod types.Pod ) (string , bool ) {
106
- metricsPod := pod .GetPod ()
107
- if metricsPod == nil {
108
- return "" , false
109
- }
110
- return metricsPod .Address , true
111
- }
112
-
113
- return indexedScoresToNormalizedScoredPods (pods , podToKey , scores )
100
+ return indexerScoresToNormalizedScoredPods (pods , scores )
114
101
}
115
102
116
103
func getMinMax (scores map [string ]int ) (int , int ) {
@@ -129,21 +116,17 @@ func getMinMax(scores map[string]int) (int, int) {
129
116
return minScore , maxScore
130
117
}
131
118
132
- // podToKey is a function type that converts a Pod to a string key.
133
- // It returns the key and a boolean indicating success.
134
- type podToKeyFunc func (pod types.Pod ) (string , bool )
135
-
136
- func indexedScoresToNormalizedScoredPods (pods []types.Pod , podToKey podToKeyFunc , scores map [string ]int ) map [types.Pod ]float64 {
119
+ func indexerScoresToNormalizedScoredPods (pods []types.Pod , scores map [string ]int ) map [types.Pod ]float64 {
137
120
scoredPods := make (map [types.Pod ]float64 )
138
121
minScore , maxScore := getMinMax (scores )
139
122
140
123
for _ , pod := range pods {
141
- key , ok := podToKey ( pod )
142
- if ! ok {
124
+ metricsPod := pod . GetPod ( )
125
+ if metricsPod == nil {
143
126
continue
144
127
}
145
128
146
- if score , ok := scores [key ]; ok {
129
+ if score , ok := scores [metricsPod . Address ]; ok {
147
130
if minScore == maxScore {
148
131
scoredPods [pod ] = 1.0
149
132
continue
0 commit comments