diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-05-25 08:53:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-25 08:53:15 -0400 |
commit | 1dcd1c970d3438bd6044cce0aba9b7258cb6849d (patch) | |
tree | caba8a5ca67cb093c456f4f532d03bdff4591d7f /pkg/specgen/generate | |
parent | da26439e2976cf1d6da0f9078e9c7eddebbab45c (diff) | |
parent | 94e82121bf73c163d86d99fa37b0d64adf996fba (diff) | |
download | podman-1dcd1c970d3438bd6044cce0aba9b7258cb6849d.tar.gz podman-1dcd1c970d3438bd6044cce0aba9b7258cb6849d.tar.bz2 podman-1dcd1c970d3438bd6044cce0aba9b7258cb6849d.zip |
Merge pull request #14308 from n1hility/root-cgroup
Support running podman under a root v2 cgroup
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) |