From b055246f0a9dd8579767e0f5230e8353400723f6 Mon Sep 17 00:00:00 2001 From: Binbin Zhao Date: Thu, 15 Jun 2017 19:06:05 -0700 Subject: [PATCH 1/3] Replace capacity with allocatable to calculate pod resource It is not accurate to use capacity to do the calculation. --- test/e2e/scheduling/predicates.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/e2e/scheduling/predicates.go b/test/e2e/scheduling/predicates.go index d104c987458..e974e1c386f 100644 --- a/test/e2e/scheduling/predicates.go +++ b/test/e2e/scheduling/predicates.go @@ -151,15 +151,15 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() { // It assumes that cluster add-on pods stay stable and cannot be run in parallel with any other test that touches Nodes or Pods. // It is so because we need to have precise control on what's running in the cluster. It("validates resource limits of pods that are allowed to run [Conformance]", func() { - nodeMaxCapacity := int64(0) + nodeMaxAllocatable := int64(0) - nodeToCapacityMap := make(map[string]int64) + nodeToAllocatableMap := make(map[string]int64) for _, node := range nodeList.Items { - capacity, found := node.Status.Capacity["cpu"] + allocatable, found := node.Status.Allocatable["cpu"] Expect(found).To(Equal(true)) - nodeToCapacityMap[node.Name] = capacity.MilliValue() - if nodeMaxCapacity < capacity.MilliValue() { - nodeMaxCapacity = capacity.MilliValue() + nodeToAllocatableMap[node.Name] = allocatable.MilliValue() + if nodeMaxAllocatable < allocatable.MilliValue() { + nodeMaxAllocatable = allocatable.MilliValue() } } framework.WaitForStableCluster(cs, masterNodes) @@ -167,21 +167,21 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() { pods, err := cs.Core().Pods(metav1.NamespaceAll).List(metav1.ListOptions{}) framework.ExpectNoError(err) for _, pod := range pods.Items { - _, found := nodeToCapacityMap[pod.Spec.NodeName] + _, found := nodeToAllocatableMap[pod.Spec.NodeName] if found && pod.Status.Phase != v1.PodSucceeded && pod.Status.Phase != v1.PodFailed { framework.Logf("Pod %v requesting resource cpu=%vm on Node %v", pod.Name, getRequestedCPU(pod), pod.Spec.NodeName) - nodeToCapacityMap[pod.Spec.NodeName] -= getRequestedCPU(pod) + nodeToAllocatableMap[pod.Spec.NodeName] -= getRequestedCPU(pod) } } var podsNeededForSaturation int - milliCpuPerPod := nodeMaxCapacity / maxNumberOfPods + milliCpuPerPod := nodeMaxAllocatable / maxNumberOfPods if milliCpuPerPod < minPodCPURequest { milliCpuPerPod = minPodCPURequest } framework.Logf("Using pod capacity: %vm", milliCpuPerPod) - for name, leftCapacity := range nodeToCapacityMap { + for name, leftCapacity := range nodeToAllocatableMap { framework.Logf("Node: %v has cpu capacity: %vm", name, leftCapacity) podsNeededForSaturation += (int)(leftCapacity / milliCpuPerPod) } From 9cbe992fc54e5587f9fcdf4e5b6cda6020f4a937 Mon Sep 17 00:00:00 2001 From: Binbin Zhao Date: Wed, 21 Jun 2017 00:55:06 -0700 Subject: [PATCH 2/3] Also rename leftCapacity to leftAllocatable --- test/e2e/scheduling/predicates.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/scheduling/predicates.go b/test/e2e/scheduling/predicates.go index e974e1c386f..548e316a59b 100644 --- a/test/e2e/scheduling/predicates.go +++ b/test/e2e/scheduling/predicates.go @@ -181,9 +181,9 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() { milliCpuPerPod = minPodCPURequest } framework.Logf("Using pod capacity: %vm", milliCpuPerPod) - for name, leftCapacity := range nodeToAllocatableMap { - framework.Logf("Node: %v has cpu capacity: %vm", name, leftCapacity) - podsNeededForSaturation += (int)(leftCapacity / milliCpuPerPod) + for name, leftAllocatable := range nodeToAllocatableMap { + framework.Logf("Node: %v has cpu allocatable: %vm", name, leftAllocatable) + podsNeededForSaturation += (int)(leftleftAllocatable / milliCpuPerPod) } By(fmt.Sprintf("Starting additional %v Pods to fully saturate the cluster CPU and trying to start another one", podsNeededForSaturation)) From 82cbbb4845213c33a5b2e31986ffa025cd543ff0 Mon Sep 17 00:00:00 2001 From: Binbin Zhao Date: Wed, 21 Jun 2017 01:15:55 -0700 Subject: [PATCH 3/3] Fix a typo Fix a typo --- test/e2e/scheduling/predicates.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/scheduling/predicates.go b/test/e2e/scheduling/predicates.go index 548e316a59b..2d62fc02b02 100644 --- a/test/e2e/scheduling/predicates.go +++ b/test/e2e/scheduling/predicates.go @@ -183,7 +183,7 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() { framework.Logf("Using pod capacity: %vm", milliCpuPerPod) for name, leftAllocatable := range nodeToAllocatableMap { framework.Logf("Node: %v has cpu allocatable: %vm", name, leftAllocatable) - podsNeededForSaturation += (int)(leftleftAllocatable / milliCpuPerPod) + podsNeededForSaturation += (int)(leftAllocatable / milliCpuPerPod) } By(fmt.Sprintf("Starting additional %v Pods to fully saturate the cluster CPU and trying to start another one", podsNeededForSaturation))