summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-01-13 14:52:56 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2022-01-14 12:32:35 -0500
commit607cb80bf77642c02b80bff56aa4c3e396a91fa0 (patch)
tree170136eef992647b38b79399f6b1fb3ad98a7b6d /pkg
parenta15dfb3648b903fa61c299347b315ad8302d8e15 (diff)
downloadpodman-607cb80bf77642c02b80bff56aa4c3e396a91fa0.tar.gz
podman-607cb80bf77642c02b80bff56aa4c3e396a91fa0.tar.bz2
podman-607cb80bf77642c02b80bff56aa4c3e396a91fa0.zip
Fix cgroup mode handling in api server
Also change code to globably be consistent when refering to capatilized Cgroup. Fixed: https://github.com/containers/podman/issues/12550 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/specgen/generate/container.go4
-rw-r--r--pkg/specgenutil/specgen.go9
2 files changed, 13 insertions, 0 deletions
diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go
index 2c7b3c091..7b55a0cb3 100644
--- a/pkg/specgen/generate/container.go
+++ b/pkg/specgen/generate/container.go
@@ -229,6 +229,10 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
}
}
+ if s.CgroupsMode == "" {
+ s.CgroupsMode = rtc.Cgroups()
+ }
+
// If caller did not specify Pids Limits load default
if s.ResourceLimits == nil || s.ResourceLimits.Pids == nil {
if s.CgroupsMode != "disabled" {
diff --git a/pkg/specgenutil/specgen.go b/pkg/specgenutil/specgen.go
index bb9d5d1f9..59ac19c2c 100644
--- a/pkg/specgenutil/specgen.go
+++ b/pkg/specgenutil/specgen.go
@@ -8,6 +8,7 @@ import (
"strings"
"time"
+ "github.com/containers/common/pkg/config"
"github.com/containers/image/v5/manifest"
"github.com/containers/podman/v3/cmd/podman/parse"
"github.com/containers/podman/v3/libpod/define"
@@ -490,6 +491,14 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions
}
s.CgroupParent = c.CgroupParent
s.CgroupsMode = c.CgroupsMode
+ if s.CgroupsMode == "" {
+ rtc, err := config.Default()
+ if err != nil {
+ return err
+ }
+
+ s.CgroupsMode = rtc.Cgroups()
+ }
s.Groups = c.GroupAdd