From 21748701f1e1e348678b7f633cf07121cc97578b Mon Sep 17 00:00:00 2001 From: Vishnu kannan Date: Wed, 20 Jan 2016 15:34:58 -0800 Subject: [PATCH] Avoid nodes that have `0` cpu and memory capacity. Signed-off-by: Vishnu kannan --- pkg/kubelet/kubelet.go | 4 +--- plugin/pkg/scheduler/algorithm/predicates/predicates.go | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index ae920762666..edda108ada2 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -2159,9 +2159,7 @@ func hasHostPortConflicts(pods []*api.Pod) bool { return false } -// hasInsufficientfFreeResources detects pods that exceeds node's resources. -// TODO: Consider integrate disk space into this function, and returns a -// suitable reason and message per resource type. +// hasInsufficientfFreeResources detects pods that exceeds node's cpu and memory resource. func (kl *Kubelet) hasInsufficientfFreeResources(pods []*api.Pod) (bool, bool) { info, err := kl.GetCachedMachineInfo() if err != nil { diff --git a/plugin/pkg/scheduler/algorithm/predicates/predicates.go b/plugin/pkg/scheduler/algorithm/predicates/predicates.go index 539f2be5c4c..f12d33f8aff 100644 --- a/plugin/pkg/scheduler/algorithm/predicates/predicates.go +++ b/plugin/pkg/scheduler/algorithm/predicates/predicates.go @@ -164,8 +164,8 @@ func CheckPodsExceedingFreeResources(pods []*api.Pod, capacity api.ResourceList) memoryRequested := int64(0) for _, pod := range pods { podRequest := getResourceRequest(pod) - fitsCPU := totalMilliCPU == 0 || (totalMilliCPU-milliCPURequested) >= podRequest.milliCPU - fitsMemory := totalMemory == 0 || (totalMemory-memoryRequested) >= podRequest.memory + fitsCPU := (totalMilliCPU - milliCPURequested) >= podRequest.milliCPU + fitsMemory := (totalMemory - memoryRequested) >= podRequest.memory if !fitsCPU { // the pod doesn't fit due to CPU request notFittingCPU = append(notFittingCPU, pod)