mirror of
https://github.com/containers/podman.git
synced 2025-08-02 17:22:30 +08:00
Fix Memory Swappiness passing in Container Clone
`DefineCreateFlags` was excluding clone from using the memory-swappiness flag leading the value to be zero when our deafult is -1. Rearrange the if/else to give clone these memory related options resolves #13856 Signed-off-by: cdoern <cdoern@redhat.com>
This commit is contained in:
@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user