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
3f630d8a
Commit
3f630d8a
authored
Oct 26, 2015
by
eulerzgy
Committed by
zhengguoyong
Nov 10, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
when pod has successed, update condition to PodCompleted
parent
c3898970
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
kubelet.go
pkg/kubelet/kubelet.go
+8
-2
kubelet_test.go
pkg/kubelet/kubelet_test.go
+20
-1
No files found.
pkg/kubelet/kubelet.go
View file @
3f630d8a
...
...
@@ -2657,7 +2657,7 @@ func readyPodCondition(isPodReady bool, reason, message string) []api.PodConditi
}
// getPodReadyCondition returns ready condition if all containers in a pod are ready, else it returns an unready condition.
func
getPodReadyCondition
(
spec
*
api
.
PodSpec
,
containerStatuses
[]
api
.
ContainerStatus
)
[]
api
.
PodCondition
{
func
getPodReadyCondition
(
spec
*
api
.
PodSpec
,
containerStatuses
[]
api
.
ContainerStatus
,
podPhase
api
.
PodPhase
)
[]
api
.
PodCondition
{
// Find if all containers are ready or not.
if
containerStatuses
==
nil
{
return
readyPodCondition
(
false
,
"UnknownContainerStatuses"
,
""
)
...
...
@@ -2673,6 +2673,12 @@ func getPodReadyCondition(spec *api.PodSpec, containerStatuses []api.ContainerSt
unknownContainers
=
append
(
unknownContainers
,
container
.
Name
)
}
}
// In case of unexist unknowContainers, If pod has derminated successed and it has unreadyContainers, just return PodCompleted
if
podPhase
==
api
.
PodSucceeded
&&
len
(
unknownContainers
)
==
0
{
return
readyPodCondition
(
false
,
fmt
.
Sprint
(
"PodCompleted"
),
""
)
}
unreadyMessages
:=
[]
string
{}
if
len
(
unknownContainers
)
>
0
{
unreadyMessages
=
append
(
unreadyMessages
,
fmt
.
Sprintf
(
"containers with unknown status: %s"
,
unknownContainers
))
...
...
@@ -2734,7 +2740,7 @@ func (kl *Kubelet) generatePodStatus(pod *api.Pod) (api.PodStatus, error) {
podStatus
.
Phase
=
GetPhase
(
spec
,
podStatus
.
ContainerStatuses
)
kl
.
probeManager
.
UpdatePodStatus
(
pod
.
UID
,
podStatus
)
podStatus
.
Conditions
=
append
(
podStatus
.
Conditions
,
getPodReadyCondition
(
spec
,
podStatus
.
ContainerStatuses
)
...
)
podStatus
.
Conditions
=
append
(
podStatus
.
Conditions
,
getPodReadyCondition
(
spec
,
podStatus
.
ContainerStatuses
,
podStatus
.
Phase
)
...
)
if
!
kl
.
standaloneMode
{
hostIP
,
err
:=
kl
.
GetHostIP
()
...
...
pkg/kubelet/kubelet_test.go
View file @
3f630d8a
...
...
@@ -1875,16 +1875,19 @@ func TestGetPodReadyCondition(t *testing.T) {
tests
:=
[]
struct
{
spec
*
api
.
PodSpec
containerStatuses
[]
api
.
ContainerStatus
podPhase
api
.
PodPhase
expected
[]
api
.
PodCondition
}{
{
spec
:
nil
,
containerStatuses
:
nil
,
podPhase
:
api
.
PodRunning
,
expected
:
getReadyCondition
(
api
.
ConditionFalse
,
"UnknownContainerStatuses"
,
""
),
},
{
spec
:
&
api
.
PodSpec
{},
containerStatuses
:
[]
api
.
ContainerStatus
{},
podPhase
:
api
.
PodRunning
,
expected
:
getReadyCondition
(
api
.
ConditionTrue
,
""
,
""
),
},
{
...
...
@@ -1894,6 +1897,7 @@ func TestGetPodReadyCondition(t *testing.T) {
},
},
containerStatuses
:
[]
api
.
ContainerStatus
{},
podPhase
:
api
.
PodRunning
,
expected
:
getReadyCondition
(
api
.
ConditionFalse
,
"ContainersNotReady"
,
"containers with unknown status: [1234]"
),
},
{
...
...
@@ -1907,6 +1911,7 @@ func TestGetPodReadyCondition(t *testing.T) {
getReadyStatus
(
"1234"
),
getReadyStatus
(
"5678"
),
},
podPhase
:
api
.
PodRunning
,
expected
:
getReadyCondition
(
api
.
ConditionTrue
,
""
,
""
),
},
{
...
...
@@ -1919,6 +1924,7 @@ func TestGetPodReadyCondition(t *testing.T) {
containerStatuses
:
[]
api
.
ContainerStatus
{
getReadyStatus
(
"1234"
),
},
podPhase
:
api
.
PodRunning
,
expected
:
getReadyCondition
(
api
.
ConditionFalse
,
"ContainersNotReady"
,
"containers with unknown status: [5678]"
),
},
{
...
...
@@ -1932,12 +1938,25 @@ func TestGetPodReadyCondition(t *testing.T) {
getReadyStatus
(
"1234"
),
getNotReadyStatus
(
"5678"
),
},
podPhase
:
api
.
PodRunning
,
expected
:
getReadyCondition
(
api
.
ConditionFalse
,
"ContainersNotReady"
,
"containers with unready status: [5678]"
),
},
{
spec
:
&
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Name
:
"1234"
},
},
},
containerStatuses
:
[]
api
.
ContainerStatus
{
getNotReadyStatus
(
"1234"
),
},
podPhase
:
api
.
PodSucceeded
,
expected
:
getReadyCondition
(
api
.
ConditionFalse
,
"PodCompleted"
,
""
),
},
}
for
i
,
test
:=
range
tests
{
condition
:=
getPodReadyCondition
(
test
.
spec
,
test
.
containerStatuses
)
condition
:=
getPodReadyCondition
(
test
.
spec
,
test
.
containerStatuses
,
test
.
podPhase
)
if
!
reflect
.
DeepEqual
(
condition
,
test
.
expected
)
{
t
.
Errorf
(
"On test case %v, expected:
\n
%+v
\n
got
\n
%+v
\n
"
,
i
,
test
.
expected
,
condition
)
}
...
...
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