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
0c4c219f
Unverified
Commit
0c4c219f
authored
Aug 15, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Aug 15, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #81293 from tedyu/automated-cherry-pick-of-#78493-upstream-release-1.15
Automated cherry pick of #78493: Continue admitting the pod regardless of return value from
parents
32d2b1ad
66d428e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
5 deletions
+51
-5
preemption.go
pkg/kubelet/preemption/preemption.go
+3
-1
preemption_test.go
pkg/kubelet/preemption/preemption_test.go
+48
-4
No files found.
pkg/kubelet/preemption/preemption.go
View file @
0c4c219f
...
@@ -107,7 +107,9 @@ func (c *CriticalPodAdmissionHandler) evictPodsToFreeRequests(admitPod *v1.Pod,
...
@@ -107,7 +107,9 @@ func (c *CriticalPodAdmissionHandler) evictPodsToFreeRequests(admitPod *v1.Pod,
// this is a blocking call and should only return when the pod and its containers are killed.
// this is a blocking call and should only return when the pod and its containers are killed.
err
:=
c
.
killPodFunc
(
pod
,
status
,
nil
)
err
:=
c
.
killPodFunc
(
pod
,
status
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"preemption: pod %s failed to evict %v"
,
format
.
Pod
(
pod
),
err
)
klog
.
Warningf
(
"preemption: pod %s failed to evict %v"
,
format
.
Pod
(
pod
),
err
)
// In future syncPod loops, the kubelet will retry the pod deletion steps that it was stuck on.
continue
}
}
klog
.
Infof
(
"preemption: pod %s evicted successfully"
,
format
.
Pod
(
pod
))
klog
.
Infof
(
"preemption: pod %s evicted successfully"
,
format
.
Pod
(
pod
))
}
}
...
...
pkg/kubelet/preemption/preemption_test.go
View file @
0c4c219f
...
@@ -46,11 +46,12 @@ const (
...
@@ -46,11 +46,12 @@ const (
)
)
type
fakePodKiller
struct
{
type
fakePodKiller
struct
{
killedPods
[]
*
v1
.
Pod
killedPods
[]
*
v1
.
Pod
errDuringPodKilling
bool
}
}
func
newFakePodKiller
()
*
fakePodKiller
{
func
newFakePodKiller
(
errPodKilling
bool
)
*
fakePodKiller
{
return
&
fakePodKiller
{
killedPods
:
[]
*
v1
.
Pod
{}}
return
&
fakePodKiller
{
killedPods
:
[]
*
v1
.
Pod
{}
,
errDuringPodKilling
:
errPodKilling
}
}
}
func
(
f
*
fakePodKiller
)
clear
()
{
func
(
f
*
fakePodKiller
)
clear
()
{
...
@@ -62,6 +63,10 @@ func (f *fakePodKiller) getKilledPods() []*v1.Pod {
...
@@ -62,6 +63,10 @@ func (f *fakePodKiller) getKilledPods() []*v1.Pod {
}
}
func
(
f
*
fakePodKiller
)
killPodNow
(
pod
*
v1
.
Pod
,
status
v1
.
PodStatus
,
gracePeriodOverride
*
int64
)
error
{
func
(
f
*
fakePodKiller
)
killPodNow
(
pod
*
v1
.
Pod
,
status
v1
.
PodStatus
,
gracePeriodOverride
*
int64
)
error
{
if
f
.
errDuringPodKilling
{
f
.
killedPods
=
[]
*
v1
.
Pod
{}
return
fmt
.
Errorf
(
"problem killing pod %v"
,
pod
)
}
f
.
killedPods
=
append
(
f
.
killedPods
,
pod
)
f
.
killedPods
=
append
(
f
.
killedPods
,
pod
)
return
nil
return
nil
}
}
...
@@ -90,6 +95,45 @@ func getTestCriticalPodAdmissionHandler(podProvider *fakePodProvider, podKiller
...
@@ -90,6 +95,45 @@ func getTestCriticalPodAdmissionHandler(podProvider *fakePodProvider, podKiller
}
}
}
}
func
TestEvictPodsToFreeRequestsWithError
(
t
*
testing
.
T
)
{
defer
featuregatetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
ExperimentalCriticalPodAnnotation
,
true
)()
type
testRun
struct
{
testName
string
inputPods
[]
*
v1
.
Pod
insufficientResources
admissionRequirementList
expectErr
bool
expectedOutput
[]
*
v1
.
Pod
}
podProvider
:=
newFakePodProvider
()
podKiller
:=
newFakePodKiller
(
true
)
criticalPodAdmissionHandler
:=
getTestCriticalPodAdmissionHandler
(
podProvider
,
podKiller
)
allPods
:=
getTestPods
()
runs
:=
[]
testRun
{
{
testName
:
"multiple pods eviction error"
,
inputPods
:
[]
*
v1
.
Pod
{
allPods
[
critical
],
allPods
[
bestEffort
],
allPods
[
burstable
],
allPods
[
highRequestBurstable
],
allPods
[
guaranteed
],
allPods
[
highRequestGuaranteed
]},
insufficientResources
:
getAdmissionRequirementList
(
0
,
550
,
0
),
expectErr
:
false
,
expectedOutput
:
nil
,
},
}
for
_
,
r
:=
range
runs
{
podProvider
.
setPods
(
r
.
inputPods
)
outErr
:=
criticalPodAdmissionHandler
.
evictPodsToFreeRequests
(
allPods
[
critical
],
r
.
insufficientResources
)
outputPods
:=
podKiller
.
getKilledPods
()
if
!
r
.
expectErr
&&
outErr
!=
nil
{
t
.
Errorf
(
"evictPodsToFreeRequests returned an unexpected error during the %s test. Err: %v"
,
r
.
testName
,
outErr
)
}
else
if
r
.
expectErr
&&
outErr
==
nil
{
t
.
Errorf
(
"evictPodsToFreeRequests expected an error but returned a successful output=%v during the %s test."
,
outputPods
,
r
.
testName
)
}
else
if
!
podListEqual
(
r
.
expectedOutput
,
outputPods
)
{
t
.
Errorf
(
"evictPodsToFreeRequests expected %v but got %v during the %s test."
,
r
.
expectedOutput
,
outputPods
,
r
.
testName
)
}
podKiller
.
clear
()
}
}
func
TestEvictPodsToFreeRequests
(
t
*
testing
.
T
)
{
func
TestEvictPodsToFreeRequests
(
t
*
testing
.
T
)
{
defer
featuregatetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
ExperimentalCriticalPodAnnotation
,
true
)()
defer
featuregatetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
ExperimentalCriticalPodAnnotation
,
true
)()
type
testRun
struct
{
type
testRun
struct
{
...
@@ -100,7 +144,7 @@ func TestEvictPodsToFreeRequests(t *testing.T) {
...
@@ -100,7 +144,7 @@ func TestEvictPodsToFreeRequests(t *testing.T) {
expectedOutput
[]
*
v1
.
Pod
expectedOutput
[]
*
v1
.
Pod
}
}
podProvider
:=
newFakePodProvider
()
podProvider
:=
newFakePodProvider
()
podKiller
:=
newFakePodKiller
()
podKiller
:=
newFakePodKiller
(
false
)
criticalPodAdmissionHandler
:=
getTestCriticalPodAdmissionHandler
(
podProvider
,
podKiller
)
criticalPodAdmissionHandler
:=
getTestCriticalPodAdmissionHandler
(
podProvider
,
podKiller
)
allPods
:=
getTestPods
()
allPods
:=
getTestPods
()
runs
:=
[]
testRun
{
runs
:=
[]
testRun
{
...
...
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