diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-06-14 14:17:45 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-06-15 09:25:21 +0000 |
commit | 4b4de5dc21f034f5f678114dbf6d51f047c96a59 (patch) | |
tree | 7de07789af0802ae00664ab1280eeb4e36e7c2eb | |
parent | 8f1b7be275e74a7a3f9ecaad105846d603aabb1d (diff) | |
download | podman-4b4de5dc21f034f5f678114dbf6d51f047c96a59.tar.gz podman-4b4de5dc21f034f5f678114dbf6d51f047c96a59.tar.bz2 podman-4b4de5dc21f034f5f678114dbf6d51f047c96a59.zip |
When setting a memory limit, also set a swap limit
Closes #940
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #946
Approved by: rhatdan
-rw-r--r-- | pkg/spec/spec.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go index fdbbcd6ad..75ab03e53 100644 --- a/pkg/spec/spec.go +++ b/pkg/spec/spec.go @@ -74,6 +74,11 @@ func CreateConfigToOCISpec(config *CreateConfig) (*spec.Spec, error) { //nolint // RESOURCES - MEMORY if config.Resources.Memory != 0 { g.SetLinuxResourcesMemoryLimit(config.Resources.Memory) + // If a swap limit is not explicitly set, also set a swap limit + // Default to double the memory limit + if config.Resources.MemorySwap == 0 { + g.SetLinuxResourcesMemorySwap(2 * config.Resources.Memory) + } } if config.Resources.MemoryReservation != 0 { g.SetLinuxResourcesMemoryReservation(config.Resources.MemoryReservation) |