From 4b4de5dc21f034f5f678114dbf6d51f047c96a59 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 14 Jun 2018 14:17:45 -0400 Subject: When setting a memory limit, also set a swap limit Closes #940 Signed-off-by: Matthew Heon Closes: #946 Approved by: rhatdan --- pkg/spec/spec.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pkg/spec') 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) -- cgit v1.2.3-54-g00ecf