memory cgroup quota applies to both runsc and guest pids
- Dominant language
- Go
- Stars
- 19.3k
- Forks
- 2k
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 264
Description
Followup from https://github.com/google/gvisor/issues/2520
I tried to restrict my container to not use to much memory. The OCI spec defines this:
https://github.com/tianon/oci-runtime-spec/blob/master/config-linux.md#memory
It turns out swap is hard, so for this exercise let's disable swap and overcommit:
```
swapoff -a
```
And use this config in config.json
```
"disableOOMKiller": false,
"memory": {
"limit": 1073741824
},
```
What a user wants by such a config? I want to ensure that if the guests would "use more ram than mentioned" then OOM killer would kill them.
Now, I don't want runsc to die when that happens. I don't want to limit runsc-sandbox/gofer processes. If I wanted that I would run a memory cgroup on higher level. It's like - setting memory cgroup limits for a docker container does not mean I want to restrict docker daemon memory.
Sadly, today it doesn't work like that. Gvisor puts itself and guests into the same memory cgroup, so setting the limit in config.json means it's runsc-sandbox has chances of being reaped.
Couple ideas how to work around:
(A) put only guest pids into memory cgroup. Keep runsc-sandbox and runsc-gofer outside.
(B) Create a separate cgroup for guest pids with smaller limits inside the already existing cgroup
(C) change OOM killer priority for runsc processes to reduce the likelyhood of it being killed. For example keep passed `oomScoreAdj` for runsc and set the value +10 for guests.
(D) do active memory accounting in runsc-sandbox and avoid using the linux's OOM killer - implement one in runsc.
Contributor guide
Assessment
This issue has not been assessed yet.