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
0f0e1040
Commit
0f0e1040
authored
Jun 14, 2017
by
Klaus Ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checked whether balanced Pods were created.
parent
c885c70c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
16 deletions
+23
-16
priorities.go
test/e2e/scheduling/priorities.go
+23
-16
No files found.
test/e2e/scheduling/priorities.go
View file @
0f0e1040
...
@@ -79,7 +79,6 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -79,7 +79,6 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
err
:=
framework
.
CheckTestingNSDeletedExcept
(
cs
,
ns
)
err
:=
framework
.
CheckTestingNSDeletedExcept
(
cs
,
ns
)
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
err
=
framework
.
WaitForPodsRunningReady
(
cs
,
metav1
.
NamespaceSystem
,
int32
(
systemPodsNo
),
0
,
framework
.
PodReadyBeforeTimeout
,
ignoreLabels
)
err
=
framework
.
WaitForPodsRunningReady
(
cs
,
metav1
.
NamespaceSystem
,
int32
(
systemPodsNo
),
0
,
framework
.
PodReadyBeforeTimeout
,
ignoreLabels
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
})
})
...
@@ -94,7 +93,8 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -94,7 +93,8 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
defer
framework
.
RemoveLabelOffNode
(
cs
,
nodeName
,
k
)
defer
framework
.
RemoveLabelOffNode
(
cs
,
nodeName
,
k
)
// make the nodes have balanced cpu,mem usage ratio
// make the nodes have balanced cpu,mem usage ratio
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.6
)
err
:=
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.6
)
framework
.
ExpectNoError
(
err
)
By
(
"Trying to relaunch the pod, now with labels."
)
By
(
"Trying to relaunch the pod, now with labels."
)
labelPodName
:=
"pod-with-node-affinity"
labelPodName
:=
"pod-with-node-affinity"
pod
:=
createPausePod
(
f
,
pausePodConfig
{
pod
:=
createPausePod
(
f
,
pausePodConfig
{
...
@@ -141,10 +141,9 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -141,10 +141,9 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
framework
.
AddOrUpdateLabelOnNode
(
cs
,
nodeName
,
k
,
v
)
framework
.
AddOrUpdateLabelOnNode
(
cs
,
nodeName
,
k
,
v
)
framework
.
ExpectNodeHasLabel
(
cs
,
nodeName
,
k
,
v
)
framework
.
ExpectNodeHasLabel
(
cs
,
nodeName
,
k
,
v
)
defer
framework
.
RemoveLabelOffNode
(
cs
,
nodeName
,
k
)
defer
framework
.
RemoveLabelOffNode
(
cs
,
nodeName
,
k
)
// make the nodes have balanced cpu,mem usage
// make the nodes have balanced cpu,mem usage
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.6
)
err
:=
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.6
)
framework
.
ExpectNoError
(
err
)
By
(
"Trying to launch the pod, now with podAffinity."
)
By
(
"Trying to launch the pod, now with podAffinity."
)
labelPodName
:=
"pod-with-podaffinity"
labelPodName
:=
"pod-with-podaffinity"
pod
=
createPausePod
(
f
,
pausePodConfig
{
pod
=
createPausePod
(
f
,
pausePodConfig
{
...
@@ -203,9 +202,9 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -203,9 +202,9 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
framework
.
AddOrUpdateLabelOnNode
(
cs
,
nodeName
,
k
,
v
)
framework
.
AddOrUpdateLabelOnNode
(
cs
,
nodeName
,
k
,
v
)
framework
.
ExpectNodeHasLabel
(
cs
,
nodeName
,
k
,
v
)
framework
.
ExpectNodeHasLabel
(
cs
,
nodeName
,
k
,
v
)
defer
framework
.
RemoveLabelOffNode
(
cs
,
nodeName
,
k
)
defer
framework
.
RemoveLabelOffNode
(
cs
,
nodeName
,
k
)
// make the nodes have balanced cpu,mem usage
// make the nodes have balanced cpu,mem usage
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.6
)
err
:=
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.6
)
framework
.
ExpectNoError
(
err
)
By
(
"Trying to launch the pod with podAntiAffinity."
)
By
(
"Trying to launch the pod with podAntiAffinity."
)
labelPodName
:=
"pod-with-pod-antiaffinity"
labelPodName
:=
"pod-with-pod-antiaffinity"
pod
=
createPausePod
(
f
,
pausePodConfig
{
pod
=
createPausePod
(
f
,
pausePodConfig
{
...
@@ -253,7 +252,8 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -253,7 +252,8 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
It
(
"Pod should avoid to schedule to node that have avoidPod annotation"
,
func
()
{
It
(
"Pod should avoid to schedule to node that have avoidPod annotation"
,
func
()
{
nodeName
:=
nodeList
.
Items
[
0
]
.
Name
nodeName
:=
nodeList
.
Items
[
0
]
.
Name
// make the nodes have balanced cpu,mem usage
// make the nodes have balanced cpu,mem usage
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.5
)
err
:=
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.5
)
framework
.
ExpectNoError
(
err
)
By
(
"Create a RC, with 0 replicas"
)
By
(
"Create a RC, with 0 replicas"
)
rc
:=
createRC
(
ns
,
"scheduler-priority-avoid-pod"
,
int32
(
0
),
map
[
string
]
string
{
"name"
:
"scheduler-priority-avoid-pod"
},
f
,
podRequestedResource
)
rc
:=
createRC
(
ns
,
"scheduler-priority-avoid-pod"
,
int32
(
0
),
map
[
string
]
string
{
"name"
:
"scheduler-priority-avoid-pod"
},
f
,
podRequestedResource
)
// Cleanup the replication controller when we are done.
// Cleanup the replication controller when we are done.
...
@@ -314,7 +314,8 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -314,7 +314,8 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
It
(
"Pod should perfer to scheduled to nodes pod can tolerate"
,
func
()
{
It
(
"Pod should perfer to scheduled to nodes pod can tolerate"
,
func
()
{
// make the nodes have balanced cpu,mem usage ratio
// make the nodes have balanced cpu,mem usage ratio
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.5
)
err
:=
createBalancedPodForNodes
(
f
,
cs
,
ns
,
nodeList
.
Items
,
podRequestedResource
,
0.5
)
framework
.
ExpectNoError
(
err
)
//we need apply more taints on a node, because one match toleration only count 1
//we need apply more taints on a node, because one match toleration only count 1
By
(
"Trying to apply 10 taint on the nodes except first one."
)
By
(
"Trying to apply 10 taint on the nodes except first one."
)
nodeName
:=
nodeList
.
Items
[
0
]
.
Name
nodeName
:=
nodeList
.
Items
[
0
]
.
Name
...
@@ -363,24 +364,24 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
...
@@ -363,24 +364,24 @@ var _ = framework.KubeDescribe("SchedulerPriorities [Serial]", func() {
})
})
// createBalancedPodForNodes creates a pod per node that asks for enough resources to make all nodes have the same mem/cpu usage ratio.
// createBalancedPodForNodes creates a pod per node that asks for enough resources to make all nodes have the same mem/cpu usage ratio.
func
createBalancedPodForNodes
(
f
*
framework
.
Framework
,
cs
clientset
.
Interface
,
ns
string
,
nodes
[]
v1
.
Node
,
requestedResource
*
v1
.
ResourceRequirements
,
ratio
float64
)
{
func
createBalancedPodForNodes
(
f
*
framework
.
Framework
,
cs
clientset
.
Interface
,
ns
string
,
nodes
[]
v1
.
Node
,
requestedResource
*
v1
.
ResourceRequirements
,
ratio
float64
)
error
{
// find the max, if the node has the max,use the one, if not,use the ratio parameter
// find the max, if the node has the max,use the one, if not,use the ratio parameter
var
maxC
pu
Fraction
,
maxMemFraction
float64
=
ratio
,
ratio
var
maxC
PU
Fraction
,
maxMemFraction
float64
=
ratio
,
ratio
var
cpuFractionMap
=
make
(
map
[
string
]
float64
)
var
cpuFractionMap
=
make
(
map
[
string
]
float64
)
var
memFractionMap
=
make
(
map
[
string
]
float64
)
var
memFractionMap
=
make
(
map
[
string
]
float64
)
for
_
,
node
:=
range
nodes
{
for
_
,
node
:=
range
nodes
{
cpuFraction
,
memFraction
:=
computeCpuMemFraction
(
cs
,
node
,
requestedResource
)
cpuFraction
,
memFraction
:=
computeCpuMemFraction
(
cs
,
node
,
requestedResource
)
cpuFractionMap
[
node
.
Name
]
=
cpuFraction
cpuFractionMap
[
node
.
Name
]
=
cpuFraction
memFractionMap
[
node
.
Name
]
=
memFraction
memFractionMap
[
node
.
Name
]
=
memFraction
if
cpuFraction
>
maxC
pu
Fraction
{
if
cpuFraction
>
maxC
PU
Fraction
{
maxC
pu
Fraction
=
cpuFraction
maxC
PU
Fraction
=
cpuFraction
}
}
if
memFraction
>
maxMemFraction
{
if
memFraction
>
maxMemFraction
{
maxMemFraction
=
memFraction
maxMemFraction
=
memFraction
}
}
}
}
// we need the max one to keep the same cpu/mem use rate
// we need the max one to keep the same cpu/mem use rate
ratio
=
math
.
Max
(
maxC
pu
Fraction
,
maxMemFraction
)
ratio
=
math
.
Max
(
maxC
PU
Fraction
,
maxMemFraction
)
for
_
,
node
:=
range
nodes
{
for
_
,
node
:=
range
nodes
{
memAllocatable
,
found
:=
node
.
Status
.
Allocatable
[
"memory"
]
memAllocatable
,
found
:=
node
.
Status
.
Allocatable
[
"memory"
]
Expect
(
found
)
.
To
(
Equal
(
true
))
Expect
(
found
)
.
To
(
Equal
(
true
))
...
@@ -397,7 +398,7 @@ func createBalancedPodForNodes(f *framework.Framework, cs clientset.Interface, n
...
@@ -397,7 +398,7 @@ func createBalancedPodForNodes(f *framework.Framework, cs clientset.Interface, n
needCreateResource
[
"memory"
]
=
*
resource
.
NewQuantity
(
int64
((
ratio
-
memFraction
)
*
float64
(
memAllocatableVal
)),
resource
.
BinarySI
)
needCreateResource
[
"memory"
]
=
*
resource
.
NewQuantity
(
int64
((
ratio
-
memFraction
)
*
float64
(
memAllocatableVal
)),
resource
.
BinarySI
)
testutils
.
StartPods
(
cs
,
1
,
ns
,
"priority-balanced-mem-"
+
node
.
Name
,
err
:=
testutils
.
StartPods
(
cs
,
1
,
ns
,
"priority-balanced-mem-"
+
node
.
Name
,
*
initPausePod
(
f
,
pausePodConfig
{
*
initPausePod
(
f
,
pausePodConfig
{
Name
:
""
,
Name
:
""
,
Labels
:
balancePodLabel
,
Labels
:
balancePodLabel
,
...
@@ -407,12 +408,18 @@ func createBalancedPodForNodes(f *framework.Framework, cs clientset.Interface, n
...
@@ -407,12 +408,18 @@ func createBalancedPodForNodes(f *framework.Framework, cs clientset.Interface, n
},
},
NodeName
:
node
.
Name
,
NodeName
:
node
.
Name
,
}),
true
,
framework
.
Logf
)
}),
true
,
framework
.
Logf
)
if
err
!=
nil
{
return
err
}
}
}
for
_
,
node
:=
range
nodes
{
for
_
,
node
:=
range
nodes
{
By
(
"Compute Cpu, Mem Fraction after create balanced pods."
)
By
(
"Compute Cpu, Mem Fraction after create balanced pods."
)
computeCpuMemFraction
(
cs
,
node
,
requestedResource
)
computeCpuMemFraction
(
cs
,
node
,
requestedResource
)
}
}
return
nil
}
}
func
computeCpuMemFraction
(
cs
clientset
.
Interface
,
node
v1
.
Node
,
resource
*
v1
.
ResourceRequirements
)
(
float64
,
float64
)
{
func
computeCpuMemFraction
(
cs
clientset
.
Interface
,
node
v1
.
Node
,
resource
*
v1
.
ResourceRequirements
)
(
float64
,
float64
)
{
...
...
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