2021-08-23 13:14:53 +00:00
|
|
|
//go:build !windows
|
2016-12-16 14:13:23 +00:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-08-24 10:10:50 +00:00
|
|
|
"os"
|
2016-12-16 14:13:23 +00:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/sysinfo"
|
|
|
|
)
|
|
|
|
|
2023-07-14 18:02:38 +00:00
|
|
|
var sysInfo *sysinfo.SysInfo
|
|
|
|
|
|
|
|
func setupLocalInfo() {
|
|
|
|
sysInfo = sysinfo.New()
|
|
|
|
}
|
2016-12-16 14:13:23 +00:00
|
|
|
|
|
|
|
func cpuCfsPeriod() bool {
|
2017-09-11 14:23:59 +00:00
|
|
|
return testEnv.DaemonInfo.CPUCfsPeriod
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func cpuCfsQuota() bool {
|
2017-09-11 14:23:59 +00:00
|
|
|
return testEnv.DaemonInfo.CPUCfsQuota
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func cpuShare() bool {
|
2017-09-11 14:23:59 +00:00
|
|
|
return testEnv.DaemonInfo.CPUShares
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func oomControl() bool {
|
2017-09-11 14:23:59 +00:00
|
|
|
return testEnv.DaemonInfo.OomKillDisable
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func pidsLimit() bool {
|
2023-07-14 18:02:38 +00:00
|
|
|
return sysInfo.PidsLimit
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func memoryLimitSupport() bool {
|
2017-09-11 14:23:59 +00:00
|
|
|
return testEnv.DaemonInfo.MemoryLimit
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func memoryReservationSupport() bool {
|
2023-07-14 18:02:38 +00:00
|
|
|
return sysInfo.MemoryReservation
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func swapMemorySupport() bool {
|
2017-09-11 14:23:59 +00:00
|
|
|
return testEnv.DaemonInfo.SwapLimit
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func memorySwappinessSupport() bool {
|
2023-07-14 18:02:38 +00:00
|
|
|
return testEnv.IsLocalDaemon() && sysInfo.MemorySwappiness
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func blkioWeight() bool {
|
2023-07-14 18:02:38 +00:00
|
|
|
return testEnv.IsLocalDaemon() && sysInfo.BlkioWeight
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func cgroupCpuset() bool {
|
2017-09-11 14:23:59 +00:00
|
|
|
return testEnv.DaemonInfo.CPUSet
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func seccompEnabled() bool {
|
2023-07-14 18:02:38 +00:00
|
|
|
return sysInfo.Seccomp
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func bridgeNfIptables() bool {
|
2023-07-14 18:02:38 +00:00
|
|
|
return !sysInfo.BridgeNFCallIPTablesDisabled
|
2016-12-16 14:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func unprivilegedUsernsClone() bool {
|
2021-08-24 10:10:50 +00:00
|
|
|
content, err := os.ReadFile("/proc/sys/kernel/unprivileged_userns_clone")
|
2016-12-16 14:13:23 +00:00
|
|
|
return err != nil || !strings.Contains(string(content), "0")
|
|
|
|
}
|