Skip to content

Commit

Permalink
add check for cgroupv2 in clone
Browse files Browse the repository at this point in the history
resolves containers#13916

Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
  • Loading branch information
cdoern committed Apr 19, 2022
1 parent be0da4a commit 566dc33
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/specgen/generate/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

cdi "github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
"github.com/containers/common/libimage"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v4/libpod"
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/namespaces"
Expand Down Expand Up @@ -183,6 +184,16 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener
if err != nil {
return nil, nil, nil, err
}

cgroup2, err := cgroups.IsCgroup2UnifiedMode()
if err != nil {
return nil, nil, nil, err
}

if cgroup2 && s.ResourceLimits.Memory != nil && s.ResourceLimits.Memory.Swappiness != nil { // cgroupsv2 does not support memory swappiness
return nil, nil, nil, errors.Wrapf(define.ErrInvalidArg, "cgroupsv2 does not support memory swappiness")
}

if s.ResourceLimits != nil {
switch {
case s.ResourceLimits.CPU != nil:
Expand Down

0 comments on commit 566dc33

Please sign in to comment.