Ouput volumes (total capacity and requests) too along with cpu and memory

when the feature BalanceAttachedNodeVolumes is used.
pull/8/head
Avesh Agarwal 2018-08-07 15:40:33 -04:00
parent ea7f711ae2
commit be741feb1a
1 changed files with 21 additions and 8 deletions

View File

@ -21,6 +21,8 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
priorityutil "k8s.io/kubernetes/pkg/scheduler/algorithm/priorities/util" priorityutil "k8s.io/kubernetes/pkg/scheduler/algorithm/priorities/util"
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api" schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
schedulercache "k8s.io/kubernetes/pkg/scheduler/cache" schedulercache "k8s.io/kubernetes/pkg/scheduler/cache"
@ -56,20 +58,31 @@ func (r *ResourceAllocationPriority) PriorityMap(
requested.Memory += nodeInfo.NonZeroRequest().Memory requested.Memory += nodeInfo.NonZeroRequest().Memory
var score int64 var score int64
// Check if the pod has volumes and this could be added to scorer function for balanced resource allocation. // Check if the pod has volumes and this could be added to scorer function for balanced resource allocation.
if len(pod.Spec.Volumes) >= 0 && nodeInfo.TransientInfo != nil { if len(pod.Spec.Volumes) >= 0 && utilfeature.DefaultFeatureGate.Enabled(features.BalanceAttachedNodeVolumes) && nodeInfo.TransientInfo != nil {
score = r.scorer(&requested, &allocatable, true, nodeInfo.TransientInfo.TransNodeInfo.RequestedVolumes, nodeInfo.TransientInfo.TransNodeInfo.AllocatableVolumesCount) score = r.scorer(&requested, &allocatable, true, nodeInfo.TransientInfo.TransNodeInfo.RequestedVolumes, nodeInfo.TransientInfo.TransNodeInfo.AllocatableVolumesCount)
} else { } else {
score = r.scorer(&requested, &allocatable, false, 0, 0) score = r.scorer(&requested, &allocatable, false, 0, 0)
} }
if glog.V(10) { if glog.V(10) {
glog.Infof( if len(pod.Spec.Volumes) >= 0 && utilfeature.DefaultFeatureGate.Enabled(features.BalanceAttachedNodeVolumes) && nodeInfo.TransientInfo != nil {
"%v -> %v: %v, capacity %d millicores %d memory bytes, total request %d millicores %d memory bytes, score %d", glog.Infof(
pod.Name, node.Name, r.Name, "%v -> %v: %v, capacity %d millicores %d memory bytes, %d volumes, total request %d millicores %d memory bytes %d volumes, score %d",
allocatable.MilliCPU, allocatable.Memory, pod.Name, node.Name, r.Name,
requested.MilliCPU, requested.Memory, allocatable.MilliCPU, allocatable.Memory, nodeInfo.TransientInfo.TransNodeInfo.AllocatableVolumesCount,
score, requested.MilliCPU, requested.Memory,
) nodeInfo.TransientInfo.TransNodeInfo.RequestedVolumes,
score,
)
} else {
glog.Infof(
"%v -> %v: %v, capacity %d millicores %d memory bytes, total request %d millicores %d memory bytes, score %d",
pod.Name, node.Name, r.Name,
allocatable.MilliCPU, allocatable.Memory,
requested.MilliCPU, requested.Memory,
score,
)
}
} }
return schedulerapi.HostPriority{ return schedulerapi.HostPriority{