Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b055246f
Commit
b055246f
authored
Jun 15, 2017
by
Binbin Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace capacity with allocatable to calculate pod resource
It is not accurate to use capacity to do the calculation.
parent
562e721e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
predicates.go
test/e2e/scheduling/predicates.go
+10
-10
No files found.
test/e2e/scheduling/predicates.go
View file @
b055246f
...
...
@@ -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
()
{
nodeMax
Capacity
:=
int64
(
0
)
nodeMax
Allocatable
:=
int64
(
0
)
nodeTo
Capacity
Map
:=
make
(
map
[
string
]
int64
)
nodeTo
Allocatable
Map
:=
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
))
nodeTo
CapacityMap
[
node
.
Name
]
=
capacity
.
MilliValue
()
if
nodeMax
Capacity
<
capacity
.
MilliValue
()
{
nodeMax
Capacity
=
capacity
.
MilliValue
()
nodeTo
AllocatableMap
[
node
.
Name
]
=
allocatable
.
MilliValue
()
if
nodeMax
Allocatable
<
allocatable
.
MilliValue
()
{
nodeMax
Allocatable
=
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
:=
nodeTo
Capacity
Map
[
pod
.
Spec
.
NodeName
]
_
,
found
:=
nodeTo
Allocatable
Map
[
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
)
nodeTo
Capacity
Map
[
pod
.
Spec
.
NodeName
]
-=
getRequestedCPU
(
pod
)
nodeTo
Allocatable
Map
[
pod
.
Spec
.
NodeName
]
-=
getRequestedCPU
(
pod
)
}
}
var
podsNeededForSaturation
int
milliCpuPerPod
:=
nodeMax
Capacity
/
maxNumberOfPods
milliCpuPerPod
:=
nodeMax
Allocatable
/
maxNumberOfPods
if
milliCpuPerPod
<
minPodCPURequest
{
milliCpuPerPod
=
minPodCPURequest
}
framework
.
Logf
(
"Using pod capacity: %vm"
,
milliCpuPerPod
)
for
name
,
leftCapacity
:=
range
nodeTo
Capacity
Map
{
for
name
,
leftCapacity
:=
range
nodeTo
Allocatable
Map
{
framework
.
Logf
(
"Node: %v has cpu capacity: %vm"
,
name
,
leftCapacity
)
podsNeededForSaturation
+=
(
int
)(
leftCapacity
/
milliCpuPerPod
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment