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
a2e1341e
Commit
a2e1341e
authored
Jan 23, 2017
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DaemonSet controller actively kills failed pods (to recreate them)
parent
90b5d4cb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
105 deletions
+109
-105
daemoncontroller.go
pkg/controller/daemon/daemoncontroller.go
+22
-8
daemon_set.go
test/e2e/daemon_set.go
+87
-97
No files found.
pkg/controller/daemon/daemoncontroller.go
View file @
a2e1341e
...
...
@@ -467,20 +467,34 @@ func (dsc *DaemonSetsController) manage(ds *extensions.DaemonSet) error {
continue
}
daemonPods
,
isRunning
:=
nodeToDaemonPods
[
node
.
Name
]
daemonPods
,
exists
:=
nodeToDaemonPods
[
node
.
Name
]
switch
{
case
shouldSchedule
&&
!
isRunning
:
case
shouldSchedule
&&
!
exists
:
// If daemon pod is supposed to be running on node, but isn't, create daemon pod.
nodesNeedingDaemonPods
=
append
(
nodesNeedingDaemonPods
,
node
.
Name
)
case
shouldContinueRunning
&&
len
(
daemonPods
)
>
1
:
case
shouldContinueRunning
:
// If a daemon pod failed, delete it
// TODO: handle the case when the daemon pods fail consistently and causes kill-recreate hot loop
var
daemonPodsRunning
[]
*
v1
.
Pod
for
i
:=
range
daemonPods
{
daemon
:=
daemonPods
[
i
]
if
daemon
.
Status
.
Phase
==
v1
.
PodFailed
{
glog
.
V
(
2
)
.
Infof
(
"Found failed daemon pod %s/%s, will try to kill it"
,
daemon
.
Namespace
,
daemon
.
Name
)
podsToDelete
=
append
(
podsToDelete
,
daemon
.
Name
)
}
else
{
daemonPodsRunning
=
append
(
daemonPodsRunning
,
daemon
)
}
}
// If daemon pod is supposed to be running on node, but more than 1 daemon pod is running, delete the excess daemon pods.
// Sort the daemon pods by creation time, so the the oldest is preserved.
sort
.
Sort
(
podByCreationTimestamp
(
daemonPods
))
for
i
:=
1
;
i
<
len
(
daemonPods
);
i
++
{
podsToDelete
=
append
(
podsToDelete
,
daemonPods
[
i
]
.
Name
)
// Sort the daemon pods by creation time, so the oldest is preserved.
if
len
(
daemonPodsRunning
)
>
1
{
sort
.
Sort
(
podByCreationTimestamp
(
daemonPodsRunning
))
for
i
:=
1
;
i
<
len
(
daemonPodsRunning
);
i
++
{
podsToDelete
=
append
(
podsToDelete
,
daemonPods
[
i
]
.
Name
)
}
}
case
!
shouldContinueRunning
&&
isRunning
:
case
!
shouldContinueRunning
&&
exists
:
// If daemon pod isn't supposed to run on node, but it is, delete all daemon pods on node.
for
i
:=
range
daemonPods
{
podsToDelete
=
append
(
podsToDelete
,
daemonPods
[
i
]
.
Name
)
...
...
test/e2e/daemon_set.go
View file @
a2e1341e
This diff is collapsed.
Click to expand it.
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