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
65b59474
Commit
65b59474
authored
Sep 19, 2017
by
tanshanshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix-todo
parent
00c1ec52
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
28 deletions
+17
-28
util.go
test/e2e/framework/util.go
+1
-1
conditions.go
test/utils/conditions.go
+16
-27
No files found.
test/e2e/framework/util.go
View file @
65b59474
...
...
@@ -824,7 +824,7 @@ func WaitForPodCondition(c clientset.Interface, ns, podName, desc string, timeou
}
// log now so that current pod info is reported before calling `condition()`
Logf
(
"Pod %q: Phase=%q, Reason=%q, readiness=%t. Elapsed: %v"
,
podName
,
pod
.
Status
.
Phase
,
pod
.
Status
.
Reason
,
testutil
.
PodReady
(
pod
),
time
.
Since
(
start
))
podName
,
pod
.
Status
.
Phase
,
pod
.
Status
.
Reason
,
podutil
.
Is
PodReady
(
pod
),
time
.
Since
(
start
))
if
done
,
err
:=
condition
(
pod
);
done
{
if
err
==
nil
{
Logf
(
"Pod %q satisfied condition %q"
,
podName
,
desc
)
...
...
test/utils/conditions.go
View file @
65b59474
...
...
@@ -20,6 +20,7 @@ import (
"fmt"
"k8s.io/api/core/v1"
podutil
"k8s.io/kubernetes/pkg/api/v1/pod"
)
type
ContainerFailures
struct
{
...
...
@@ -36,7 +37,7 @@ func PodRunningReady(p *v1.Pod) (bool, error) {
p
.
ObjectMeta
.
Name
,
p
.
Spec
.
NodeName
,
v1
.
PodRunning
,
p
.
Status
.
Phase
)
}
// Check the ready condition is true.
if
!
PodReady
(
p
)
{
if
!
podutil
.
Is
PodReady
(
p
)
{
return
false
,
fmt
.
Errorf
(
"pod '%s' on '%s' didn't have condition {%v %v}; conditions: %v"
,
p
.
ObjectMeta
.
Name
,
p
.
Spec
.
NodeName
,
v1
.
PodReady
,
v1
.
ConditionTrue
,
p
.
Status
.
Conditions
)
}
...
...
@@ -62,21 +63,20 @@ func FailedContainers(pod *v1.Pod) map[string]ContainerFailures {
statuses
:=
pod
.
Status
.
ContainerStatuses
if
len
(
statuses
)
==
0
{
return
nil
}
else
{
for
_
,
status
:=
range
statuses
{
if
status
.
State
.
Terminated
!=
nil
{
states
[
status
.
ContainerID
]
=
ContainerFailures
{
status
:
status
.
State
.
Terminated
}
}
else
if
status
.
LastTerminationState
.
Terminated
!=
nil
{
states
[
status
.
ContainerID
]
=
ContainerFailures
{
status
:
status
.
LastTerminationState
.
Terminated
}
}
if
status
.
RestartCount
>
0
{
var
ok
bool
if
state
,
ok
=
states
[
status
.
ContainerID
];
!
ok
{
state
=
ContainerFailures
{}
}
state
.
Restarts
=
int
(
status
.
RestartCount
)
states
[
status
.
ContainerID
]
=
state
}
for
_
,
status
:=
range
statuses
{
if
status
.
State
.
Terminated
!=
nil
{
states
[
status
.
ContainerID
]
=
ContainerFailures
{
status
:
status
.
State
.
Terminated
}
}
else
if
status
.
LastTerminationState
.
Terminated
!=
nil
{
states
[
status
.
ContainerID
]
=
ContainerFailures
{
status
:
status
.
LastTerminationState
.
Terminated
}
}
if
status
.
RestartCount
>
0
{
var
ok
bool
if
state
,
ok
=
states
[
status
.
ContainerID
];
!
ok
{
state
=
ContainerFailures
{}
}
state
.
Restarts
=
int
(
status
.
RestartCount
)
states
[
status
.
ContainerID
]
=
state
}
}
...
...
@@ -103,20 +103,9 @@ func TerminatedContainers(pod *v1.Pod) map[string]string {
// PodNotReady checks whether pod p's has a ready condition of status false.
func
PodNotReady
(
p
*
v1
.
Pod
)
(
bool
,
error
)
{
// Check the ready condition is false.
if
PodReady
(
p
)
{
if
podutil
.
Is
PodReady
(
p
)
{
return
false
,
fmt
.
Errorf
(
"pod '%s' on '%s' didn't have condition {%v %v}; conditions: %v"
,
p
.
ObjectMeta
.
Name
,
p
.
Spec
.
NodeName
,
v1
.
PodReady
,
v1
.
ConditionFalse
,
p
.
Status
.
Conditions
)
}
return
true
,
nil
}
// podReady returns whether pod has a condition of Ready with a status of true.
// TODO: should be replaced with podutil.IsPodReady
func
PodReady
(
pod
*
v1
.
Pod
)
bool
{
for
_
,
cond
:=
range
pod
.
Status
.
Conditions
{
if
cond
.
Type
==
v1
.
PodReady
&&
cond
.
Status
==
v1
.
ConditionTrue
{
return
true
}
}
return
false
}
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