Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/backend/resources/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ func ContainersResourceList(containers []v1.Container) *ResourceList {
}
}

func ContainersRequestResourceList(containers []v1.Container) *ResourceList {
var cpuUsage, memoryUsage int64
for _, container := range containers {
// unit m
cpuUsage += container.Resources.Requests.Cpu().MilliValue()
// unit Byte
memoryUsage += container.Resources.Requests.Memory().Value()
}
return &ResourceList{
Cpu: cpuUsage,
Memory: memoryUsage,
}
}

func CompareLabels(source map[string]string, target map[string]string) bool {
if len(source) != len(target) {
return false
Expand Down
2 changes: 1 addition & 1 deletion src/backend/resources/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func podUsedResourcesOnAvaliableNode(indexer *client.CacheFactory, avaliableNode
continue
}

resourceList := common.ContainersResourceList(pod.Spec.Containers)
resourceList := common.ContainersRequestResourceList(pod.Spec.Containers)

result.Cpu += resourceList.Cpu
result.Memory += resourceList.Memory
Expand Down