containerd / containerd/nerdctl

cgroupv2: `--oom-kill-disable` is not respected

Open
#1,520 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
10.4k
Forks
826
Avg merge
1d 23h
Merged PRs (30d)
44

Description

### Description

According to the `Disabling OOMs` section of https://github.com/opencontainers/runtime-spec/issues/1005, it seems that to implement `--oom-kill-disable` on a host that uses cgroupv2, the only way that's mentioned is setting [`oom_score_adj`](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/proc.txt?h=v5.0#n1498) to `-1000`.

However, the value of `/proc/self/oom_score_adj` remains `1` regardless if `--oom-kill-disable` is passed to `nerdctl run` or not:

```sh
➜ ~ limactl shell default stat -fc %T /sys/fs/cgroup/
cgroup2fs
➜ ~ lima nerdctl run --rm --memory 256m --oom-kill-disable alpine cat /proc/self/oom_score_adj
1
➜ ~ lima nerdctl run --rm --memory 256m alpine cat /proc/self/oom_score_adj
1
```

Also checked both `containerd/containerd` and `containerd/cgroup`, and it seems that [only cgroupv1 is checking `LinuxMemory.DisableOOMKiller`](https://github.com/containerd/cgroups/search?q=DisableOOMKiller), which makes me wonder if `nerdctl` supports `--oom-kill-disable` for cgroupv2 hosts at all.

I just started to learn about these things recently, so my understanding could be off. Thank you for reading!

### Steps to reproduce the issue

```sh
lima nerdctl run --rm --memory 256m --oom-kill-disable alpine cat /proc/self/oom_score_adj
```

### Describe the results you received and expected

#### Received

`1`

#### Expected

`-1000`

### What version of nerdctl are you using?

```sh
➜ ~ lima nerdctl version
Client:
Version: v1.0.0
OS/Arch: linux/arm64
Git commit: c00780a1f5b905b09812722459c54936c9e070e6
buildctl:
Version: v0.10.5
GitCommit: bc26045116045516ff2427201abd299043eaf8f7

Server:
containerd:
Version: v1.6.8
GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d1
```

### Are you using a variant of nerdctl? (e.g., Rancher Desktop)

Lima

### Host information

```sh
➜ ~ lima nerdctl info
Client:
Namespace: default
Debug Mode: false

Server:
Server Version: v1.6.8
Storage Driver: overlayfs
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Log: fluentd journald json-file syslog
Storage: native overlayfs stargz fuse-overlayfs
Security Options:
apparmor
seccomp
Profile: default
cgroupns
rootless
Kernel Version: 5.15.0-52-generic
Operating System: Ubuntu 22.04.1 LTS
OSType: linux
Architecture: aarch64
CPUs: 4
Total Memory: 3.816GiB
Name: lima-default
ID: a928eae4-cc94-427b-9e85-bcae448db4bd

WARNING: AppArmor profile "nerdctl-default" is not loaded.
Use 'sudo nerdctl apparmor load' if you prefer to use AppArmor with rootless mode.
This warning is negligible if you do not intend to use AppArmor.
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.