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
c0c7ffb7
Commit
c0c7ffb7
authored
Jan 12, 2015
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3355 from saad-ali/fix2495
Fix "Kubelet doesn't kill old pods when BoundPods is empty" issue
parents
969c4b8c
e1917cf9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
6 deletions
+25
-6
etcd.go
pkg/kubelet/config/etcd.go
+13
-1
etcd_test.go
pkg/kubelet/config/etcd_test.go
+1
-1
file.go
pkg/kubelet/config/file.go
+2
-0
file_test.go
pkg/kubelet/config/file_test.go
+7
-1
http.go
pkg/kubelet/config/http.go
+2
-0
kubelet.go
pkg/kubelet/kubelet.go
+0
-3
No files found.
pkg/kubelet/config/etcd.go
View file @
c0c7ffb7
...
...
@@ -59,7 +59,16 @@ func NewSourceEtcd(key string, client tools.EtcdClient, updates chan<- interface
}
func
(
s
*
sourceEtcd
)
run
()
{
watching
:=
s
.
helper
.
Watch
(
s
.
key
,
0
)
boundPods
:=
api
.
BoundPods
{}
err
:=
s
.
helper
.
ExtractToList
(
s
.
key
,
&
boundPods
)
if
err
!=
nil
{
glog
.
Errorf
(
"etcd failed to retrieve the value for the key %q. Error: %v"
,
s
.
key
,
err
)
return
}
// Push update. Maybe an empty PodList to allow EtcdSource to be marked as seen
s
.
updates
<-
kubelet
.
PodUpdate
{
boundPods
.
Items
,
kubelet
.
SET
,
kubelet
.
EtcdSource
}
index
,
_
:=
s
.
helper
.
ResourceVersioner
.
ResourceVersion
(
&
boundPods
)
watching
:=
s
.
helper
.
Watch
(
s
.
key
,
index
)
for
{
select
{
case
event
,
ok
:=
<-
watching
.
ResultChan
()
:
...
...
@@ -87,6 +96,9 @@ func (s *sourceEtcd) run() {
// It returns a list of containers, or an error if one occurs.
func
eventToPods
(
ev
watch
.
Event
)
([]
api
.
BoundPod
,
error
)
{
pods
:=
[]
api
.
BoundPod
{}
if
ev
.
Object
==
nil
{
return
pods
,
nil
}
boundPods
,
ok
:=
ev
.
Object
.
(
*
api
.
BoundPods
)
if
!
ok
{
return
pods
,
errors
.
New
(
"unable to parse response as BoundPods"
)
...
...
pkg/kubelet/config/etcd_test.go
View file @
c0c7ffb7
...
...
@@ -33,7 +33,7 @@ func TestEventToPods(t *testing.T) {
{
input
:
watch
.
Event
{
Object
:
nil
},
pods
:
[]
api
.
BoundPod
{},
fail
:
tru
e
,
fail
:
fals
e
,
},
{
input
:
watch
.
Event
{
Object
:
&
api
.
BoundPods
{}},
...
...
pkg/kubelet/config/file.go
View file @
c0c7ffb7
...
...
@@ -64,6 +64,8 @@ func (s *sourceFile) extractFromPath() error {
if
!
os
.
IsNotExist
(
err
)
{
return
err
}
// Emit an update with an empty PodList to allow FileSource to be marked as seen
s
.
updates
<-
kubelet
.
PodUpdate
{[]
api
.
BoundPod
{},
kubelet
.
SET
,
kubelet
.
FileSource
}
return
fmt
.
Errorf
(
"path does not exist, ignoring"
)
}
...
...
pkg/kubelet/config/file_test.go
View file @
c0c7ffb7
...
...
@@ -92,8 +92,14 @@ func TestUpdateOnNonExistentFile(t *testing.T) {
NewSourceFile
(
"random_non_existent_path"
,
time
.
Millisecond
,
ch
)
select
{
case
got
:=
<-
ch
:
t
.
Errorf
(
"Expected no update, Got %#v"
,
got
)
update
:=
got
.
(
kubelet
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
FileSource
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Fatalf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
}
case
<-
time
.
After
(
2
*
time
.
Millisecond
)
:
t
.
Errorf
(
"Expected update, timeout instead"
)
}
}
...
...
pkg/kubelet/config/http.go
View file @
c0c7ffb7
...
...
@@ -69,6 +69,8 @@ func (s *sourceURL) extractFromURL() error {
return
fmt
.
Errorf
(
"%v: %v"
,
s
.
url
,
resp
.
Status
)
}
if
len
(
data
)
==
0
{
// Emit an update with an empty PodList to allow HTTPSource to be marked as seen
s
.
updates
<-
kubelet
.
PodUpdate
{[]
api
.
BoundPod
{},
kubelet
.
SET
,
kubelet
.
HTTPSource
}
return
fmt
.
Errorf
(
"zero-length data received from %v"
,
s
.
url
)
}
// Short circuit if the manifest has not changed since the last time it was read.
...
...
pkg/kubelet/kubelet.go
View file @
c0c7ffb7
...
...
@@ -1118,9 +1118,6 @@ func (kl *Kubelet) syncLoop(updates <-chan PodUpdate, handler SyncHandler) {
}
case
<-
time
.
After
(
kl
.
resyncInterval
)
:
glog
.
V
(
4
)
.
Infof
(
"Periodic sync"
)
if
kl
.
pods
==
nil
{
continue
}
}
err
:=
handler
.
SyncPods
(
kl
.
pods
)
...
...
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