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
fb3a1d68
Commit
fb3a1d68
authored
Jan 05, 2017
by
Michael Fraenkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid panic when stopping the podKiller
use a mutex instead of a channel
parent
e18f54f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
18 deletions
+20
-18
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+20
-18
No files found.
pkg/kubelet/kubelet_pods.go
View file @
fb3a1d68
...
...
@@ -29,6 +29,7 @@ import (
"runtime"
"sort"
"strings"
"sync"
"time"
"github.com/golang/glog"
...
...
@@ -799,8 +800,8 @@ func (kl *Kubelet) HandlePodCleanups() error {
// another goroutine isn't already in action.
func
(
kl
*
Kubelet
)
podKiller
()
{
killing
:=
sets
.
NewString
()
resultCh
:=
make
(
chan
types
.
UID
)
defer
close
(
resultCh
)
// guard for the killing set
lock
:=
sync
.
Mutex
{}
for
{
select
{
case
podPair
,
ok
:=
<-
kl
.
podKillingCh
:
...
...
@@ -811,24 +812,25 @@ func (kl *Kubelet) podKiller() {
runningPod
:=
podPair
.
RunningPod
apiPod
:=
podPair
.
APIPod
if
killing
.
Has
(
string
(
runningPod
.
ID
))
{
// The pod is already being killed.
break
lock
.
Lock
()
exists
:=
killing
.
Has
(
string
(
runningPod
.
ID
))
if
!
exists
{
killing
.
Insert
(
string
(
runningPod
.
ID
))
}
killing
.
Insert
(
string
(
runningPod
.
ID
))
go
func
(
apiPod
*
v1
.
Pod
,
runningPod
*
kubecontainer
.
Pod
,
ch
chan
types
.
UID
)
{
defer
func
()
{
ch
<-
runningPod
.
ID
}()
glog
.
V
(
2
)
.
Infof
(
"Killing unwanted pod %q"
,
runningPod
.
Name
)
err
:=
kl
.
killPod
(
apiPod
,
runningPod
,
nil
,
nil
)
if
err
!=
nil
{
glog
.
Errorf
(
"Failed killing the pod %q: %v"
,
runningPod
.
Name
,
err
)
}
}(
apiPod
,
runningPod
,
resultCh
)
lock
.
Unlock
()
case
podID
:=
<-
resultCh
:
killing
.
Delete
(
string
(
podID
))
if
!
exists
{
go
func
(
apiPod
*
v1
.
Pod
,
runningPod
*
kubecontainer
.
Pod
)
{
glog
.
V
(
2
)
.
Infof
(
"Killing unwanted pod %q"
,
runningPod
.
Name
)
err
:=
kl
.
killPod
(
apiPod
,
runningPod
,
nil
,
nil
)
if
err
!=
nil
{
glog
.
Errorf
(
"Failed killing the pod %q: %v"
,
runningPod
.
Name
,
err
)
}
lock
.
Lock
()
killing
.
Delete
(
string
(
runningPod
.
ID
))
lock
.
Unlock
()
}(
apiPod
,
runningPod
)
}
}
}
}
...
...
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