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
44eade9b
Commit
44eade9b
authored
Sep 29, 2016
by
ymqytw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide more detailed error message when pod fails to be success state
parent
cfb833e8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
util.go
test/e2e/framework/util.go
+7
-5
No files found.
test/e2e/framework/util.go
View file @
44eade9b
...
@@ -507,8 +507,8 @@ func logPodStates(pods []api.Pod) {
...
@@ -507,8 +507,8 @@ func logPodStates(pods []api.Pod) {
}
}
// errorBadPodsStates create error message of basic info of bad pods for debugging.
// errorBadPodsStates create error message of basic info of bad pods for debugging.
func
errorBadPodsStates
(
badPods
[]
api
.
Pod
,
desiredPods
int
,
ns
string
,
timeout
time
.
Duration
)
string
{
func
errorBadPodsStates
(
badPods
[]
api
.
Pod
,
desiredPods
int
,
ns
,
desiredState
string
,
timeout
time
.
Duration
)
string
{
errStr
:=
fmt
.
Sprintf
(
"%d / %d pods in namespace %q are NOT in
the desired state in %v
\n
"
,
len
(
badPods
),
desiredPods
,
ns
,
timeout
)
errStr
:=
fmt
.
Sprintf
(
"%d / %d pods in namespace %q are NOT in
%s state in %v
\n
"
,
len
(
badPods
),
desiredPods
,
ns
,
desiredState
,
timeout
)
// Pirnt bad pods info only if there are fewer than 10 bad pods
// Pirnt bad pods info only if there are fewer than 10 bad pods
if
len
(
badPods
)
>
10
{
if
len
(
badPods
)
>
10
{
return
errStr
+
"There are too many bad pods. Please check log for details."
return
errStr
+
"There are too many bad pods. Please check log for details."
...
@@ -580,7 +580,7 @@ func hasReplicationControllersForPod(rcs *api.ReplicationControllerList, pod api
...
@@ -580,7 +580,7 @@ func hasReplicationControllersForPod(rcs *api.ReplicationControllerList, pod api
// pods have been created.
// pods have been created.
func
WaitForPodsSuccess
(
c
*
client
.
Client
,
ns
string
,
successPodLabels
map
[
string
]
string
,
timeout
time
.
Duration
)
error
{
func
WaitForPodsSuccess
(
c
*
client
.
Client
,
ns
string
,
successPodLabels
map
[
string
]
string
,
timeout
time
.
Duration
)
error
{
successPodSelector
:=
labels
.
SelectorFromSet
(
successPodLabels
)
successPodSelector
:=
labels
.
SelectorFromSet
(
successPodLabels
)
start
,
badPods
:=
time
.
Now
(),
[]
api
.
Pod
{}
start
,
badPods
,
desiredPods
:=
time
.
Now
(),
[]
api
.
Pod
{},
0
if
wait
.
PollImmediate
(
30
*
time
.
Second
,
timeout
,
func
()
(
bool
,
error
)
{
if
wait
.
PollImmediate
(
30
*
time
.
Second
,
timeout
,
func
()
(
bool
,
error
)
{
podList
,
err
:=
c
.
Pods
(
ns
)
.
List
(
api
.
ListOptions
{
LabelSelector
:
successPodSelector
})
podList
,
err
:=
c
.
Pods
(
ns
)
.
List
(
api
.
ListOptions
{
LabelSelector
:
successPodSelector
})
...
@@ -593,6 +593,7 @@ func WaitForPodsSuccess(c *client.Client, ns string, successPodLabels map[string
...
@@ -593,6 +593,7 @@ func WaitForPodsSuccess(c *client.Client, ns string, successPodLabels map[string
return
true
,
nil
return
true
,
nil
}
}
badPods
=
[]
api
.
Pod
{}
badPods
=
[]
api
.
Pod
{}
desiredPods
=
len
(
podList
.
Items
)
for
_
,
pod
:=
range
podList
.
Items
{
for
_
,
pod
:=
range
podList
.
Items
{
if
pod
.
Status
.
Phase
!=
api
.
PodSucceeded
{
if
pod
.
Status
.
Phase
!=
api
.
PodSucceeded
{
badPods
=
append
(
badPods
,
pod
)
badPods
=
append
(
badPods
,
pod
)
...
@@ -608,7 +609,8 @@ func WaitForPodsSuccess(c *client.Client, ns string, successPodLabels map[string
...
@@ -608,7 +609,8 @@ func WaitForPodsSuccess(c *client.Client, ns string, successPodLabels map[string
})
!=
nil
{
})
!=
nil
{
logPodStates
(
badPods
)
logPodStates
(
badPods
)
LogPodsWithLabels
(
c
,
ns
,
successPodLabels
)
LogPodsWithLabels
(
c
,
ns
,
successPodLabels
)
return
fmt
.
Errorf
(
"Not all pods in namespace %q are successful within %v"
,
ns
,
timeout
)
return
errors
.
New
(
errorBadPodsStates
(
badPods
,
desiredPods
,
ns
,
"SUCCESS"
,
timeout
))
}
}
return
nil
return
nil
}
}
...
@@ -695,7 +697,7 @@ func WaitForPodsRunningReady(c *client.Client, ns string, minPods int32, timeout
...
@@ -695,7 +697,7 @@ func WaitForPodsRunningReady(c *client.Client, ns string, minPods int32, timeout
logPodStates
(
badPods
)
logPodStates
(
badPods
)
return
false
,
nil
return
false
,
nil
})
!=
nil
{
})
!=
nil
{
return
errors
.
New
(
errorBadPodsStates
(
badPods
,
desiredPods
,
ns
,
timeout
))
return
errors
.
New
(
errorBadPodsStates
(
badPods
,
desiredPods
,
ns
,
"RUNNING and READY"
,
timeout
))
}
}
wg
.
Wait
()
wg
.
Wait
()
if
waitForSuccessError
!=
nil
{
if
waitForSuccessError
!=
nil
{
...
...
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