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
f8dff6bd
Commit
f8dff6bd
authored
May 10, 2019
by
David Ashpole
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only collect metrics for cgroups required by the summary API
parent
21bec91e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
8 deletions
+80
-8
server.go
cmd/kubelet/app/server.go
+26
-1
cadvisor_linux.go
pkg/kubelet/cadvisor/cadvisor_linux.go
+2
-4
cadvisor_unsupported.go
pkg/kubelet/cadvisor/cadvisor_unsupported.go
+1
-1
cadvisor_windows.go
pkg/kubelet/cadvisor/cadvisor_windows.go
+1
-1
helpers_linux.go
pkg/kubelet/cm/helpers_linux.go
+34
-0
helpers_unsupported.go
pkg/kubelet/cm/helpers_unsupported.go
+15
-0
conformance.go
test/e2e_node/environment/conformance.go
+1
-1
No files found.
cmd/kubelet/app/server.go
View file @
f8dff6bd
...
@@ -616,9 +616,34 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, stopCh <-chan
...
@@ -616,9 +616,34 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, stopCh <-chan
kubeDeps
.
Auth
=
auth
kubeDeps
.
Auth
=
auth
}
}
var
cgroupRoots
[]
string
cgroupRoots
=
append
(
cgroupRoots
,
cm
.
NodeAllocatableRoot
(
s
.
CgroupRoot
,
s
.
CgroupDriver
))
kubeletCgroup
,
err
:=
cm
.
GetKubeletContainer
(
s
.
KubeletCgroups
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to get the kubelet's cgroup: %v"
,
err
)
}
if
kubeletCgroup
!=
""
{
cgroupRoots
=
append
(
cgroupRoots
,
kubeletCgroup
)
}
runtimeCgroup
,
err
:=
cm
.
GetRuntimeContainer
(
s
.
ContainerRuntime
,
s
.
RuntimeCgroups
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to get the container runtime's cgroup: %v"
,
err
)
}
if
runtimeCgroup
!=
""
{
// RuntimeCgroups is optional, so ignore if it isn't specified
cgroupRoots
=
append
(
cgroupRoots
,
runtimeCgroup
)
}
if
s
.
SystemCgroups
!=
""
{
// SystemCgroups is optional, so ignore if it isn't specified
cgroupRoots
=
append
(
cgroupRoots
,
s
.
SystemCgroups
)
}
if
kubeDeps
.
CAdvisorInterface
==
nil
{
if
kubeDeps
.
CAdvisorInterface
==
nil
{
imageFsInfoProvider
:=
cadvisor
.
NewImageFsInfoProvider
(
s
.
ContainerRuntime
,
s
.
RemoteRuntimeEndpoint
)
imageFsInfoProvider
:=
cadvisor
.
NewImageFsInfoProvider
(
s
.
ContainerRuntime
,
s
.
RemoteRuntimeEndpoint
)
kubeDeps
.
CAdvisorInterface
,
err
=
cadvisor
.
New
(
imageFsInfoProvider
,
s
.
RootDirectory
,
cadvisor
.
UsingLegacyCadvisorStats
(
s
.
ContainerRuntime
,
s
.
RemoteRuntimeEndpoint
))
kubeDeps
.
CAdvisorInterface
,
err
=
cadvisor
.
New
(
imageFsInfoProvider
,
s
.
RootDirectory
,
c
groupRoots
,
c
advisor
.
UsingLegacyCadvisorStats
(
s
.
ContainerRuntime
,
s
.
RemoteRuntimeEndpoint
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubelet/cadvisor/cadvisor_linux.go
View file @
f8dff6bd
...
@@ -82,7 +82,7 @@ func init() {
...
@@ -82,7 +82,7 @@ func init() {
}
}
}
}
func
New
(
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
,
usingLegacyStats
bool
)
(
Interface
,
error
)
{
func
New
(
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
,
cgroupRoots
[]
string
,
usingLegacyStats
bool
)
(
Interface
,
error
)
{
sysFs
:=
sysfs
.
NewRealSysFs
()
sysFs
:=
sysfs
.
NewRealSysFs
()
includedMetrics
:=
cadvisormetrics
.
MetricSet
{
includedMetrics
:=
cadvisormetrics
.
MetricSet
{
...
@@ -98,10 +98,8 @@ func New(imageFsInfoProvider ImageFsInfoProvider, rootPath string, usingLegacySt
...
@@ -98,10 +98,8 @@ func New(imageFsInfoProvider ImageFsInfoProvider, rootPath string, usingLegacySt
includedMetrics
[
cadvisormetrics
.
DiskUsageMetrics
]
=
struct
{}{}
includedMetrics
[
cadvisormetrics
.
DiskUsageMetrics
]
=
struct
{}{}
}
}
// collect metrics for all cgroups
rawContainerCgroupPathPrefixWhiteList
:=
[]
string
{
"/"
}
// Create and start the cAdvisor container manager.
// Create and start the cAdvisor container manager.
m
,
err
:=
manager
.
New
(
memory
.
New
(
statsCacheDuration
,
nil
),
sysFs
,
maxHousekeepingInterval
,
allowDynamicHousekeeping
,
includedMetrics
,
http
.
DefaultClient
,
rawContainerCgroupPathPrefixWhiteList
)
m
,
err
:=
manager
.
New
(
memory
.
New
(
statsCacheDuration
,
nil
),
sysFs
,
maxHousekeepingInterval
,
allowDynamicHousekeeping
,
includedMetrics
,
http
.
DefaultClient
,
cgroupRoots
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/kubelet/cadvisor/cadvisor_unsupported.go
View file @
f8dff6bd
...
@@ -31,7 +31,7 @@ type cadvisorUnsupported struct {
...
@@ -31,7 +31,7 @@ type cadvisorUnsupported struct {
var
_
Interface
=
new
(
cadvisorUnsupported
)
var
_
Interface
=
new
(
cadvisorUnsupported
)
func
New
(
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
,
usingLegacyStats
bool
)
(
Interface
,
error
)
{
func
New
(
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
,
cgroupsRoots
[]
string
,
usingLegacyStats
bool
)
(
Interface
,
error
)
{
return
&
cadvisorUnsupported
{},
nil
return
&
cadvisorUnsupported
{},
nil
}
}
...
...
pkg/kubelet/cadvisor/cadvisor_windows.go
View file @
f8dff6bd
...
@@ -33,7 +33,7 @@ type cadvisorClient struct {
...
@@ -33,7 +33,7 @@ type cadvisorClient struct {
var
_
Interface
=
new
(
cadvisorClient
)
var
_
Interface
=
new
(
cadvisorClient
)
// New creates a cAdvisor and exports its API on the specified port if port > 0.
// New creates a cAdvisor and exports its API on the specified port if port > 0.
func
New
(
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
,
usingLegacyStats
bool
)
(
Interface
,
error
)
{
func
New
(
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
,
cgroupRoots
[]
string
,
usingLegacyStats
bool
)
(
Interface
,
error
)
{
client
,
err
:=
winstats
.
NewPerfCounterClient
()
client
,
err
:=
winstats
.
NewPerfCounterClient
()
return
&
cadvisorClient
{
return
&
cadvisorClient
{
rootPath
:
rootPath
,
rootPath
:
rootPath
,
...
...
pkg/kubelet/cm/helpers_linux.go
View file @
f8dff6bd
...
@@ -236,3 +236,37 @@ func getCgroupProcs(dir string) ([]int, error) {
...
@@ -236,3 +236,37 @@ func getCgroupProcs(dir string) ([]int, error) {
func
GetPodCgroupNameSuffix
(
podUID
types
.
UID
)
string
{
func
GetPodCgroupNameSuffix
(
podUID
types
.
UID
)
string
{
return
podCgroupNamePrefix
+
string
(
podUID
)
return
podCgroupNamePrefix
+
string
(
podUID
)
}
}
// NodeAllocatableRoot returns the literal cgroup path for the node allocatable cgroup
func
NodeAllocatableRoot
(
cgroupRoot
,
cgroupDriver
string
)
string
{
root
:=
ParseCgroupfsToCgroupName
(
cgroupRoot
)
nodeAllocatableRoot
:=
NewCgroupName
(
root
,
defaultNodeAllocatableCgroupName
)
if
libcontainerCgroupManagerType
(
cgroupDriver
)
==
libcontainerSystemd
{
return
nodeAllocatableRoot
.
ToSystemd
()
}
return
nodeAllocatableRoot
.
ToCgroupfs
()
}
// GetKubeletContainer returns the cgroup the kubelet will use
func
GetKubeletContainer
(
kubeletCgroups
string
)
(
string
,
error
)
{
if
kubeletCgroups
==
""
{
cont
,
err
:=
getContainer
(
os
.
Getpid
())
if
err
!=
nil
{
return
""
,
err
}
return
cont
,
nil
}
return
kubeletCgroups
,
nil
}
// GetRuntimeContainer returns the cgroup used by the container runtime
func
GetRuntimeContainer
(
containerRuntime
,
runtimeCgroups
string
)
(
string
,
error
)
{
if
containerRuntime
==
"docker"
{
cont
,
err
:=
getContainerNameForProcess
(
dockerProcessName
,
dockerPidFile
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to get container name for docker process: %v"
,
err
)
}
return
cont
,
nil
}
return
runtimeCgroups
,
nil
}
pkg/kubelet/cm/helpers_unsupported.go
View file @
f8dff6bd
...
@@ -59,3 +59,18 @@ func getCgroupProcs(dir string) ([]int, error) {
...
@@ -59,3 +59,18 @@ func getCgroupProcs(dir string) ([]int, error) {
func
GetPodCgroupNameSuffix
(
podUID
types
.
UID
)
string
{
func
GetPodCgroupNameSuffix
(
podUID
types
.
UID
)
string
{
return
""
return
""
}
}
// NodeAllocatableRoot returns the literal cgroup path for the node allocatable cgroup
func
NodeAllocatableRoot
(
cgroupRoot
,
cgroupDriver
string
)
string
{
return
""
}
// GetKubeletContainer returns the cgroup the kubelet will use
func
GetKubeletContainer
(
kubeletCgroups
string
)
(
string
,
error
)
{
return
""
,
nil
}
// GetRuntimeContainer returns the cgroup used by the container runtime
func
GetRuntimeContainer
(
containerRuntime
,
runtimeCgroups
string
)
(
string
,
error
)
{
return
""
,
nil
}
test/e2e_node/environment/conformance.go
View file @
f8dff6bd
...
@@ -99,7 +99,7 @@ func containerRuntime() error {
...
@@ -99,7 +99,7 @@ func containerRuntime() error {
}
}
// Setup cadvisor to check the container environment
// Setup cadvisor to check the container environment
c
,
err
:=
cadvisor
.
New
(
cadvisor
.
NewImageFsInfoProvider
(
"docker"
,
""
),
"/var/lib/kubelet"
,
false
)
c
,
err
:=
cadvisor
.
New
(
cadvisor
.
NewImageFsInfoProvider
(
"docker"
,
""
),
"/var/lib/kubelet"
,
[]
string
{
"/"
},
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
printError
(
"Container Runtime Check: %s Could not start cadvisor %v"
,
failed
,
err
)
return
printError
(
"Container Runtime Check: %s Could not start cadvisor %v"
,
failed
,
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