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
25cbd1c7
Unverified
Commit
25cbd1c7
authored
Sep 10, 2018
by
k8s-ci-robot
Committed by
GitHub
Sep 10, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #67781 from dashpole/fix_priority_tests
Fix priority tests
parents
d472a547
90f58c11
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
10 deletions
+22
-10
preemption_test.go
pkg/kubelet/preemption/preemption_test.go
+11
-1
pod_update.go
pkg/kubelet/types/pod_update.go
+6
-7
critical_pod_test.go
test/e2e_node/critical_pod_test.go
+5
-2
No files found.
pkg/kubelet/preemption/preemption_test.go
View file @
25cbd1c7
...
@@ -130,7 +130,7 @@ func TestEvictPodsToFreeRequests(t *testing.T) {
...
@@ -130,7 +130,7 @@ func TestEvictPodsToFreeRequests(t *testing.T) {
}
}
for
_
,
r
:=
range
runs
{
for
_
,
r
:=
range
runs
{
podProvider
.
setPods
(
r
.
inputPods
)
podProvider
.
setPods
(
r
.
inputPods
)
outErr
:=
criticalPodAdmissionHandler
.
evictPodsToFreeRequests
(
nil
,
r
.
insufficientResources
)
outErr
:=
criticalPodAdmissionHandler
.
evictPodsToFreeRequests
(
allPods
[
critical
]
,
r
.
insufficientResources
)
outputPods
:=
podKiller
.
getKilledPods
()
outputPods
:=
podKiller
.
getKilledPods
()
if
!
r
.
expectErr
&&
outErr
!=
nil
{
if
!
r
.
expectErr
&&
outErr
!=
nil
{
t
.
Errorf
(
"evictPodsToFreeRequests returned an unexpected error during the %s test. Err: %v"
,
r
.
testName
,
outErr
)
t
.
Errorf
(
"evictPodsToFreeRequests returned an unexpected error during the %s test. Err: %v"
,
r
.
testName
,
outErr
)
...
@@ -171,6 +171,7 @@ func TestGetPodsToPreempt(t *testing.T) {
...
@@ -171,6 +171,7 @@ func TestGetPodsToPreempt(t *testing.T) {
runs
:=
[]
testRun
{
runs
:=
[]
testRun
{
{
{
testName
:
"no requirements"
,
testName
:
"no requirements"
,
preemptor
:
allPods
[
critical
],
inputPods
:
[]
*
v1
.
Pod
{},
inputPods
:
[]
*
v1
.
Pod
{},
insufficientResources
:
getAdmissionRequirementList
(
0
,
0
,
0
),
insufficientResources
:
getAdmissionRequirementList
(
0
,
0
,
0
),
expectErr
:
false
,
expectErr
:
false
,
...
@@ -178,6 +179,7 @@ func TestGetPodsToPreempt(t *testing.T) {
...
@@ -178,6 +179,7 @@ func TestGetPodsToPreempt(t *testing.T) {
},
},
{
{
testName
:
"no pods"
,
testName
:
"no pods"
,
preemptor
:
allPods
[
critical
],
inputPods
:
[]
*
v1
.
Pod
{},
inputPods
:
[]
*
v1
.
Pod
{},
insufficientResources
:
getAdmissionRequirementList
(
0
,
0
,
1
),
insufficientResources
:
getAdmissionRequirementList
(
0
,
0
,
1
),
expectErr
:
true
,
expectErr
:
true
,
...
@@ -185,6 +187,7 @@ func TestGetPodsToPreempt(t *testing.T) {
...
@@ -185,6 +187,7 @@ func TestGetPodsToPreempt(t *testing.T) {
},
},
{
{
testName
:
"equal pods and resources requirements"
,
testName
:
"equal pods and resources requirements"
,
preemptor
:
allPods
[
critical
],
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
burstable
]},
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
burstable
]},
insufficientResources
:
getAdmissionRequirementList
(
100
,
100
,
1
),
insufficientResources
:
getAdmissionRequirementList
(
100
,
100
,
1
),
expectErr
:
false
,
expectErr
:
false
,
...
@@ -192,6 +195,7 @@ func TestGetPodsToPreempt(t *testing.T) {
...
@@ -192,6 +195,7 @@ func TestGetPodsToPreempt(t *testing.T) {
},
},
{
{
testName
:
"higher requirements than pod requests"
,
testName
:
"higher requirements than pod requests"
,
preemptor
:
allPods
[
critical
],
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
burstable
]},
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
burstable
]},
insufficientResources
:
getAdmissionRequirementList
(
200
,
200
,
2
),
insufficientResources
:
getAdmissionRequirementList
(
200
,
200
,
2
),
expectErr
:
true
,
expectErr
:
true
,
...
@@ -199,6 +203,7 @@ func TestGetPodsToPreempt(t *testing.T) {
...
@@ -199,6 +203,7 @@ func TestGetPodsToPreempt(t *testing.T) {
},
},
{
{
testName
:
"choose between bestEffort and burstable"
,
testName
:
"choose between bestEffort and burstable"
,
preemptor
:
allPods
[
critical
],
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
burstable
],
allPods
[
bestEffort
]},
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
burstable
],
allPods
[
bestEffort
]},
insufficientResources
:
getAdmissionRequirementList
(
0
,
0
,
1
),
insufficientResources
:
getAdmissionRequirementList
(
0
,
0
,
1
),
expectErr
:
false
,
expectErr
:
false
,
...
@@ -206,6 +211,7 @@ func TestGetPodsToPreempt(t *testing.T) {
...
@@ -206,6 +211,7 @@ func TestGetPodsToPreempt(t *testing.T) {
},
},
{
{
testName
:
"choose between burstable and guaranteed"
,
testName
:
"choose between burstable and guaranteed"
,
preemptor
:
allPods
[
critical
],
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
burstable
],
allPods
[
guaranteed
]},
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
burstable
],
allPods
[
guaranteed
]},
insufficientResources
:
getAdmissionRequirementList
(
0
,
0
,
1
),
insufficientResources
:
getAdmissionRequirementList
(
0
,
0
,
1
),
expectErr
:
false
,
expectErr
:
false
,
...
@@ -213,6 +219,7 @@ func TestGetPodsToPreempt(t *testing.T) {
...
@@ -213,6 +219,7 @@ func TestGetPodsToPreempt(t *testing.T) {
},
},
{
{
testName
:
"choose lower request burstable if it meets requirements"
,
testName
:
"choose lower request burstable if it meets requirements"
,
preemptor
:
allPods
[
critical
],
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
bestEffort
],
allPods
[
highRequestBurstable
],
allPods
[
burstable
]},
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
bestEffort
],
allPods
[
highRequestBurstable
],
allPods
[
burstable
]},
insufficientResources
:
getAdmissionRequirementList
(
100
,
100
,
0
),
insufficientResources
:
getAdmissionRequirementList
(
100
,
100
,
0
),
expectErr
:
false
,
expectErr
:
false
,
...
@@ -220,6 +227,7 @@ func TestGetPodsToPreempt(t *testing.T) {
...
@@ -220,6 +227,7 @@ func TestGetPodsToPreempt(t *testing.T) {
},
},
{
{
testName
:
"choose higher request burstable if lower does not meet requirements"
,
testName
:
"choose higher request burstable if lower does not meet requirements"
,
preemptor
:
allPods
[
critical
],
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
bestEffort
],
allPods
[
burstable
],
allPods
[
highRequestBurstable
]},
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
bestEffort
],
allPods
[
burstable
],
allPods
[
highRequestBurstable
]},
insufficientResources
:
getAdmissionRequirementList
(
150
,
150
,
0
),
insufficientResources
:
getAdmissionRequirementList
(
150
,
150
,
0
),
expectErr
:
false
,
expectErr
:
false
,
...
@@ -227,6 +235,7 @@ func TestGetPodsToPreempt(t *testing.T) {
...
@@ -227,6 +235,7 @@ func TestGetPodsToPreempt(t *testing.T) {
},
},
{
{
testName
:
"multiple pods required"
,
testName
:
"multiple pods required"
,
preemptor
:
allPods
[
critical
],
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
bestEffort
],
allPods
[
burstable
],
allPods
[
highRequestBurstable
],
allPods
[
guaranteed
],
allPods
[
highRequestGuaranteed
]},
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
bestEffort
],
allPods
[
burstable
],
allPods
[
highRequestBurstable
],
allPods
[
guaranteed
],
allPods
[
highRequestGuaranteed
]},
insufficientResources
:
getAdmissionRequirementList
(
350
,
350
,
0
),
insufficientResources
:
getAdmissionRequirementList
(
350
,
350
,
0
),
expectErr
:
false
,
expectErr
:
false
,
...
@@ -234,6 +243,7 @@ func TestGetPodsToPreempt(t *testing.T) {
...
@@ -234,6 +243,7 @@ func TestGetPodsToPreempt(t *testing.T) {
},
},
{
{
testName
:
"evict guaranteed when we have to, and dont evict the extra burstable"
,
testName
:
"evict guaranteed when we have to, and dont evict the extra burstable"
,
preemptor
:
allPods
[
critical
],
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
bestEffort
],
allPods
[
burstable
],
allPods
[
highRequestBurstable
],
allPods
[
guaranteed
],
allPods
[
highRequestGuaranteed
]},
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
bestEffort
],
allPods
[
burstable
],
allPods
[
highRequestBurstable
],
allPods
[
guaranteed
],
allPods
[
highRequestGuaranteed
]},
insufficientResources
:
getAdmissionRequirementList
(
0
,
550
,
0
),
insufficientResources
:
getAdmissionRequirementList
(
0
,
550
,
0
),
expectErr
:
false
,
expectErr
:
false
,
...
...
pkg/kubelet/types/pod_update.go
View file @
25cbd1c7
...
@@ -159,13 +159,12 @@ func IsCriticalPod(pod *v1.Pod) bool {
...
@@ -159,13 +159,12 @@ func IsCriticalPod(pod *v1.Pod) bool {
return
false
return
false
}
}
// Preemptable returns true if preemptor pod can preempt preemptee pod:
// Preemptable returns true if preemptor pod can preempt preemptee pod
// - If preemptor's is greater than preemptee's priority, it's preemptable (return true)
// if preemptee is not critical or if preemptor's priority is greater than preemptee's priority
// - If preemptor (or its priority) is nil and preemptee bears the critical pod annotation key,
// preemptee can not be preempted (return false)
// - If preemptor (or its priority) is nil and preemptee's priority is greater than or equal to
// SystemCriticalPriority, preemptee can not be preempted (return false)
func
Preemptable
(
preemptor
,
preemptee
*
v1
.
Pod
)
bool
{
func
Preemptable
(
preemptor
,
preemptee
*
v1
.
Pod
)
bool
{
if
IsCriticalPod
(
preemptor
)
&&
!
IsCriticalPod
(
preemptee
)
{
return
true
}
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
PodPriority
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
PodPriority
)
{
if
(
preemptor
!=
nil
&&
preemptor
.
Spec
.
Priority
!=
nil
)
&&
if
(
preemptor
!=
nil
&&
preemptor
.
Spec
.
Priority
!=
nil
)
&&
(
preemptee
!=
nil
&&
preemptee
.
Spec
.
Priority
!=
nil
)
{
(
preemptee
!=
nil
&&
preemptee
.
Spec
.
Priority
!=
nil
)
{
...
@@ -173,7 +172,7 @@ func Preemptable(preemptor, preemptee *v1.Pod) bool {
...
@@ -173,7 +172,7 @@ func Preemptable(preemptor, preemptee *v1.Pod) bool {
}
}
}
}
return
!
IsCriticalPod
(
preemptee
)
return
false
}
}
// IsCritical returns true if parameters bear the critical pod annotation
// IsCritical returns true if parameters bear the critical pod annotation
...
...
test/e2e_node/critical_pod_test.go
View file @
25cbd1c7
...
@@ -45,6 +45,9 @@ var _ = framework.KubeDescribe("CriticalPod [Serial] [Disruptive] [NodeFeature:C
...
@@ -45,6 +45,9 @@ var _ = framework.KubeDescribe("CriticalPod [Serial] [Disruptive] [NodeFeature:C
Context
(
"when we need to admit a critical pod"
,
func
()
{
Context
(
"when we need to admit a critical pod"
,
func
()
{
tempSetCurrentKubeletConfig
(
f
,
func
(
initialConfig
*
kubeletconfig
.
KubeletConfiguration
)
{
tempSetCurrentKubeletConfig
(
f
,
func
(
initialConfig
*
kubeletconfig
.
KubeletConfiguration
)
{
if
initialConfig
.
FeatureGates
==
nil
{
initialConfig
.
FeatureGates
=
make
(
map
[
string
]
bool
)
}
initialConfig
.
FeatureGates
[
string
(
features
.
ExperimentalCriticalPodAnnotation
)]
=
true
initialConfig
.
FeatureGates
[
string
(
features
.
ExperimentalCriticalPodAnnotation
)]
=
true
})
})
...
@@ -142,9 +145,9 @@ func getTestPod(critical bool, name string, resources v1.ResourceRequirements) *
...
@@ -142,9 +145,9 @@ func getTestPod(critical bool, name string, resources v1.ResourceRequirements) *
pod
.
ObjectMeta
.
Annotations
=
map
[
string
]
string
{
pod
.
ObjectMeta
.
Annotations
=
map
[
string
]
string
{
kubelettypes
.
CriticalPodAnnotationKey
:
""
,
kubelettypes
.
CriticalPodAnnotationKey
:
""
,
}
}
Expect
(
kubelettypes
.
IsCritical
Pod
(
pod
))
.
To
(
BeTrue
(),
"pod should be a critical pod"
)
Expect
(
kubelettypes
.
IsCritical
(
pod
.
Namespace
,
pod
.
Annotations
))
.
To
(
BeTrue
(),
"pod should be a critical pod"
)
}
else
{
}
else
{
Expect
(
kubelettypes
.
IsCritical
Pod
(
pod
))
.
To
(
BeFalse
(),
"pod should not be a critical pod"
)
Expect
(
kubelettypes
.
IsCritical
(
pod
.
Namespace
,
pod
.
Annotations
))
.
To
(
BeFalse
(),
"pod should not be a critical pod"
)
}
}
return
pod
return
pod
}
}
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