aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorJason T. Greene <jason.greene@redhat.com>2022-05-20 21:19:38 -0500
committerMatthew Heon <mheon@redhat.com>2022-06-14 14:26:55 -0400
commit24ef21ebdf67b64b2a19de7cd65358771f0be732 (patch)
tree4427de8a7e66eb2b0ed1af5319510d311f25e359 /pkg
parenta71d8c9c8e6136b67925c618c9feeb2e7dc6d593 (diff)
downloadpodman-24ef21ebdf67b64b2a19de7cd65358771f0be732.tar.gz
podman-24ef21ebdf67b64b2a19de7cd65358771f0be732.tar.bz2
podman-24ef21ebdf67b64b2a19de7cd65358771f0be732.zip
Support running podman under a root v2 cgroup
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/specgen/generate/validate.go9
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)