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
6d0b8ea7
Commit
6d0b8ea7
authored
Feb 05, 2015
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a regression where we never cleared out failed nodes.
parent
5de2e916
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
1 deletion
+41
-1
replication_controller.go
pkg/controller/replication_controller.go
+2
-1
pod_cache.go
pkg/master/pod_cache.go
+10
-0
pod_cache_test.go
pkg/master/pod_cache_test.go
+29
-0
No files found.
pkg/controller/replication_controller.go
View file @
6d0b8ea7
...
@@ -166,7 +166,8 @@ func FilterActivePods(pods []api.Pod) []api.Pod {
...
@@ -166,7 +166,8 @@ func FilterActivePods(pods []api.Pod) []api.Pod {
var
result
[]
api
.
Pod
var
result
[]
api
.
Pod
for
_
,
value
:=
range
pods
{
for
_
,
value
:=
range
pods
{
if
api
.
PodSucceeded
!=
value
.
Status
.
Phase
&&
if
api
.
PodSucceeded
!=
value
.
Status
.
Phase
&&
api
.
PodFailed
!=
value
.
Status
.
Phase
{
api
.
PodFailed
!=
value
.
Status
.
Phase
&&
api
.
PodUnknown
!=
value
.
Status
.
Phase
{
result
=
append
(
result
,
value
)
result
=
append
(
result
,
value
)
}
}
}
}
...
...
pkg/master/pod_cache.go
View file @
6d0b8ea7
...
@@ -135,6 +135,12 @@ func (p *PodCache) getNodeStatus(name string) (*api.NodeStatus, error) {
...
@@ -135,6 +135,12 @@ func (p *PodCache) getNodeStatus(name string) (*api.NodeStatus, error) {
return
&
node
.
Status
,
nil
return
&
node
.
Status
,
nil
}
}
func
(
p
*
PodCache
)
clearNodeStatus
()
{
p
.
lock
.
Lock
()
defer
p
.
lock
.
Unlock
()
p
.
currentNodes
=
map
[
objKey
]
api
.
NodeStatus
{}
}
// TODO: once Host gets moved to spec, this can take a podSpec + metadata instead of an
// TODO: once Host gets moved to spec, this can take a podSpec + metadata instead of an
// entire pod?
// entire pod?
func
(
p
*
PodCache
)
updatePodStatus
(
pod
*
api
.
Pod
)
error
{
func
(
p
*
PodCache
)
updatePodStatus
(
pod
*
api
.
Pod
)
error
{
...
@@ -221,6 +227,10 @@ func (p *PodCache) GarbageCollectPodStatus() {
...
@@ -221,6 +227,10 @@ func (p *PodCache) GarbageCollectPodStatus() {
// calling again, or risk having new info getting clobbered by delayed
// calling again, or risk having new info getting clobbered by delayed
// old info.
// old info.
func
(
p
*
PodCache
)
UpdateAllContainers
()
{
func
(
p
*
PodCache
)
UpdateAllContainers
()
{
// TODO: this is silly, we should pro-actively update the pod status when
// the API server makes changes.
p
.
clearNodeStatus
()
ctx
:=
api
.
NewContext
()
ctx
:=
api
.
NewContext
()
pods
,
err
:=
p
.
pods
.
ListPods
(
ctx
,
labels
.
Everything
())
pods
,
err
:=
p
.
pods
.
ListPods
(
ctx
,
labels
.
Everything
())
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/master/pod_cache_test.go
View file @
6d0b8ea7
...
@@ -254,6 +254,35 @@ func makeUnhealthyNode(name string) *api.Node {
...
@@ -254,6 +254,35 @@ func makeUnhealthyNode(name string) *api.Node {
}
}
}
}
func
TestPodUpdateAllContainersClearsNodeStatus
(
t
*
testing
.
T
)
{
node
:=
makeHealthyNode
(
"machine"
,
"1.2.3.5"
)
pod1
:=
makePod
(
api
.
NamespaceDefault
,
"foo"
,
"machine"
,
"bar"
)
pod2
:=
makePod
(
api
.
NamespaceDefault
,
"baz"
,
"machine"
,
"qux"
)
config
:=
podCacheTestConfig
{
kubeletContainerInfo
:
api
.
PodStatus
{
Info
:
api
.
PodInfo
{
"bar"
:
api
.
ContainerStatus
{}}},
nodes
:
[]
api
.
Node
{
*
node
},
pods
:
[]
api
.
Pod
{
*
pod1
,
*
pod2
},
}
cache
:=
config
.
Construct
()
if
len
(
cache
.
currentNodes
)
!=
0
{
t
.
Errorf
(
"unexpected node cache: %v"
,
cache
.
currentNodes
)
}
key
:=
objKey
{
""
,
"machine"
}
cache
.
currentNodes
[
key
]
=
makeUnhealthyNode
(
"machine"
)
.
Status
cache
.
UpdateAllContainers
()
if
len
(
cache
.
currentNodes
)
!=
1
{
t
.
Errorf
(
"unexpected empty node cache: %v"
,
cache
.
currentNodes
)
}
if
!
reflect
.
DeepEqual
(
cache
.
currentNodes
[
key
],
node
.
Status
)
{
t
.
Errorf
(
"unexpected status:
\n
%#v
\n
expected:
\n
%#v
\n
"
,
cache
.
currentNodes
[
key
],
node
.
Status
)
}
}
func
TestPodUpdateAllContainers
(
t
*
testing
.
T
)
{
func
TestPodUpdateAllContainers
(
t
*
testing
.
T
)
{
pod1
:=
makePod
(
api
.
NamespaceDefault
,
"foo"
,
"machine"
,
"bar"
)
pod1
:=
makePod
(
api
.
NamespaceDefault
,
"foo"
,
"machine"
,
"bar"
)
pod2
:=
makePod
(
api
.
NamespaceDefault
,
"baz"
,
"machine"
,
"qux"
)
pod2
:=
makePod
(
api
.
NamespaceDefault
,
"baz"
,
"machine"
,
"qux"
)
...
...
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