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>
| ... | ... |
@@ -60,6 +60,9 @@ func New(quiet bool) *SysInfo {
|
| 60 | 60 |
w := o(sysInfo, cgMounts) |
| 61 | 61 |
warnings = append(warnings, w...) |
| 62 | 62 |
} |
| 63 |
+ if cgroups.IsCgroup2UnifiedMode() {
|
|
| 64 |
+ warnings = append(warnings, "Your system is running cgroup v2 (unsupported)") |
|
| 65 |
+ } |
|
| 63 | 66 |
if !quiet {
|
| 64 | 67 |
for _, w := range warnings {
|
| 65 | 68 |
logrus.Warn(w) |
| ... | ... |
@@ -70,6 +73,15 @@ func New(quiet bool) *SysInfo {
|
| 70 | 70 |
|
| 71 | 71 |
// applyMemoryCgroupInfo reads the memory information from the memory cgroup mount point. |
| 72 | 72 |
func applyMemoryCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
| 73 |
+ if cgroups.IsCgroup2UnifiedMode() {
|
|
| 74 |
+ // TODO: check cgroup2 info correctly |
|
| 75 |
+ info.MemoryLimit = true |
|
| 76 |
+ info.SwapLimit = true |
|
| 77 |
+ info.MemoryReservation = true |
|
| 78 |
+ info.OomKillDisable = true |
|
| 79 |
+ info.MemorySwappiness = true |
|
| 80 |
+ return nil |
|
| 81 |
+ } |
|
| 73 | 82 |
var warnings []string |
| 74 | 83 |
mountPoint, ok := cgMounts["memory"] |
| 75 | 84 |
if !ok {
|
| ... | ... |
@@ -108,6 +120,15 @@ func applyMemoryCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
| 108 | 108 |
|
| 109 | 109 |
// applyCPUCgroupInfo reads the cpu information from the cpu cgroup mount point. |
| 110 | 110 |
func applyCPUCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
| 111 |
+ if cgroups.IsCgroup2UnifiedMode() {
|
|
| 112 |
+ // TODO: check cgroup2 info correctly |
|
| 113 |
+ info.CPUShares = true |
|
| 114 |
+ info.CPUCfsPeriod = true |
|
| 115 |
+ info.CPUCfsQuota = true |
|
| 116 |
+ info.CPURealtimePeriod = true |
|
| 117 |
+ info.CPURealtimeRuntime = true |
|
| 118 |
+ return nil |
|
| 119 |
+ } |
|
| 111 | 120 |
var warnings []string |
| 112 | 121 |
mountPoint, ok := cgMounts["cpu"] |
| 113 | 122 |
if !ok {
|
| ... | ... |
@@ -145,6 +166,15 @@ func applyCPUCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
| 145 | 145 |
|
| 146 | 146 |
// applyBlkioCgroupInfo reads the blkio information from the blkio cgroup mount point. |
| 147 | 147 |
func applyBlkioCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
| 148 |
+ if cgroups.IsCgroup2UnifiedMode() {
|
|
| 149 |
+ // TODO: check cgroup2 info correctly |
|
| 150 |
+ info.BlkioWeight = true |
|
| 151 |
+ info.BlkioReadBpsDevice = true |
|
| 152 |
+ info.BlkioWriteBpsDevice = true |
|
| 153 |
+ info.BlkioReadIOpsDevice = true |
|
| 154 |
+ info.BlkioWriteIOpsDevice = true |
|
| 155 |
+ return nil |
|
| 156 |
+ } |
|
| 148 | 157 |
var warnings []string |
| 149 | 158 |
mountPoint, ok := cgMounts["blkio"] |
| 150 | 159 |
if !ok {
|
| ... | ... |
@@ -186,6 +216,11 @@ func applyBlkioCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
| 186 | 186 |
|
| 187 | 187 |
// applyCPUSetCgroupInfo reads the cpuset information from the cpuset cgroup mount point. |
| 188 | 188 |
func applyCPUSetCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
| 189 |
+ if cgroups.IsCgroup2UnifiedMode() {
|
|
| 190 |
+ // TODO: check cgroup2 info correctly |
|
| 191 |
+ info.Cpuset = true |
|
| 192 |
+ return nil |
|
| 193 |
+ } |
|
| 189 | 194 |
var warnings []string |
| 190 | 195 |
mountPoint, ok := cgMounts["cpuset"] |
| 191 | 196 |
if !ok {
|
| ... | ... |
@@ -213,6 +248,11 @@ func applyCPUSetCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
| 213 | 213 |
|
| 214 | 214 |
// applyPIDSCgroupInfo reads the pids information from the pids cgroup mount point. |
| 215 | 215 |
func applyPIDSCgroupInfo(info *SysInfo, _ map[string]string) []string {
|
| 216 |
+ if cgroups.IsCgroup2UnifiedMode() {
|
|
| 217 |
+ // TODO: check cgroup2 info correctly |
|
| 218 |
+ info.PidsLimit = true |
|
| 219 |
+ return nil |
|
| 220 |
+ } |
|
| 216 | 221 |
var warnings []string |
| 217 | 222 |
_, err := cgroups.FindCgroupMountpoint("", "pids")
|
| 218 | 223 |
if err != nil {
|
| ... | ... |
@@ -225,6 +265,11 @@ func applyPIDSCgroupInfo(info *SysInfo, _ map[string]string) []string {
|
| 225 | 225 |
|
| 226 | 226 |
// applyDevicesCgroupInfo reads the pids information from the devices cgroup mount point. |
| 227 | 227 |
func applyDevicesCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
|
| 228 |
+ if cgroups.IsCgroup2UnifiedMode() {
|
|
| 229 |
+ // TODO: check cgroup2 info correctly |
|
| 230 |
+ info.CgroupDevicesEnabled = true |
|
| 231 |
+ return nil |
|
| 232 |
+ } |
|
| 228 | 233 |
var warnings []string |
| 229 | 234 |
_, ok := cgMounts["devices"] |
| 230 | 235 |
info.CgroupDevicesEnabled = ok |