aboutsummaryrefslogtreecommitdiff
path: root/pkg/specgen/generate
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-04-15 05:54:05 -0400
committerGitHub <noreply@github.com>2022-04-15 05:54:05 -0400
commitf2ab79cc02520fde565729727184767726bb09ce (patch)
tree3b8b878f305dc3b4be076d23ad835c2709981b93 /pkg/specgen/generate
parent6076e1a9a53a785d0053d22f1859103d5fea8b56 (diff)
parentf38b03d3752aa2a8fe1172b50b73cd5a33ae14ea (diff)
downloadpodman-f2ab79cc02520fde565729727184767726bb09ce.tar.gz
podman-f2ab79cc02520fde565729727184767726bb09ce.tar.bz2
podman-f2ab79cc02520fde565729727184767726bb09ce.zip
Merge pull request #13868 from cdoern/cloneSwap
Fix Memory Swappiness passing in Container Clone
Diffstat (limited to 'pkg/specgen/generate')
-rw-r--r--pkg/specgen/generate/container_create.go34
1 files changed, 10 insertions, 24 deletions
diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go
index b85a87742..5667a02e8 100644
--- a/pkg/specgen/generate/container_create.go
+++ b/pkg/specgen/generate/container_create.go
@@ -8,7 +8,6 @@ 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"
@@ -184,32 +183,19 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener
if err != nil {
return nil, nil, nil, err
}
-
- switch {
- case s.ResourceLimits.CPU != nil:
- runtimeSpec.Linux.Resources.CPU = s.ResourceLimits.CPU
- case s.ResourceLimits.Memory != nil:
- runtimeSpec.Linux.Resources.Memory = s.ResourceLimits.Memory
- case s.ResourceLimits.BlockIO != nil:
- runtimeSpec.Linux.Resources.BlockIO = s.ResourceLimits.BlockIO
- case s.ResourceLimits.Devices != nil:
- runtimeSpec.Linux.Resources.Devices = s.ResourceLimits.Devices
- }
-
- cgroup2, err := cgroups.IsCgroup2UnifiedMode()
- if err != nil {
- return nil, nil, nil, err
- }
- if cgroup2 && s.ResourceLimits.Memory != nil && s.ResourceLimits.Memory.Swappiness != nil { // conf.Spec.Linux contains memory swappiness established after the spec process we need to remove that
- s.ResourceLimits.Memory.Swappiness = nil
- if runtimeSpec.Linux.Resources.Memory != nil {
- runtimeSpec.Linux.Resources.Memory.Swappiness = nil
+ if s.ResourceLimits != nil {
+ switch {
+ case s.ResourceLimits.CPU != nil:
+ runtimeSpec.Linux.Resources.CPU = s.ResourceLimits.CPU
+ case s.ResourceLimits.Memory != nil:
+ runtimeSpec.Linux.Resources.Memory = s.ResourceLimits.Memory
+ case s.ResourceLimits.BlockIO != nil:
+ runtimeSpec.Linux.Resources.BlockIO = s.ResourceLimits.BlockIO
+ case s.ResourceLimits.Devices != nil:
+ runtimeSpec.Linux.Resources.Devices = s.ResourceLimits.Devices
}
}
}
- if err != nil {
- return nil, nil, nil, err
- }
if len(s.HostDeviceList) > 0 {
options = append(options, libpod.WithHostDevice(s.HostDeviceList))
}