summaryrefslogtreecommitdiff
path: root/pkg/spec/spec.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/spec/spec.go')
-rw-r--r--pkg/spec/spec.go5
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)