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
9d68ae59
Commit
9d68ae59
authored
May 26, 2017
by
zhengjiajin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix naming and comments in Container Manage
parent
d0dfd8c4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
16 deletions
+16
-16
cgroup_manager_linux.go
pkg/kubelet/cm/cgroup_manager_linux.go
+12
-12
container_manager.go
pkg/kubelet/cm/container_manager.go
+1
-1
container_manager_linux_test.go
pkg/kubelet/cm/container_manager_linux_test.go
+1
-1
pod_container_manager_linux.go
pkg/kubelet/cm/pod_container_manager_linux.go
+1
-1
types.go
pkg/kubelet/cm/types.go
+1
-1
No files found.
pkg/kubelet/cm/cgroup_manager_linux.go
View file @
9d68ae59
...
@@ -164,7 +164,7 @@ func (l *libcontainerAdapter) adaptName(cgroupName CgroupName, outputToCgroupFs
...
@@ -164,7 +164,7 @@ func (l *libcontainerAdapter) adaptName(cgroupName CgroupName, outputToCgroupFs
return
ConvertCgroupNameToSystemd
(
cgroupName
,
outputToCgroupFs
)
return
ConvertCgroupNameToSystemd
(
cgroupName
,
outputToCgroupFs
)
}
}
// CgroupSubsystems holds information about the mounted cgroup subsytems
// CgroupSubsystems holds information about the mounted cgroup subsy
s
tems
type
CgroupSubsystems
struct
{
type
CgroupSubsystems
struct
{
// Cgroup subsystem mounts.
// Cgroup subsystem mounts.
// e.g.: "/sys/fs/cgroup/cpu" -> ["cpu", "cpuacct"]
// e.g.: "/sys/fs/cgroup/cpu" -> ["cpu", "cpuacct"]
...
@@ -181,7 +181,7 @@ type CgroupSubsystems struct {
...
@@ -181,7 +181,7 @@ type CgroupSubsystems struct {
// It uses the Libcontainer raw fs cgroup manager for cgroup management.
// It uses the Libcontainer raw fs cgroup manager for cgroup management.
type
cgroupManagerImpl
struct
{
type
cgroupManagerImpl
struct
{
// subsystems holds information about all the
// subsystems holds information about all the
// mounted cgroup subsytems on the node
// mounted cgroup subsy
s
tems on the node
subsystems
*
CgroupSubsystems
subsystems
*
CgroupSubsystems
// simplifies interaction with libcontainer and its cgroup managers
// simplifies interaction with libcontainer and its cgroup managers
adapter
*
libcontainerAdapter
adapter
*
libcontainerAdapter
...
@@ -305,8 +305,8 @@ var supportedSubsystems = []subsystem{
...
@@ -305,8 +305,8 @@ var supportedSubsystems = []subsystem{
&
cgroupfs
.
CpuGroup
{},
&
cgroupfs
.
CpuGroup
{},
}
}
// setSupportedSubsytems sets cgroup resource limits only on the supported
// setSupportedSubsy
s
tems sets cgroup resource limits only on the supported
// subsytems. ie. cpu and memory. We don't use libcontainer's cgroup/fs/Set()
// subsy
s
tems. ie. cpu and memory. We don't use libcontainer's cgroup/fs/Set()
// method as it doesn't allow us to skip updates on the devices cgroup
// method as it doesn't allow us to skip updates on the devices cgroup
// Allowing or denying all devices by writing 'a' to devices.allow or devices.deny is
// Allowing or denying all devices by writing 'a' to devices.allow or devices.deny is
// not possible once the device cgroups has children. Once the pod level cgroup are
// not possible once the device cgroups has children. Once the pod level cgroup are
...
@@ -314,10 +314,10 @@ var supportedSubsystems = []subsystem{
...
@@ -314,10 +314,10 @@ var supportedSubsystems = []subsystem{
// We would like to skip setting any values on the device cgroup in this case
// We would like to skip setting any values on the device cgroup in this case
// but this is not possible with libcontainers Set() method
// but this is not possible with libcontainers Set() method
// See https://github.com/opencontainers/runc/issues/932
// See https://github.com/opencontainers/runc/issues/932
func
setSupportedSubsytems
(
cgroupConfig
*
libcontainerconfigs
.
Cgroup
)
error
{
func
setSupportedSubsy
s
tems
(
cgroupConfig
*
libcontainerconfigs
.
Cgroup
)
error
{
for
_
,
sys
:=
range
supportedSubsystems
{
for
_
,
sys
:=
range
supportedSubsystems
{
if
_
,
ok
:=
cgroupConfig
.
Paths
[
sys
.
Name
()];
!
ok
{
if
_
,
ok
:=
cgroupConfig
.
Paths
[
sys
.
Name
()];
!
ok
{
return
fmt
.
Errorf
(
"Failed to find subsy
tem mount for subsy
tem: %v"
,
sys
.
Name
())
return
fmt
.
Errorf
(
"Failed to find subsy
stem mount for subsys
tem: %v"
,
sys
.
Name
())
}
}
if
err
:=
sys
.
Set
(
cgroupConfig
.
Paths
[
sys
.
Name
()],
cgroupConfig
);
err
!=
nil
{
if
err
:=
sys
.
Set
(
cgroupConfig
.
Paths
[
sys
.
Name
()],
cgroupConfig
);
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to set config for supported subsystems : %v"
,
err
)
return
fmt
.
Errorf
(
"Failed to set config for supported subsystems : %v"
,
err
)
...
@@ -380,7 +380,7 @@ func (m *cgroupManagerImpl) Update(cgroupConfig *CgroupConfig) error {
...
@@ -380,7 +380,7 @@ func (m *cgroupManagerImpl) Update(cgroupConfig *CgroupConfig) error {
Paths
:
cgroupPaths
,
Paths
:
cgroupPaths
,
}
}
if
err
:=
setSupportedSubsytems
(
libcontainerCgroupConfig
);
err
!=
nil
{
if
err
:=
setSupportedSubsy
s
tems
(
libcontainerCgroupConfig
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to set supported cgroup subsystems for cgroup %v: %v"
,
cgroupConfig
.
Name
,
err
)
return
fmt
.
Errorf
(
"failed to set supported cgroup subsystems for cgroup %v: %v"
,
cgroupConfig
.
Name
,
err
)
}
}
return
nil
return
nil
...
@@ -422,7 +422,7 @@ func (m *cgroupManagerImpl) Create(cgroupConfig *CgroupConfig) error {
...
@@ -422,7 +422,7 @@ func (m *cgroupManagerImpl) Create(cgroupConfig *CgroupConfig) error {
// Apply(-1) is a hack to create the cgroup directories for each resource
// Apply(-1) is a hack to create the cgroup directories for each resource
// subsystem. The function [cgroups.Manager.apply()] applies cgroup
// subsystem. The function [cgroups.Manager.apply()] applies cgroup
// configuration to the process with the specified pid.
// configuration to the process with the specified pid.
// It creates cgroup files for each subsytems and writes the pid
// It creates cgroup files for each subsy
s
tems and writes the pid
// in the tasks file. We use the function to create all the required
// in the tasks file. We use the function to create all the required
// cgroup files but not attach any "real" pid to the cgroup.
// cgroup files but not attach any "real" pid to the cgroup.
if
err
:=
manager
.
Apply
(
-
1
);
err
!=
nil
{
if
err
:=
manager
.
Apply
(
-
1
);
err
!=
nil
{
...
@@ -436,7 +436,7 @@ func (m *cgroupManagerImpl) Create(cgroupConfig *CgroupConfig) error {
...
@@ -436,7 +436,7 @@ func (m *cgroupManagerImpl) Create(cgroupConfig *CgroupConfig) error {
return
nil
return
nil
}
}
// Scans through all subsytems to find pids associated with specified cgroup.
// Scans through all subsy
s
tems to find pids associated with specified cgroup.
func
(
m
*
cgroupManagerImpl
)
Pids
(
name
CgroupName
)
[]
int
{
func
(
m
*
cgroupManagerImpl
)
Pids
(
name
CgroupName
)
[]
int
{
// we need the driver specific name
// we need the driver specific name
cgroupFsName
:=
m
.
Name
(
name
)
cgroupFsName
:=
m
.
Name
(
name
)
...
@@ -500,11 +500,11 @@ func (m *cgroupManagerImpl) ReduceCPULimits(cgroupName CgroupName) error {
...
@@ -500,11 +500,11 @@ func (m *cgroupManagerImpl) ReduceCPULimits(cgroupName CgroupName) error {
return
m
.
Update
(
containerConfig
)
return
m
.
Update
(
containerConfig
)
}
}
func
getStatsSupportedSubsytems
(
cgroupPaths
map
[
string
]
string
)
(
*
libcontainercgroups
.
Stats
,
error
)
{
func
getStatsSupportedSubsy
s
tems
(
cgroupPaths
map
[
string
]
string
)
(
*
libcontainercgroups
.
Stats
,
error
)
{
stats
:=
libcontainercgroups
.
NewStats
()
stats
:=
libcontainercgroups
.
NewStats
()
for
_
,
sys
:=
range
supportedSubsystems
{
for
_
,
sys
:=
range
supportedSubsystems
{
if
_
,
ok
:=
cgroupPaths
[
sys
.
Name
()];
!
ok
{
if
_
,
ok
:=
cgroupPaths
[
sys
.
Name
()];
!
ok
{
return
nil
,
fmt
.
Errorf
(
"Failed to find subsy
tem mount for subsy
tem: %v"
,
sys
.
Name
())
return
nil
,
fmt
.
Errorf
(
"Failed to find subsy
stem mount for subsys
tem: %v"
,
sys
.
Name
())
}
}
if
err
:=
sys
.
GetStats
(
cgroupPaths
[
sys
.
Name
()],
stats
);
err
!=
nil
{
if
err
:=
sys
.
GetStats
(
cgroupPaths
[
sys
.
Name
()],
stats
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Failed to get stats for supported subsystems : %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"Failed to get stats for supported subsystems : %v"
,
err
)
...
@@ -524,7 +524,7 @@ func toResourceStats(stats *libcontainercgroups.Stats) *ResourceStats {
...
@@ -524,7 +524,7 @@ func toResourceStats(stats *libcontainercgroups.Stats) *ResourceStats {
// Get sets the ResourceParameters of the specified cgroup as read from the cgroup fs
// Get sets the ResourceParameters of the specified cgroup as read from the cgroup fs
func
(
m
*
cgroupManagerImpl
)
GetResourceStats
(
name
CgroupName
)
(
*
ResourceStats
,
error
)
{
func
(
m
*
cgroupManagerImpl
)
GetResourceStats
(
name
CgroupName
)
(
*
ResourceStats
,
error
)
{
cgroupPaths
:=
m
.
buildCgroupPaths
(
name
)
cgroupPaths
:=
m
.
buildCgroupPaths
(
name
)
stats
,
err
:=
getStatsSupportedSubsytems
(
cgroupPaths
)
stats
,
err
:=
getStatsSupportedSubsy
s
tems
(
cgroupPaths
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to get stats supported cgroup subsystems for cgroup %v: %v"
,
name
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to get stats supported cgroup subsystems for cgroup %v: %v"
,
name
,
err
)
}
}
...
...
pkg/kubelet/cm/container_manager.go
View file @
9d68ae59
...
@@ -51,7 +51,7 @@ type ContainerManager interface {
...
@@ -51,7 +51,7 @@ type ContainerManager interface {
// Returns a noop implementation if qos cgroup hierarchy is not enabled
// Returns a noop implementation if qos cgroup hierarchy is not enabled
NewPodContainerManager
()
PodContainerManager
NewPodContainerManager
()
PodContainerManager
// GetMountedSubsystems returns the mounted cgroup subsytems on the node
// GetMountedSubsystems returns the mounted cgroup subsy
s
tems on the node
GetMountedSubsystems
()
*
CgroupSubsystems
GetMountedSubsystems
()
*
CgroupSubsystems
// GetQOSContainersInfo returns the names of top level QoS containers
// GetQOSContainersInfo returns the names of top level QoS containers
...
...
pkg/kubelet/cm/container_manager_linux_test.go
View file @
9d68ae59
...
@@ -124,7 +124,7 @@ func TestCgroupMountValidationMemoryMissing(t *testing.T) {
...
@@ -124,7 +124,7 @@ func TestCgroupMountValidationMemoryMissing(t *testing.T) {
assert
.
Error
(
t
,
err
)
assert
.
Error
(
t
,
err
)
}
}
func
TestCgroupMountValidationMultipleSubsytem
(
t
*
testing
.
T
)
{
func
TestCgroupMountValidationMultipleSubsy
s
tem
(
t
*
testing
.
T
)
{
mountInt
:=
&
fakeMountInterface
{
mountInt
:=
&
fakeMountInterface
{
[]
mount
.
MountPoint
{
[]
mount
.
MountPoint
{
{
{
...
...
pkg/kubelet/cm/pod_container_manager_linux.go
View file @
9d68ae59
...
@@ -175,7 +175,7 @@ func (m *podContainerManagerImpl) ReduceCPULimits(podCgroup CgroupName) error {
...
@@ -175,7 +175,7 @@ func (m *podContainerManagerImpl) ReduceCPULimits(podCgroup CgroupName) error {
return
m
.
cgroupManager
.
ReduceCPULimits
(
podCgroup
)
return
m
.
cgroupManager
.
ReduceCPULimits
(
podCgroup
)
}
}
// GetAllPodsFromCgroups scans through all the subsytems of pod cgroups
// GetAllPodsFromCgroups scans through all the subsy
s
tems of pod cgroups
// Get list of pods whose cgroup still exist on the cgroup mounts
// Get list of pods whose cgroup still exist on the cgroup mounts
func
(
m
*
podContainerManagerImpl
)
GetAllPodsFromCgroups
()
(
map
[
types
.
UID
]
CgroupName
,
error
)
{
func
(
m
*
podContainerManagerImpl
)
GetAllPodsFromCgroups
()
(
map
[
types
.
UID
]
CgroupName
,
error
)
{
// Map for storing all the found pods on the disk
// Map for storing all the found pods on the disk
...
...
pkg/kubelet/cm/types.go
View file @
9d68ae59
...
@@ -80,7 +80,7 @@ type CgroupManager interface {
...
@@ -80,7 +80,7 @@ type CgroupManager interface {
Name
(
name
CgroupName
)
string
Name
(
name
CgroupName
)
string
// CgroupName converts the literal cgroupfs name on the host to an internal identifier.
// CgroupName converts the literal cgroupfs name on the host to an internal identifier.
CgroupName
(
name
string
)
CgroupName
CgroupName
(
name
string
)
CgroupName
// Pids scans through all subsytems to find pids associated with specified cgroup.
// Pids scans through all subsy
s
tems to find pids associated with specified cgroup.
Pids
(
name
CgroupName
)
[]
int
Pids
(
name
CgroupName
)
[]
int
// ReduceCPULimits reduces the CPU CFS values to the minimum amount of shares.
// ReduceCPULimits reduces the CPU CFS values to the minimum amount of shares.
ReduceCPULimits
(
cgroupName
CgroupName
)
error
ReduceCPULimits
(
cgroupName
CgroupName
)
error
...
...
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