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
715ea4c8
Commit
715ea4c8
authored
Feb 10, 2016
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
e2e: checking RSS memory for daemons
parent
c70c7fde
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
14 deletions
+78
-14
kubelet_perf.go
test/e2e/kubelet_perf.go
+42
-4
kubelet_stats.go
test/e2e/kubelet_stats.go
+36
-10
No files found.
test/e2e/kubelet_perf.go
View file @
715ea4c8
...
@@ -95,15 +95,53 @@ func runResourceTrackingTest(framework *Framework, podsPerNode int, nodeNames se
...
@@ -95,15 +95,53 @@ func runResourceTrackingTest(framework *Framework, podsPerNode int, nodeNames se
By
(
"Reporting overall resource usage"
)
By
(
"Reporting overall resource usage"
)
logPodsOnNodes
(
framework
.
Client
,
nodeNames
.
List
())
logPodsOnNodes
(
framework
.
Client
,
nodeNames
.
List
())
rm
.
LogLatest
()
rm
.
LogLatest
()
usageSummary
,
err
:=
rm
.
GetLatest
()
summary
:=
rm
.
GetCPUSummary
()
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Logf
(
"%s"
,
rm
.
FormatCPUSummary
(
summary
))
Logf
(
"%s"
,
rm
.
FormatResourceUsage
(
usageSummary
))
verifyCPULimits
(
expected
,
summary
)
// TODO(yujuhong): Set realistic values after gathering enough data.
verifyMemoryLimits
(
resourceUsagePerContainer
{
"/kubelet"
:
&
containerResourceUsage
{
MemoryRSSInBytes
:
500
*
1024
*
1024
},
"/docker-daemon"
:
&
containerResourceUsage
{
MemoryRSSInBytes
:
500
*
1024
*
1024
},
},
usageSummary
)
cpuSummary
:=
rm
.
GetCPUSummary
()
Logf
(
"%s"
,
rm
.
FormatCPUSummary
(
cpuSummary
))
verifyCPULimits
(
expected
,
cpuSummary
)
By
(
"Deleting the RC"
)
By
(
"Deleting the RC"
)
DeleteRC
(
framework
.
Client
,
framework
.
Namespace
.
Name
,
rcName
)
DeleteRC
(
framework
.
Client
,
framework
.
Namespace
.
Name
,
rcName
)
}
}
func
verifyMemoryLimits
(
expected
resourceUsagePerContainer
,
actual
resourceUsagePerNode
)
{
if
expected
==
nil
{
return
}
var
errList
[]
string
for
nodeName
,
nodeSummary
:=
range
actual
{
var
nodeErrs
[]
string
for
cName
,
expectedResult
:=
range
expected
{
container
,
ok
:=
nodeSummary
[
cName
]
if
!
ok
{
nodeErrs
=
append
(
nodeErrs
,
fmt
.
Sprintf
(
"container %q: missing"
,
cName
))
continue
}
expectedValue
:=
expectedResult
.
MemoryRSSInBytes
actualValue
:=
container
.
MemoryRSSInBytes
if
expectedValue
!=
0
&&
actualValue
>
expectedValue
{
nodeErrs
=
append
(
nodeErrs
,
fmt
.
Sprintf
(
"container %q: expected RSS memory (MB) < %d; got %d"
,
cName
,
expectedValue
,
actualValue
))
}
}
if
len
(
nodeErrs
)
>
0
{
errList
=
append
(
errList
,
fmt
.
Sprintf
(
"node %v:
\n
%s"
,
nodeName
,
strings
.
Join
(
nodeErrs
,
", "
)))
}
}
if
len
(
errList
)
>
0
{
Failf
(
"CPU usage exceeding limits:
\n
%s"
,
strings
.
Join
(
errList
,
"
\n
"
))
}
}
func
verifyCPULimits
(
expected
containersCPUSummary
,
actual
nodesCPUSummary
)
{
func
verifyCPULimits
(
expected
containersCPUSummary
,
actual
nodesCPUSummary
)
{
if
expected
==
nil
{
if
expected
==
nil
{
return
return
...
...
test/e2e/kubelet_stats.go
View file @
715ea4c8
...
@@ -36,6 +36,7 @@ import (
...
@@ -36,6 +36,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/metrics"
"k8s.io/kubernetes/pkg/kubelet/metrics"
"k8s.io/kubernetes/pkg/kubelet/server/stats"
"k8s.io/kubernetes/pkg/kubelet/server/stats"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/master/ports"
utilerrors
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
)
)
...
@@ -198,6 +199,7 @@ type containerResourceUsage struct {
...
@@ -198,6 +199,7 @@ type containerResourceUsage struct {
CPUUsageInCores
float64
CPUUsageInCores
float64
MemoryUsageInBytes
int64
MemoryUsageInBytes
int64
MemoryWorkingSetInBytes
int64
MemoryWorkingSetInBytes
int64
MemoryRSSInBytes
uint64
// The interval used to calculate CPUUsageInCores.
// The interval used to calculate CPUUsageInCores.
CPUInterval
time
.
Duration
CPUInterval
time
.
Duration
}
}
...
@@ -207,6 +209,7 @@ func (r *containerResourceUsage) isStrictlyGreaterThan(rhs *containerResourceUsa
...
@@ -207,6 +209,7 @@ func (r *containerResourceUsage) isStrictlyGreaterThan(rhs *containerResourceUsa
}
}
type
resourceUsagePerContainer
map
[
string
]
*
containerResourceUsage
type
resourceUsagePerContainer
map
[
string
]
*
containerResourceUsage
type
resourceUsagePerNode
map
[
string
]
resourceUsagePerContainer
// getOneTimeResourceUsageOnNode queries the node's /stats/container endpoint
// getOneTimeResourceUsageOnNode queries the node's /stats/container endpoint
// and returns the resource usage of all containerNames for the past
// and returns the resource usage of all containerNames for the past
...
@@ -292,9 +295,9 @@ func formatResourceUsageStats(nodeName string, containerStats resourceUsagePerCo
...
@@ -292,9 +295,9 @@ func formatResourceUsageStats(nodeName string, containerStats resourceUsagePerCo
// "/system" 0.007 119.88
// "/system" 0.007 119.88
buf
:=
&
bytes
.
Buffer
{}
buf
:=
&
bytes
.
Buffer
{}
w
:=
tabwriter
.
NewWriter
(
buf
,
1
,
0
,
1
,
' '
,
0
)
w
:=
tabwriter
.
NewWriter
(
buf
,
1
,
0
,
1
,
' '
,
0
)
fmt
.
Fprintf
(
w
,
"container
\t
cpu(cores)
\t
memory(MB)
\n
"
)
fmt
.
Fprintf
(
w
,
"container
\t
cpu(cores)
\t
memory
_working_set(MB)
\t
memory_rss
(MB)
\n
"
)
for
name
,
s
:=
range
containerStats
{
for
name
,
s
:=
range
containerStats
{
fmt
.
Fprintf
(
w
,
"%q
\t
%.3f
\t
%.2f
\
n
"
,
name
,
s
.
CPUUsageInCores
,
float64
(
s
.
MemoryWorkingSet
InBytes
)
/
(
1024
*
1024
))
fmt
.
Fprintf
(
w
,
"%q
\t
%.3f
\t
%.2f
\
t
%.2f
\n
"
,
name
,
s
.
CPUUsageInCores
,
float64
(
s
.
MemoryWorkingSetInBytes
)
/
(
1024
*
1024
),
float64
(
s
.
MemoryRSS
InBytes
)
/
(
1024
*
1024
))
}
}
w
.
Flush
()
w
.
Flush
()
return
fmt
.
Sprintf
(
"Resource usage on node %q:
\n
%s"
,
nodeName
,
buf
.
String
())
return
fmt
.
Sprintf
(
"Resource usage on node %q:
\n
%s"
,
nodeName
,
buf
.
String
())
...
@@ -364,6 +367,7 @@ func computeContainerResourceUsage(name string, oldStats, newStats *cadvisorapi.
...
@@ -364,6 +367,7 @@ func computeContainerResourceUsage(name string, oldStats, newStats *cadvisorapi.
CPUUsageInCores
:
float64
(
newStats
.
Cpu
.
Usage
.
Total
-
oldStats
.
Cpu
.
Usage
.
Total
)
/
float64
(
newStats
.
Timestamp
.
Sub
(
oldStats
.
Timestamp
)
.
Nanoseconds
()),
CPUUsageInCores
:
float64
(
newStats
.
Cpu
.
Usage
.
Total
-
oldStats
.
Cpu
.
Usage
.
Total
)
/
float64
(
newStats
.
Timestamp
.
Sub
(
oldStats
.
Timestamp
)
.
Nanoseconds
()),
MemoryUsageInBytes
:
int64
(
newStats
.
Memory
.
Usage
),
MemoryUsageInBytes
:
int64
(
newStats
.
Memory
.
Usage
),
MemoryWorkingSetInBytes
:
int64
(
newStats
.
Memory
.
WorkingSet
),
MemoryWorkingSetInBytes
:
int64
(
newStats
.
Memory
.
WorkingSet
),
MemoryRSSInBytes
:
newStats
.
Memory
.
RSS
,
CPUInterval
:
newStats
.
Timestamp
.
Sub
(
oldStats
.
Timestamp
),
CPUInterval
:
newStats
.
Timestamp
.
Sub
(
oldStats
.
Timestamp
),
}
}
}
}
...
@@ -437,20 +441,18 @@ func (r *resourceCollector) collectStats(oldStats map[string]*cadvisorapi.Contai
...
@@ -437,20 +441,18 @@ func (r *resourceCollector) collectStats(oldStats map[string]*cadvisorapi.Contai
}
}
}
}
// LogLatest logs the latest resource usage of each container.
func
(
r
*
resourceCollector
)
GetLatest
()
(
resourceUsagePerContainer
,
error
)
{
func
(
r
*
resourceCollector
)
LogLatest
()
{
r
.
lock
.
RLock
()
r
.
lock
.
RLock
()
defer
r
.
lock
.
RUnlock
()
defer
r
.
lock
.
RUnlock
()
stats
:=
make
(
map
[
string
]
*
containerResourceUsage
)
stats
:=
make
(
resourceUsagePerContainer
)
for
_
,
name
:=
range
r
.
containers
{
for
_
,
name
:=
range
r
.
containers
{
contStats
,
ok
:=
r
.
buffers
[
name
]
contStats
,
ok
:=
r
.
buffers
[
name
]
if
!
ok
||
len
(
contStats
)
==
0
{
if
!
ok
||
len
(
contStats
)
==
0
{
Logf
(
"Resource usage on node %q is not ready yet"
,
r
.
node
)
return
nil
,
fmt
.
Errorf
(
"Resource usage on node %q is not ready yet"
,
r
.
node
)
return
}
}
stats
[
name
]
=
contStats
[
len
(
contStats
)
-
1
]
stats
[
name
]
=
contStats
[
len
(
contStats
)
-
1
]
}
}
Logf
(
"
\n
%s"
,
formatResourceUsageStats
(
r
.
node
,
stats
))
return
stats
,
nil
}
}
// Reset frees the stats and start over.
// Reset frees the stats and start over.
...
@@ -534,9 +536,33 @@ func (r *resourceMonitor) Reset() {
...
@@ -534,9 +536,33 @@ func (r *resourceMonitor) Reset() {
}
}
func
(
r
*
resourceMonitor
)
LogLatest
()
{
func
(
r
*
resourceMonitor
)
LogLatest
()
{
for
_
,
collector
:=
range
r
.
collectors
{
summary
,
err
:=
r
.
GetLatest
()
collector
.
LogLatest
()
if
err
!=
nil
{
Logf
(
"%v"
,
err
)
}
r
.
FormatResourceUsage
(
summary
)
}
func
(
r
*
resourceMonitor
)
FormatResourceUsage
(
s
resourceUsagePerNode
)
string
{
summary
:=
[]
string
{}
for
node
,
usage
:=
range
s
{
summary
=
append
(
summary
,
formatResourceUsageStats
(
node
,
usage
))
}
return
strings
.
Join
(
summary
,
"
\n
"
)
}
func
(
r
*
resourceMonitor
)
GetLatest
()
(
resourceUsagePerNode
,
error
)
{
result
:=
make
(
resourceUsagePerNode
)
errs
:=
[]
error
{}
for
key
,
collector
:=
range
r
.
collectors
{
s
,
err
:=
collector
.
GetLatest
()
if
err
!=
nil
{
errs
=
append
(
errs
,
err
)
continue
}
result
[
key
]
=
s
}
}
return
result
,
utilerrors
.
NewAggregate
(
errs
)
}
}
// containersCPUSummary is indexed by the container name with each entry a
// containersCPUSummary is indexed by the container name with each entry a
...
...
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