func()

in pkg/noderesources/resource_allocation.go [49:75]


func (r *resourceAllocationScorer) score(
	pod *v1.Pod,
	nodeInfo *framework.NodeInfo) (int64, *framework.Status) {
	node := nodeInfo.Node()
	if node == nil {
		return 0, framework.NewStatus(framework.Error, "node not found")
	}
	if r.resourceToWeightMap == nil {
		return 0, framework.NewStatus(framework.Error, "resources not found")
	}
	requested := make(resourceToValueMap, len(r.resourceToWeightMap))
	allocatable := make(resourceToValueMap, len(r.resourceToWeightMap))
	for resource := range r.resourceToWeightMap {
		allocatable[resource], requested[resource] = calculateResourceAllocatableRequest(nodeInfo, pod, resource)
	}

	score := r.scorer(requested, allocatable)

	if klog.V(10).Enabled() {
		klog.InfoS("Resources and score",
			"podName", pod.Name, "nodeName", node.Name, "scorer", r.Name,
			"allocatableResources", allocatable, "requestedResources", requested,
			"score", score)
	}

	return score, nil
}