mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
cgroup2: enable resource limitation
enable resource limitation by disabling cgroup v1 warnings resource limitation still doesn't work with rootless mode (even with systemd mode) Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
612343618d
commit
409bbdc321
1 changed files with 45 additions and 0 deletions
|
@ -60,6 +60,9 @@ func New(quiet bool) *SysInfo {
|
|||
w := o(sysInfo, cgMounts)
|
||||
warnings = append(warnings, w...)
|
||||
}
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
warnings = append(warnings, "Your system is running cgroup v2 (unsupported)")
|
||||
}
|
||||
if !quiet {
|
||||
for _, w := range warnings {
|
||||
logrus.Warn(w)
|
||||
|
@ -70,6 +73,15 @@ func New(quiet bool) *SysInfo {
|
|||
|
||||
// applyMemoryCgroupInfo reads the memory information from the memory cgroup mount point.
|
||||
func applyMemoryCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
// TODO: check cgroup2 info correctly
|
||||
info.MemoryLimit = true
|
||||
info.SwapLimit = true
|
||||
info.MemoryReservation = true
|
||||
info.OomKillDisable = true
|
||||
info.MemorySwappiness = true
|
||||
return nil
|
||||
}
|
||||
var warnings []string
|
||||
mountPoint, ok := cgMounts["memory"]
|
||||
if !ok {
|
||||
|
@ -108,6 +120,15 @@ func applyMemoryCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
|||
|
||||
// applyCPUCgroupInfo reads the cpu information from the cpu cgroup mount point.
|
||||
func applyCPUCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
// TODO: check cgroup2 info correctly
|
||||
info.CPUShares = true
|
||||
info.CPUCfsPeriod = true
|
||||
info.CPUCfsQuota = true
|
||||
info.CPURealtimePeriod = true
|
||||
info.CPURealtimeRuntime = true
|
||||
return nil
|
||||
}
|
||||
var warnings []string
|
||||
mountPoint, ok := cgMounts["cpu"]
|
||||
if !ok {
|
||||
|
@ -145,6 +166,15 @@ func applyCPUCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
|||
|
||||
// applyBlkioCgroupInfo reads the blkio information from the blkio cgroup mount point.
|
||||
func applyBlkioCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
// TODO: check cgroup2 info correctly
|
||||
info.BlkioWeight = true
|
||||
info.BlkioReadBpsDevice = true
|
||||
info.BlkioWriteBpsDevice = true
|
||||
info.BlkioReadIOpsDevice = true
|
||||
info.BlkioWriteIOpsDevice = true
|
||||
return nil
|
||||
}
|
||||
var warnings []string
|
||||
mountPoint, ok := cgMounts["blkio"]
|
||||
if !ok {
|
||||
|
@ -186,6 +216,11 @@ func applyBlkioCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
|||
|
||||
// applyCPUSetCgroupInfo reads the cpuset information from the cpuset cgroup mount point.
|
||||
func applyCPUSetCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
// TODO: check cgroup2 info correctly
|
||||
info.Cpuset = true
|
||||
return nil
|
||||
}
|
||||
var warnings []string
|
||||
mountPoint, ok := cgMounts["cpuset"]
|
||||
if !ok {
|
||||
|
@ -213,6 +248,11 @@ func applyCPUSetCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
|||
|
||||
// applyPIDSCgroupInfo reads the pids information from the pids cgroup mount point.
|
||||
func applyPIDSCgroupInfo(info *SysInfo, _ map[string]string) []string {
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
// TODO: check cgroup2 info correctly
|
||||
info.PidsLimit = true
|
||||
return nil
|
||||
}
|
||||
var warnings []string
|
||||
_, err := cgroups.FindCgroupMountpoint("", "pids")
|
||||
if err != nil {
|
||||
|
@ -225,6 +265,11 @@ func applyPIDSCgroupInfo(info *SysInfo, _ map[string]string) []string {
|
|||
|
||||
// applyDevicesCgroupInfo reads the pids information from the devices cgroup mount point.
|
||||
func applyDevicesCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
// TODO: check cgroup2 info correctly
|
||||
info.CgroupDevicesEnabled = true
|
||||
return nil
|
||||
}
|
||||
var warnings []string
|
||||
_, ok := cgMounts["devices"]
|
||||
info.CgroupDevicesEnabled = ok
|
||||
|
|
Loading…
Reference in a new issue