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
9d9e588c
Commit
9d9e588c
authored
Apr 19, 2018
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
e2e: save raw profiles too
parent
bbfa2992
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
17 deletions
+24
-17
profile_gatherer.go
test/e2e/framework/profile_gatherer.go
+24
-17
No files found.
test/e2e/framework/profile_gatherer.go
View file @
9d9e588c
...
@@ -19,7 +19,6 @@ package framework
...
@@ -19,7 +19,6 @@ package framework
import
(
import
(
"bytes"
"bytes"
"fmt"
"fmt"
"io/ioutil"
"os"
"os"
"os/exec"
"os/exec"
"path"
"path"
...
@@ -69,36 +68,44 @@ func gatherProfileOfKind(profileBaseName, kind string) error {
...
@@ -69,36 +68,44 @@ func gatherProfileOfKind(profileBaseName, kind string) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to execute curl command on master through SSH: %v"
,
err
)
return
fmt
.
Errorf
(
"Failed to execute curl command on master through SSH: %v"
,
err
)
}
}
// Write the data to a temp file.
var
tmpfile
*
os
.
File
var
profilePrefix
string
tmpfile
,
err
=
ioutil
.
TempFile
(
""
,
"apiserver-profile"
)
switch
{
case
kind
==
"heap"
:
profilePrefix
=
"ApiserverMemoryProfile_"
case
strings
.
HasPrefix
(
kind
,
"profile"
)
:
profilePrefix
=
"ApiserverCPUProfile_"
default
:
return
fmt
.
Errorf
(
"Unknown profile kind provided: %s"
,
kind
)
}
// Write the data to a file.
rawprofilePath
:=
path
.
Join
(
getProfilesDirectoryPath
(),
profilePrefix
+
profileBaseName
+
".pprof"
)
rawprofile
,
err
:=
os
.
Create
(
rawprofilePath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to create
temp file for profile data
: %v"
,
err
)
return
fmt
.
Errorf
(
"Failed to create
file for the profile graph
: %v"
,
err
)
}
}
defer
os
.
Remove
(
tmpfile
.
Name
())
defer
rawprofile
.
Close
()
if
_
,
err
:=
tmpfile
.
Write
([]
byte
(
sshResult
.
Stdout
));
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to write temp file with profile data: %v"
,
err
)
if
_
,
err
:=
rawprofile
.
Write
([]
byte
(
sshResult
.
Stdout
));
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to write file with profile data: %v"
,
err
)
}
}
if
err
:=
tmp
file
.
Close
();
err
!=
nil
{
if
err
:=
rawpro
file
.
Close
();
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to close
temp
file: %v"
,
err
)
return
fmt
.
Errorf
(
"Failed to close file: %v"
,
err
)
}
}
// Create a graph from the data and write it to a pdf file.
// Create a graph from the data and write it to a pdf file.
var
cmd
*
exec
.
Cmd
var
cmd
*
exec
.
Cmd
var
profilePrefix
string
switch
{
switch
{
// TODO: Support other profile kinds if needed (e.g inuse_space, alloc_objects, mutex, etc)
// TODO: Support other profile kinds if needed (e.g inuse_space, alloc_objects, mutex, etc)
case
kind
==
"heap"
:
case
kind
==
"heap"
:
cmd
=
exec
.
Command
(
"go"
,
"tool"
,
"pprof"
,
"-pdf"
,
"-symbolize=none"
,
"--alloc_space"
,
tmpfile
.
Name
())
cmd
=
exec
.
Command
(
"go"
,
"tool"
,
"pprof"
,
"-pdf"
,
"-symbolize=none"
,
"--alloc_space"
,
rawprofile
.
Name
())
profilePrefix
=
"ApiserverMemoryProfile_"
case
strings
.
HasPrefix
(
kind
,
"profile"
)
:
case
strings
.
HasPrefix
(
kind
,
"profile"
)
:
cmd
=
exec
.
Command
(
"go"
,
"tool"
,
"pprof"
,
"-pdf"
,
"-symbolize=none"
,
tmpfile
.
Name
())
cmd
=
exec
.
Command
(
"go"
,
"tool"
,
"pprof"
,
"-pdf"
,
"-symbolize=none"
,
rawprofile
.
Name
())
profilePrefix
=
"ApiserverCPUProfile_"
default
:
default
:
return
fmt
.
Errorf
(
"Unknown profile kind provided: %s"
,
kind
)
return
fmt
.
Errorf
(
"Unknown profile kind provided: %s"
,
kind
)
}
}
outfilePath
:=
path
.
Join
(
getProfilesDirectoryPath
(),
profilePrefix
+
profileBaseName
+
".pdf"
)
outfilePath
:=
path
.
Join
(
getProfilesDirectoryPath
(),
profilePrefix
+
profileBaseName
+
".pdf"
)
var
outfile
*
os
.
File
outfile
,
err
:=
os
.
Create
(
outfilePath
)
outfile
,
err
=
os
.
Create
(
outfilePath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to create file for the profile graph: %v"
,
err
)
return
fmt
.
Errorf
(
"Failed to create file for the profile graph: %v"
,
err
)
}
}
...
...
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