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
This commit is contained in:
parent
8f1b7be275
commit
4b4de5dc21
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue