mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
kernel-memory limits are not supported in cgroups v2, and were obsoleted in [kernel v5.4], producing a `ENOTSUP` in kernel v5.16. Support for this option was removed in runc and other runtimes, as various LTS kernels contained a broken implementation, resulting in unpredictable behavior. We deprecated this option in [moby@b8ca7de], producing a warning when used, and actively ignore the option since [moby@0798f5f]. Given that setting this option had no effect in most situations, we should just remove this option instead of continuing to handle it with the expectation that a runtime may still support it. Note that we still support RHEL 8 (kernel 4.18) and RHEL 9 (kernel 5.14). We no longer build packages for Ubuntu 20.04 (kernel 5.4) and Debian Bullseye 11 (kernel 5.10), which still have an LTS / ESM programme, but for those it would only impact situations where a runtime is used that still supports it, and an old API version was used. [kernel v5.4]: https://github.com/torvalds/linux/commit/0158115f702b0ba208ab0 [moby@b8ca7de]:b8ca7de823[moby@0798f5f]:0798f5f5cfSigned-off-by: Sebastiaan van Stijn <github@gone.nl>
142 lines
4.2 KiB
Go
142 lines
4.2 KiB
Go
// Package sysinfo stores information about which features a kernel supports.
|
|
package sysinfo
|
|
|
|
// Opt for New().
|
|
type Opt func(info *SysInfo)
|
|
|
|
// SysInfo stores information about which features a kernel supports.
|
|
// TODO Windows: Factor out platform specific capabilities.
|
|
type SysInfo struct {
|
|
// Whether the kernel supports AppArmor or not
|
|
AppArmor bool
|
|
// Whether the kernel supports Seccomp or not
|
|
Seccomp bool
|
|
|
|
cgroupMemInfo
|
|
cgroupCPUInfo
|
|
cgroupBlkioInfo
|
|
cgroupCpusetInfo
|
|
cgroupPids
|
|
|
|
// Whether the kernel supports cgroup namespaces or not
|
|
CgroupNamespaces bool
|
|
|
|
// Whether IPv4 forwarding is supported or not, if this was disabled, networking will not work
|
|
IPv4ForwardingDisabled bool
|
|
|
|
// Whether the cgroup has the mountpoint of "devices" or not
|
|
CgroupDevicesEnabled bool
|
|
|
|
// Whether the cgroup is in unified mode (v2).
|
|
CgroupUnified bool
|
|
|
|
// Warnings contains a slice of warnings that occurred while collecting
|
|
// system information. These warnings are intended to be informational
|
|
// messages for the user, and can either be logged or returned to the
|
|
// client; they are not intended to be parsed / used for other purposes,
|
|
// and do not have a fixed format.
|
|
Warnings []string
|
|
|
|
// cgMounts is the list of cgroup v1 mount paths, indexed by subsystem, to
|
|
// inspect availability of subsystems.
|
|
cgMounts map[string]string
|
|
|
|
// cg2GroupPath is the cgroup v2 group path to inspect availability of the controllers.
|
|
cg2GroupPath string
|
|
|
|
// cg2Controllers is an index of available cgroup v2 controllers.
|
|
cg2Controllers map[string]struct{}
|
|
}
|
|
|
|
type cgroupMemInfo struct {
|
|
// Whether memory limit is supported or not
|
|
MemoryLimit bool
|
|
|
|
// Whether swap limit is supported or not
|
|
SwapLimit bool
|
|
|
|
// Whether soft limit is supported or not
|
|
MemoryReservation bool
|
|
|
|
// Whether OOM killer disable is supported or not
|
|
OomKillDisable bool
|
|
|
|
// Whether memory swappiness is supported or not
|
|
MemorySwappiness bool
|
|
|
|
// Whether kernel memory TCP limit is supported or not. Kernel memory TCP
|
|
// limit (`memory.kmem.tcp.limit_in_bytes`) is not supported on cgroups v2.
|
|
KernelMemoryTCP bool
|
|
}
|
|
|
|
type cgroupCPUInfo struct {
|
|
// Whether CPU shares is supported or not
|
|
CPUShares bool
|
|
|
|
// Whether CPU CFS (Completely Fair Scheduler) is supported
|
|
CPUCfs bool
|
|
|
|
// Whether CPU real-time scheduler is supported
|
|
CPURealtime bool
|
|
}
|
|
|
|
type cgroupBlkioInfo struct {
|
|
// Whether Block IO weight is supported or not
|
|
BlkioWeight bool
|
|
|
|
// Whether Block IO weight_device is supported or not
|
|
BlkioWeightDevice bool
|
|
|
|
// Whether Block IO read limit in bytes per second is supported or not
|
|
BlkioReadBpsDevice bool
|
|
|
|
// Whether Block IO write limit in bytes per second is supported or not
|
|
BlkioWriteBpsDevice bool
|
|
|
|
// Whether Block IO read limit in IO per second is supported or not
|
|
BlkioReadIOpsDevice bool
|
|
|
|
// Whether Block IO write limit in IO per second is supported or not
|
|
BlkioWriteIOpsDevice bool
|
|
}
|
|
|
|
type cgroupCpusetInfo struct {
|
|
// Whether Cpuset is supported or not
|
|
Cpuset bool
|
|
|
|
// Available Cpuset's cpus as read from "cpuset.cpus.effective" (cgroups v2)
|
|
// or "cpuset.cpus" (cgroups v1).
|
|
Cpus string
|
|
|
|
// CPUSets holds the list of available cpusets parsed from "cpuset.cpus.effective" (cgroups v2)
|
|
// or "cpuset.cpus" (cgroups v1).
|
|
CPUSets map[int]struct{}
|
|
|
|
// Available Cpuset's memory nodes as read from "cpuset.mems.effective" (cgroups v2)
|
|
// or "cpuset.mems" (cgroups v1).
|
|
Mems string
|
|
|
|
// MemSets holds the list of available cpusets parsed from "cpuset.mems.effective" (cgroups v2)
|
|
// or "cpuset.mems" (cgroups v1).
|
|
MemSets map[int]struct{}
|
|
}
|
|
|
|
type cgroupPids struct {
|
|
// Whether Pids Limit is supported or not
|
|
PidsLimit bool
|
|
}
|
|
|
|
// IsCpusetCpusAvailable returns `true` if the provided string set is contained
|
|
// in cgroup's cpuset.cpus set, `false` otherwise.
|
|
// If error is not nil a parsing error occurred.
|
|
func (c cgroupCpusetInfo) IsCpusetCpusAvailable(requested string) (bool, error) {
|
|
return isCpusetListAvailable(requested, c.CPUSets)
|
|
}
|
|
|
|
// IsCpusetMemsAvailable returns `true` if the provided string set is contained
|
|
// in cgroup's cpuset.mems set, `false` otherwise.
|
|
// If error is not nil a parsing error occurred.
|
|
func (c cgroupCpusetInfo) IsCpusetMemsAvailable(requested string) (bool, error) {
|
|
return isCpusetListAvailable(requested, c.MemSets)
|
|
}
|