@@ -37,21 +37,21 @@ import (
37
37
// NodeUsage stores a node's info, pods on it, thresholds and its resource usage
38
38
type NodeUsage struct {
39
39
node * v1.Node
40
- usage map [v1. ResourceName ] * resource. Quantity
40
+ usage api. ReferencedResourceList
41
41
allPods []* v1.Pod
42
42
}
43
43
44
44
type NodeThresholds struct {
45
- lowResourceThreshold map [v1. ResourceName ] * resource. Quantity
46
- highResourceThreshold map [v1. ResourceName ] * resource. Quantity
45
+ lowResourceThreshold api. ReferencedResourceList
46
+ highResourceThreshold api. ReferencedResourceList
47
47
}
48
48
49
49
type NodeInfo struct {
50
50
NodeUsage
51
51
thresholds NodeThresholds
52
52
}
53
53
54
- type continueEvictionCond func (nodeInfo NodeInfo , totalAvailableUsage map [v1. ResourceName ] * resource. Quantity ) bool
54
+ type continueEvictionCond func (nodeInfo NodeInfo , totalAvailableUsage api. ReferencedResourceList ) bool
55
55
56
56
// NodePodsMap is a set of (node, pods) pairs
57
57
type NodePodsMap map [* v1.Node ][]* v1.Pod
@@ -94,8 +94,8 @@ func getNodeThresholds(
94
94
}
95
95
96
96
nodeThresholdsMap [node .Name ] = NodeThresholds {
97
- lowResourceThreshold : map [v1. ResourceName ] * resource. Quantity {},
98
- highResourceThreshold : map [v1. ResourceName ] * resource. Quantity {},
97
+ lowResourceThreshold : api. ReferencedResourceList {},
98
+ highResourceThreshold : api. ReferencedResourceList {},
99
99
}
100
100
101
101
for _ , resourceName := range resourceNames {
@@ -206,7 +206,7 @@ func classifyNodes(
206
206
return lowNodes , highNodes
207
207
}
208
208
209
- func usageToKeysAndValues (usage map [v1. ResourceName ] * resource. Quantity ) []interface {} {
209
+ func usageToKeysAndValues (usage api. ReferencedResourceList ) []interface {} {
210
210
// log message in one line
211
211
keysAndValues := []interface {}{}
212
212
if quantity , exists := usage [v1 .ResourceCPU ]; exists {
@@ -241,7 +241,7 @@ func evictPodsFromSourceNodes(
241
241
usageClient usageClient ,
242
242
) {
243
243
// upper bound on total number of pods/cpu/memory and optional extended resources to be moved
244
- totalAvailableUsage := map [v1. ResourceName ] * resource. Quantity {}
244
+ totalAvailableUsage := api. ReferencedResourceList {}
245
245
for _ , resourceName := range resourceNames {
246
246
totalAvailableUsage [resourceName ] = & resource.Quantity {}
247
247
}
@@ -296,7 +296,7 @@ func evictPods(
296
296
evictableNamespaces * api.Namespaces ,
297
297
inputPods []* v1.Pod ,
298
298
nodeInfo NodeInfo ,
299
- totalAvailableUsage map [v1. ResourceName ] * resource. Quantity ,
299
+ totalAvailableUsage api. ReferencedResourceList ,
300
300
taintsOfLowNodes map [string ][]v1.Taint ,
301
301
podEvictor frameworktypes.Evictor ,
302
302
evictOptions evictions.EvictOptions ,
@@ -400,7 +400,7 @@ func sortNodesByUsage(nodes []NodeInfo, ascending bool) {
400
400
401
401
// isNodeAboveTargetUtilization checks if a node is overutilized
402
402
// At least one resource has to be above the high threshold
403
- func isNodeAboveTargetUtilization (usage NodeUsage , threshold map [v1. ResourceName ] * resource. Quantity ) bool {
403
+ func isNodeAboveTargetUtilization (usage NodeUsage , threshold api. ReferencedResourceList ) bool {
404
404
for name , nodeValue := range usage .usage {
405
405
// usage.highResourceThreshold[name] < nodeValue
406
406
if threshold [name ].Cmp (* nodeValue ) == - 1 {
@@ -412,7 +412,7 @@ func isNodeAboveTargetUtilization(usage NodeUsage, threshold map[v1.ResourceName
412
412
413
413
// isNodeWithLowUtilization checks if a node is underutilized
414
414
// All resources have to be below the low threshold
415
- func isNodeWithLowUtilization (usage NodeUsage , threshold map [v1. ResourceName ] * resource. Quantity ) bool {
415
+ func isNodeWithLowUtilization (usage NodeUsage , threshold api. ReferencedResourceList ) bool {
416
416
for name , nodeValue := range usage .usage {
417
417
// usage.lowResourceThreshold[name] < nodeValue
418
418
if threshold [name ].Cmp (* nodeValue ) == - 1 {
0 commit comments