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
32bc46a2
Commit
32bc46a2
authored
Nov 03, 2016
by
Kubernetes Submit Queue
Committed by
GitHub
Nov 03, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #36181 from yujuhong/get_logs
Automatic merge from submit-queue Node e2e: collect logs if the test fails unexpectedly
parents
05a08399
97a34806
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletion
+29
-1
remote.go
test/e2e_node/remote/remote.go
+29
-1
No files found.
test/e2e_node/remote/remote.go
View file @
32bc46a2
...
@@ -167,7 +167,9 @@ func RunRemote(archive string, host string, cleanup bool, junitFilePrefix string
...
@@ -167,7 +167,9 @@ func RunRemote(archive string, host string, cleanup bool, junitFilePrefix string
// Create the temp staging directory
// Create the temp staging directory
glog
.
Infof
(
"Staging test binaries on %s"
,
host
)
glog
.
Infof
(
"Staging test binaries on %s"
,
host
)
tmp
:=
fmt
.
Sprintf
(
"/tmp/gcloud-e2e-%d"
,
rand
.
Int31
())
dirName
:=
fmt
.
Sprintf
(
"gcloud-e2e-%d"
,
rand
.
Int31
())
tmp
:=
fmt
.
Sprintf
(
"/tmp/%s"
,
dirName
)
_
,
err
:=
RunSshCommand
(
"ssh"
,
GetHostnameOrIp
(
host
),
"--"
,
"mkdir"
,
tmp
)
_
,
err
:=
RunSshCommand
(
"ssh"
,
GetHostnameOrIp
(
host
),
"--"
,
"mkdir"
,
tmp
)
if
err
!=
nil
{
if
err
!=
nil
{
// Exit failure with the error
// Exit failure with the error
...
@@ -291,6 +293,32 @@ func RunRemote(archive string, host string, cleanup bool, junitFilePrefix string
...
@@ -291,6 +293,32 @@ func RunRemote(archive string, host string, cleanup bool, junitFilePrefix string
aggErrs
=
append
(
aggErrs
,
err
)
aggErrs
=
append
(
aggErrs
,
err
)
}
}
if
err
!=
nil
{
// Encountered an unexpected error. The remote test harness may not
// have finished retrieved and stored all the logs in this case. Try
// to get some logs for debugging purposes.
// TODO: This is a best-effort, temporary hack that only works for
// journald nodes. We should have a more robust way to collect logs.
var
(
logName
=
fmt
.
Sprintf
(
"%s-system.log"
,
dirName
)
logPath
=
fmt
.
Sprintf
(
"/tmp/%s-system.log"
,
dirName
)
destPath
=
fmt
.
Sprintf
(
"%s/%s-%s"
,
*
resultsDir
,
host
,
logName
)
)
glog
.
Infof
(
"Test failed unexpectedly. Attempting to retreiving system logs (only works for nodes with journald)"
)
// Try getting the system logs from journald and store it to a file.
// Don't reuse the original test directory on the remote host because
// it could've be been removed if the node was rebooted.
_
,
err
:=
RunSshCommand
(
"ssh"
,
GetHostnameOrIp
(
host
),
"--"
,
"sh"
,
"-c"
,
fmt
.
Sprintf
(
"'sudo journalctl --system --all > %s'"
,
logPath
))
if
err
==
nil
{
glog
.
Infof
(
"Got the system logs from journald; copying it back..."
)
if
_
,
err
:=
RunSshCommand
(
"scp"
,
fmt
.
Sprintf
(
"%s:%s"
,
GetHostnameOrIp
(
host
),
logPath
),
destPath
);
err
!=
nil
{
glog
.
Infof
(
"Failed to copy the log: err: %v"
,
err
)
}
}
else
{
glog
.
Infof
(
"Failed to run journactl (normal if it doesn't exist on the node): %v"
,
err
)
}
}
glog
.
Infof
(
"Copying test artifacts from %s"
,
host
)
glog
.
Infof
(
"Copying test artifacts from %s"
,
host
)
scpErr
:=
getTestArtifacts
(
host
,
tmp
)
scpErr
:=
getTestArtifacts
(
host
,
tmp
)
if
scpErr
!=
nil
{
if
scpErr
!=
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