mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Signed-off-by: Derek McGowan <derek@mcg.dev>
(cherry picked from commit cd89a35ea0)
Signed-off-by: Andrey Epifanov <aepifanov@mirantis.com>
# Conflicts:
# integration-cli/docker_cli_update_unix_test.go
# Conflicts:
# hack/make/.integration-daemon-start
# integration-cli/docker_api_stats_test.go
# integration-cli/requirements_windows_test.go
(cherry picked from commit 408b47c8a7d42f62b9be7b3807d81209221e97a4)
Signed-off-by: Andrey Epifanov <aepifanov@mirantis.com>
97 lines
1.8 KiB
Go
97 lines
1.8 KiB
Go
//go:build !windows
|
|
// +build !windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
|
|
"github.com/containerd/cgroups"
|
|
"github.com/docker/docker/pkg/sysinfo"
|
|
)
|
|
|
|
var (
|
|
// SysInfo stores information about which features a kernel supports.
|
|
SysInfo *sysinfo.SysInfo
|
|
)
|
|
|
|
func cpuCfsPeriod() bool {
|
|
return testEnv.DaemonInfo.CPUCfsPeriod
|
|
}
|
|
|
|
func cpuCfsQuota() bool {
|
|
return testEnv.DaemonInfo.CPUCfsQuota
|
|
}
|
|
|
|
func cpuShare() bool {
|
|
return testEnv.DaemonInfo.CPUShares
|
|
}
|
|
|
|
func oomControl() bool {
|
|
return testEnv.DaemonInfo.OomKillDisable
|
|
}
|
|
|
|
func pidsLimit() bool {
|
|
return SysInfo.PidsLimit
|
|
}
|
|
|
|
func memoryLimitSupport() bool {
|
|
return testEnv.DaemonInfo.MemoryLimit
|
|
}
|
|
|
|
func memoryReservationSupport() bool {
|
|
return SysInfo.MemoryReservation
|
|
}
|
|
|
|
func swapMemorySupport() bool {
|
|
return testEnv.DaemonInfo.SwapLimit
|
|
}
|
|
|
|
func memorySwappinessSupport() bool {
|
|
return testEnv.IsLocalDaemon() && SysInfo.MemorySwappiness
|
|
}
|
|
|
|
func blkioWeight() bool {
|
|
return testEnv.IsLocalDaemon() && SysInfo.BlkioWeight
|
|
}
|
|
|
|
func cgroupCpuset() bool {
|
|
return testEnv.DaemonInfo.CPUSet
|
|
}
|
|
|
|
func seccompEnabled() bool {
|
|
return SysInfo.Seccomp
|
|
}
|
|
|
|
func bridgeNfIptables() bool {
|
|
return !SysInfo.BridgeNFCallIPTablesDisabled
|
|
}
|
|
|
|
func onlyCgroupsv2() bool {
|
|
// Only check for unified, cgroup v1 tests can run under other modes
|
|
return cgroups.Mode() == cgroups.Unified
|
|
}
|
|
|
|
func unprivilegedUsernsClone() bool {
|
|
content, err := os.ReadFile("/proc/sys/kernel/unprivileged_userns_clone")
|
|
return err != nil || !strings.Contains(string(content), "0")
|
|
}
|
|
|
|
func overlayFSSupported() bool {
|
|
cmd := exec.Command(dockerBinary, "run", "--rm", "busybox", "/bin/sh", "-c", "cat /proc/filesystems")
|
|
out, err := cmd.CombinedOutput()
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return bytes.Contains(out, []byte("overlay\n"))
|
|
}
|
|
|
|
func init() {
|
|
if testEnv.IsLocalDaemon() {
|
|
SysInfo = sysinfo.New()
|
|
}
|
|
}
|