[lxc-devel] [lxd/master] Added soft memory limit even when hard is selected

lukaszmatczak on Github lxc-bot at linuxcontainers.org
Thu Mar 23 11:12:40 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 804 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170323/34ca4123/attachment.bin>
-------------- next part --------------
From 33bb0bc674ab3c4c578454751dee42d9a2a8449a Mon Sep 17 00:00:00 2001
From: Lukasz Matczak <lukasz.matczak at cba.pl>
Date: Thu, 23 Mar 2017 11:48:51 +0100
Subject: [PATCH] Added soft memory limit even when hard is selected

Signed-off-by: Lukasz Matczak <lukasz.matczak at cba.pl>
---
 lxd/container_lxc.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 5267c1a..4033870 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -3502,6 +3502,12 @@ func (c *containerLXC) Update(args containerArgs, userRequested bool) error {
 							return err
 						}
 					}
+					// Set soft limit to value 10% less than hard limit
+					err = c.CGroupSet("memory.soft_limit_in_bytes", memory*0.9)
+					if err != nil {
+						revertMemory()
+						return err
+					}
 				}
 
 				// Configure the swappiness


More information about the lxc-devel mailing list