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
de064f42
Commit
de064f42
authored
Aug 30, 2015
by
James DeFelice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix kubelet syncLoop busy loop upon close of updates chan
parent
c28b68d2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
+28
-5
kubelet.go
pkg/kubelet/kubelet.go
+8
-5
kubelet_test.go
pkg/kubelet/kubelet_test.go
+20
-0
No files found.
pkg/kubelet/kubelet.go
View file @
de064f42
...
@@ -1896,17 +1896,19 @@ func (kl *Kubelet) syncLoop(updates <-chan PodUpdate, handler SyncHandler) {
...
@@ -1896,17 +1896,19 @@ func (kl *Kubelet) syncLoop(updates <-chan PodUpdate, handler SyncHandler) {
}
}
housekeepingTimestamp
=
time
.
Now
()
housekeepingTimestamp
=
time
.
Now
()
}
}
kl
.
syncLoopIteration
(
updates
,
handler
)
if
!
kl
.
syncLoopIteration
(
updates
,
handler
)
{
break
}
}
}
}
}
func
(
kl
*
Kubelet
)
syncLoopIteration
(
updates
<-
chan
PodUpdate
,
handler
SyncHandler
)
{
func
(
kl
*
Kubelet
)
syncLoopIteration
(
updates
<-
chan
PodUpdate
,
handler
SyncHandler
)
bool
{
kl
.
syncLoopMonitor
.
Store
(
time
.
Now
())
kl
.
syncLoopMonitor
.
Store
(
time
.
Now
())
select
{
select
{
case
u
,
o
k
:=
<-
updates
:
case
u
,
o
pen
:=
<-
updates
:
if
!
o
k
{
if
!
o
pen
{
glog
.
Errorf
(
"Update channel is closed. Exiting the sync loop."
)
glog
.
Errorf
(
"Update channel is closed. Exiting the sync loop."
)
return
return
false
}
}
switch
u
.
Op
{
switch
u
.
Op
{
case
ADD
:
case
ADD
:
...
@@ -1928,6 +1930,7 @@ func (kl *Kubelet) syncLoopIteration(updates <-chan PodUpdate, handler SyncHandl
...
@@ -1928,6 +1930,7 @@ func (kl *Kubelet) syncLoopIteration(updates <-chan PodUpdate, handler SyncHandl
handler
.
HandlePodSyncs
(
kl
.
podManager
.
GetPods
())
handler
.
HandlePodSyncs
(
kl
.
podManager
.
GetPods
())
}
}
kl
.
syncLoopMonitor
.
Store
(
time
.
Now
())
kl
.
syncLoopMonitor
.
Store
(
time
.
Now
())
return
true
}
}
func
(
kl
*
Kubelet
)
dispatchWork
(
pod
*
api
.
Pod
,
syncType
SyncPodType
,
mirrorPod
*
api
.
Pod
,
start
time
.
Time
)
{
func
(
kl
*
Kubelet
)
dispatchWork
(
pod
*
api
.
Pod
,
syncType
SyncPodType
,
mirrorPod
*
api
.
Pod
,
start
time
.
Time
)
{
...
...
pkg/kubelet/kubelet_test.go
View file @
de064f42
...
@@ -329,6 +329,26 @@ func TestSyncLoopTimeUpdate(t *testing.T) {
...
@@ -329,6 +329,26 @@ func TestSyncLoopTimeUpdate(t *testing.T) {
}
}
}
}
func
TestSyncLoopAbort
(
t
*
testing
.
T
)
{
testKubelet
:=
newTestKubelet
(
t
)
testKubelet
.
fakeCadvisor
.
On
(
"MachineInfo"
)
.
Return
(
&
cadvisorApi
.
MachineInfo
{},
nil
)
kubelet
:=
testKubelet
.
kubelet
kubelet
.
lastTimestampRuntimeUp
=
time
.
Now
()
kubelet
.
networkConfigured
=
true
ch
:=
make
(
chan
PodUpdate
)
close
(
ch
)
// sanity check (also prevent this test from hanging in the next step)
ok
:=
kubelet
.
syncLoopIteration
(
ch
,
kubelet
)
if
ok
{
t
.
Fatalf
(
"expected syncLoopIteration to return !ok since update chan was closed"
)
}
// this should terminate immediately; if it hangs then the syncLoopIteration isn't aborting properly
kubelet
.
syncLoop
(
ch
,
kubelet
)
}
func
TestSyncPodsStartPod
(
t
*
testing
.
T
)
{
func
TestSyncPodsStartPod
(
t
*
testing
.
T
)
{
testKubelet
:=
newTestKubelet
(
t
)
testKubelet
:=
newTestKubelet
(
t
)
testKubelet
.
fakeCadvisor
.
On
(
"MachineInfo"
)
.
Return
(
&
cadvisorApi
.
MachineInfo
{},
nil
)
testKubelet
.
fakeCadvisor
.
On
(
"MachineInfo"
)
.
Return
(
&
cadvisorApi
.
MachineInfo
{},
nil
)
...
...
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