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
081b2168
Commit
081b2168
authored
Nov 16, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16261 from zhengguoyong/update_condition
Auto commit by PR queue bot
parents
96ae38c0
3f630d8a
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 @
081b2168
...
...
@@ -2833,7 +2833,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"
,
""
)
...
...
@@ -2849,6 +2849,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
))
...
...
@@ -2910,7 +2916,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 @
081b2168
...
...
@@ -1933,16 +1933,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
,
""
,
""
),
},
{
...
...
@@ -1952,6 +1955,7 @@ func TestGetPodReadyCondition(t *testing.T) {
},
},
containerStatuses
:
[]
api
.
ContainerStatus
{},
podPhase
:
api
.
PodRunning
,
expected
:
getReadyCondition
(
api
.
ConditionFalse
,
"ContainersNotReady"
,
"containers with unknown status: [1234]"
),
},
{
...
...
@@ -1965,6 +1969,7 @@ func TestGetPodReadyCondition(t *testing.T) {
getReadyStatus
(
"1234"
),
getReadyStatus
(
"5678"
),
},
podPhase
:
api
.
PodRunning
,
expected
:
getReadyCondition
(
api
.
ConditionTrue
,
""
,
""
),
},
{
...
...
@@ -1977,6 +1982,7 @@ func TestGetPodReadyCondition(t *testing.T) {
containerStatuses
:
[]
api
.
ContainerStatus
{
getReadyStatus
(
"1234"
),
},
podPhase
:
api
.
PodRunning
,
expected
:
getReadyCondition
(
api
.
ConditionFalse
,
"ContainersNotReady"
,
"containers with unknown status: [5678]"
),
},
{
...
...
@@ -1990,12 +1996,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