Skip to content

Commit

Permalink
nodeutilization: evictPodsFromSourceNodes: iterate through existing r…
Browse files Browse the repository at this point in the history
…esources
  • Loading branch information
ingvagabund committed Nov 13, 2024
1 parent e655a7e commit b19cb4a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pkg/framework/plugins/nodeutilization/nodeutilization.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,9 @@ func evictPodsFromSourceNodes(
continueEviction continueEvictionCond,
) {
// upper bound on total number of pods/cpu/memory and optional extended resources to be moved
totalAvailableUsage := map[v1.ResourceName]*resource.Quantity{
v1.ResourcePods: {},
v1.ResourceCPU: {},
v1.ResourceMemory: {},
totalAvailableUsage := map[v1.ResourceName]*resource.Quantity{}
for _, resourceName := range resourceNames {
totalAvailableUsage[resourceName] = &resource.Quantity{}
}

taintsOfDestinationNodes := make(map[string][]v1.Taint, len(destinationNodes))
Expand All @@ -260,10 +259,15 @@ func evictPodsFromSourceNodes(
}

// log message in one line
keysAndValues := []interface{}{
"CPU", totalAvailableUsage[v1.ResourceCPU].MilliValue(),
"Mem", totalAvailableUsage[v1.ResourceMemory].Value(),
"Pods", totalAvailableUsage[v1.ResourcePods].Value(),
keysAndValues := []interface{}{}
if quantity, exists := totalAvailableUsage[v1.ResourceCPU]; exists {
keysAndValues = append(keysAndValues, "CPU", quantity.MilliValue())
}
if quantity, exists := totalAvailableUsage[v1.ResourceMemory]; exists {
keysAndValues = append(keysAndValues, "Mem", quantity.Value())
}
if quantity, exists := totalAvailableUsage[v1.ResourcePods]; exists {
keysAndValues = append(keysAndValues, "Pods", quantity.Value())
}
for name := range totalAvailableUsage {
if !node.IsBasicResource(name) {
Expand Down

0 comments on commit b19cb4a

Please sign in to comment.