github.com/endophage/docker@v1.4.2-0.20161027011718-242853499895/integration-cli/requirements_unix.go (about) 1 // +build !windows 2 3 package main 4 5 import ( 6 "io/ioutil" 7 "strings" 8 9 "github.com/docker/docker/pkg/sysinfo" 10 ) 11 12 var ( 13 // SysInfo stores information about which features a kernel supports. 14 SysInfo *sysinfo.SysInfo 15 cpuCfsPeriod = testRequirement{ 16 func() bool { 17 return SysInfo.CPUCfsPeriod 18 }, 19 "Test requires an environment that supports cgroup cfs period.", 20 } 21 cpuCfsQuota = testRequirement{ 22 func() bool { 23 return SysInfo.CPUCfsQuota 24 }, 25 "Test requires an environment that supports cgroup cfs quota.", 26 } 27 cpuShare = testRequirement{ 28 func() bool { 29 return SysInfo.CPUShares 30 }, 31 "Test requires an environment that supports cgroup cpu shares.", 32 } 33 oomControl = testRequirement{ 34 func() bool { 35 return SysInfo.OomKillDisable 36 }, 37 "Test requires Oom control enabled.", 38 } 39 pidsLimit = testRequirement{ 40 func() bool { 41 return SysInfo.PidsLimit 42 }, 43 "Test requires pids limit enabled.", 44 } 45 kernelMemorySupport = testRequirement{ 46 func() bool { 47 return SysInfo.KernelMemory 48 }, 49 "Test requires an environment that supports cgroup kernel memory.", 50 } 51 memoryLimitSupport = testRequirement{ 52 func() bool { 53 return SysInfo.MemoryLimit 54 }, 55 "Test requires an environment that supports cgroup memory limit.", 56 } 57 memoryReservationSupport = testRequirement{ 58 func() bool { 59 return SysInfo.MemoryReservation 60 }, 61 "Test requires an environment that supports cgroup memory reservation.", 62 } 63 swapMemorySupport = testRequirement{ 64 func() bool { 65 return SysInfo.SwapLimit 66 }, 67 "Test requires an environment that supports cgroup swap memory limit.", 68 } 69 memorySwappinessSupport = testRequirement{ 70 func() bool { 71 return SysInfo.MemorySwappiness 72 }, 73 "Test requires an environment that supports cgroup memory swappiness.", 74 } 75 blkioWeight = testRequirement{ 76 func() bool { 77 return SysInfo.BlkioWeight 78 }, 79 "Test requires an environment that supports blkio weight.", 80 } 81 cgroupCpuset = testRequirement{ 82 func() bool { 83 return SysInfo.Cpuset 84 }, 85 "Test requires an environment that supports cgroup cpuset.", 86 } 87 seccompEnabled = testRequirement{ 88 func() bool { 89 return supportsSeccomp && SysInfo.Seccomp 90 }, 91 "Test requires that seccomp support be enabled in the daemon.", 92 } 93 bridgeNfIptables = testRequirement{ 94 func() bool { 95 return !SysInfo.BridgeNFCallIPTablesDisabled 96 }, 97 "Test requires that bridge-nf-call-iptables support be enabled in the daemon.", 98 } 99 bridgeNfIP6tables = testRequirement{ 100 func() bool { 101 return !SysInfo.BridgeNFCallIP6TablesDisabled 102 }, 103 "Test requires that bridge-nf-call-ip6tables support be enabled in the daemon.", 104 } 105 unprivilegedUsernsClone = testRequirement{ 106 func() bool { 107 content, err := ioutil.ReadFile("/proc/sys/kernel/unprivileged_userns_clone") 108 if err == nil && strings.Contains(string(content), "0") { 109 return false 110 } 111 return true 112 }, 113 "Test cannot be run with 'sysctl kernel.unprivileged_userns_clone' = 0", 114 } 115 ambientCapabilities = testRequirement{ 116 func() bool { 117 content, err := ioutil.ReadFile("/proc/self/status") 118 if err == nil && strings.Contains(string(content), "CapAmb:") { 119 return true 120 } 121 return false 122 }, 123 "Test cannot be run without a kernel (4.3+) supporting ambient capabilities", 124 } 125 ) 126 127 func init() { 128 SysInfo = sysinfo.New(true) 129 }