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
2bc12a2a
Commit
2bc12a2a
authored
Jan 28, 2016
by
Fabio Yeon
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20248 from yujuhong/more_logs
e2e reboot: prints stats and logs for not ready pods before and after the test
parents
11a16988
4975e5d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
20 deletions
+24
-20
reboot.go
test/e2e/reboot.go
+24
-20
No files found.
test/e2e/reboot.go
View file @
2bc12a2a
...
...
@@ -25,6 +25,7 @@ import (
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util/sets"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
...
...
@@ -157,7 +158,7 @@ func testReboot(c *client.Client, rebootCmd string) {
}
}
func
printStatusAndLogsForNotReadyPods
(
c
*
client
.
Client
,
oldPods
,
newP
ods
[]
*
api
.
Pod
)
{
func
printStatusAndLogsForNotReadyPods
(
c
*
client
.
Client
,
ns
string
,
podNames
[]
string
,
p
ods
[]
*
api
.
Pod
)
{
printFn
:=
func
(
id
,
log
string
,
err
error
,
previous
bool
)
{
prefix
:=
"Retrieving log for container"
if
previous
{
...
...
@@ -169,25 +170,27 @@ func printStatusAndLogsForNotReadyPods(c *client.Client, oldPods, newPods []*api
Logf
(
"%s %s:
\n
%s
\n
"
,
prefix
,
id
,
log
)
}
}
for
_
,
oldPod
:=
range
oldPods
{
for
_
,
p
:=
range
newPods
{
if
p
.
Namespace
!=
oldPod
.
Namespace
||
p
.
Name
!=
oldPod
.
Name
{
continue
}
if
ok
,
_
:=
podRunningReady
(
p
);
!
ok
{
Logf
(
"Status for not ready pod %s/%s: %+v"
,
p
.
Namespace
,
p
.
Name
,
p
.
Status
)
// Print the log of the containers if pod is not running and ready.
for
_
,
container
:=
range
p
.
Status
.
ContainerStatuses
{
cIdentifer
:=
fmt
.
Sprintf
(
"%s/%s/%s"
,
p
.
Namespace
,
p
.
Name
,
container
.
Name
)
log
,
err
:=
getPodLogs
(
c
,
p
.
Namespace
,
p
.
Name
,
container
.
Name
)
printFn
(
cIdentifer
,
log
,
err
,
false
)
// Get log from the previous container.
if
container
.
RestartCount
>
0
{
printFn
(
cIdentifer
,
log
,
err
,
true
)
}
}
podNameSet
:=
sets
.
NewString
(
podNames
...
)
for
_
,
p
:=
range
pods
{
if
p
.
Namespace
!=
ns
{
continue
}
if
!
podNameSet
.
Has
(
p
.
Name
)
{
continue
}
if
ok
,
_
:=
podRunningReady
(
p
);
ok
{
continue
}
Logf
(
"Status for not ready pod %s/%s: %+v"
,
p
.
Namespace
,
p
.
Name
,
p
.
Status
)
// Print the log of the containers if pod is not running and ready.
for
_
,
container
:=
range
p
.
Status
.
ContainerStatuses
{
cIdentifer
:=
fmt
.
Sprintf
(
"%s/%s/%s"
,
p
.
Namespace
,
p
.
Name
,
container
.
Name
)
log
,
err
:=
getPodLogs
(
c
,
p
.
Namespace
,
p
.
Name
,
container
.
Name
)
printFn
(
cIdentifer
,
log
,
err
,
false
)
// Get log from the previous container.
if
container
.
RestartCount
>
0
{
printFn
(
cIdentifer
,
log
,
err
,
true
)
}
break
}
}
}
...
...
@@ -242,6 +245,7 @@ func rebootNode(c *client.Client, provider, name, rebootCmd string) bool {
// For each pod, we do a sanity check to ensure it's running / healthy
// now, as that's what we'll be checking later.
if
!
checkPodsRunningReady
(
c
,
ns
,
podNames
,
podReadyBeforeTimeout
)
{
printStatusAndLogsForNotReadyPods
(
c
,
ns
,
podNames
,
pods
)
return
false
}
...
...
@@ -265,7 +269,7 @@ func rebootNode(c *client.Client, provider, name, rebootCmd string) bool {
// running / healthy.
if
!
checkPodsRunningReady
(
c
,
ns
,
podNames
,
rebootPodReadyAgainTimeout
)
{
newPods
:=
ps
.
List
()
printStatusAndLogsForNotReadyPods
(
c
,
pod
s
,
newPods
)
printStatusAndLogsForNotReadyPods
(
c
,
ns
,
podName
s
,
newPods
)
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