diff options
author | Jason T. Greene <jason.greene@redhat.com> | 2022-05-20 21:19:38 -0500 |
---|---|---|
committer | Jason T. Greene <jason.greene@redhat.com> | 2022-05-21 09:28:52 -0500 |
commit | 94e82121bf73c163d86d99fa37b0d64adf996fba (patch) | |
tree | 1b223ffd6d68b3fb701efe5eed5799aa344cac24 /pkg/specgen/generate | |
parent | 5c51e1d26ea7cb942008cf0e740bc16cb44bb2cf (diff) | |
download | podman-94e82121bf73c163d86d99fa37b0d64adf996fba.tar.gz podman-94e82121bf73c163d86d99fa37b0d64adf996fba.tar.bz2 podman-94e82121bf73c163d86d99fa37b0d64adf996fba.zip |
Support running podman under a root v2 cgroup
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
Diffstat (limited to 'pkg/specgen/generate')
-rw-r--r-- | pkg/specgen/generate/validate.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/specgen/generate/validate.go b/pkg/specgen/generate/validate.go index 44c7818e7..a1affef31 100644 --- a/pkg/specgen/generate/validate.go +++ b/pkg/specgen/generate/validate.go @@ -1,6 +1,7 @@ package generate import ( + "io/ioutil" "os" "path/filepath" @@ -166,6 +167,14 @@ func verifyContainerResourcesCgroupV2(s *specgen.SpecGenerator) ([]string, error if err != nil { return warnings, err } + + if own == "/" { + // If running under the root cgroup try to create or reuse a "probe" cgroup to read memory values + own = "podman_probe" + _ = os.MkdirAll(filepath.Join("/sys/fs/cgroup", own), 0o755) + _ = ioutil.WriteFile("/sys/fs/cgroup/cgroup.subtree_control", []byte("+memory"), 0o644) + } + memoryMax := filepath.Join("/sys/fs/cgroup", own, "memory.max") memorySwapMax := filepath.Join("/sys/fs/cgroup", own, "memory.swap.max") _, errMemoryMax := os.Stat(memoryMax) |