The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6720
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 81874149d766c3876bc4feafdb0ac17b2f713d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Wed, 15 Jan 2020 15:34:40 -0500 Subject: [PATCH 1/3] lxd/storage/btrfs: Fix bad check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/storage/drivers/driver_btrfs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxd/storage/drivers/driver_btrfs.go b/lxd/storage/drivers/driver_btrfs.go index de93cb8048..bf747f1b49 100644 --- a/lxd/storage/drivers/driver_btrfs.go +++ b/lxd/storage/drivers/driver_btrfs.go @@ -315,7 +315,7 @@ func (d *btrfs) Mount() (bool, error) { } // Custom mount options don't work inside containers - if !d.state.OS.RunningInUserNS { + if d.state.OS.RunningInUserNS { return true, nil } From 4a149c412ab225a784e71ce344e41fd2f038fa29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Wed, 15 Jan 2020 15:59:32 -0500 Subject: [PATCH 2/3] lxd/containers: Properly setup cgroup writer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/container_lxc.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go index 9dc9ca92ab..d5ce352882 100644 --- a/lxd/container_lxc.go +++ b/lxd/container_lxc.go @@ -4112,7 +4112,7 @@ func (c *containerLXC) Update(args db.InstanceArgs, userRequested bool) error { return errors.Wrap(err, "Initialize LXC") } - cg, err := c.cgroup(c.c) + cg, err := c.cgroup(nil) if err != nil { return err } @@ -4317,11 +4317,13 @@ func (c *containerLXC) Update(args db.InstanceArgs, userRequested bool) error { return err } } + err = cg.SetMemoryMaxUsage("-1") if err != nil { revertMemory() return err } + err = cg.SetMemorySoftLimit("-1") if err != nil { revertMemory() @@ -4343,6 +4345,7 @@ func (c *containerLXC) Update(args db.InstanceArgs, userRequested bool) error { revertMemory() return err } + err = cg.SetMemorySwapMax(memory) if err != nil { revertMemory() @@ -4362,6 +4365,7 @@ func (c *containerLXC) Update(args db.InstanceArgs, userRequested bool) error { revertMemory() return err } + err = cg.SetMemorySoftLimit(fmt.Sprintf("%.0f", float64(valueInt)*0.9)) if err != nil { revertMemory() @@ -5756,7 +5760,7 @@ func (c *containerLXC) cpuState() api.InstanceStateCPU { cpu := api.InstanceStateCPU{} // CPU usage in seconds - cg, err := c.cgroup(c.c) + cg, err := c.cgroup(nil) if err != nil { return cpu } @@ -5832,7 +5836,7 @@ func (c *containerLXC) diskState() map[string]api.InstanceStateDisk { func (c *containerLXC) memoryState() api.InstanceStateMemory { memory := api.InstanceStateMemory{} - cg, err := c.cgroup(c.c) + cg, err := c.cgroup(nil) if err != nil { return memory } @@ -5945,7 +5949,7 @@ func (c *containerLXC) processesState() int64 { return 0 } - cg, err := c.cgroup(c.c) + cg, err := c.cgroup(nil) if err != nil { return 0 } @@ -6525,7 +6529,7 @@ func (c *containerLXC) removeDiskDevices() error { // Network I/O limits func (c *containerLXC) setNetworkPriority() error { - cg, err := c.cgroup(c.c) + cg, err := c.cgroup(nil) if err != nil { return err } From 6edc4b256e24b06967af30b6a7109ea15efe7d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Wed, 15 Jan 2020 16:00:29 -0500 Subject: [PATCH 3/3] lxd/cgroup: Fix memory limit handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/cgroup/abstraction.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lxd/cgroup/abstraction.go b/lxd/cgroup/abstraction.go index 2f7dc09e2b..ab8a910cf5 100644 --- a/lxd/cgroup/abstraction.go +++ b/lxd/cgroup/abstraction.go @@ -50,14 +50,8 @@ func (cg *CGroup) SetMemorySoftLimit(softLim string) error { case Unavailable: return ErrControllerMissing case V1: - if softLim == "-1" { - return cg.rw.Set(version, "memory", "memory.soft_limit_in_bytes", "max") - } return cg.rw.Set(version, "memory", "memory.soft_limit_in_bytes", softLim) case V2: - if softLim == "-1" { - return cg.rw.Set(version, "memory", "memory.low", "max") - } return cg.rw.Set(version, "memory", "memory.low", softLim) } @@ -129,15 +123,8 @@ func (cg *CGroup) SetMemorySwapMax(max string) error { case Unavailable: return ErrControllerMissing case V1: - if max == "-1" { - return cg.rw.Set(version, "memory", "memory.memsw.limit_in_bytes", "max") - } - return cg.rw.Set(version, "memory", "memory.memsw.limit_in_bytes", max) case V2: - if max == "-1" { - return cg.rw.Set(version, "memory", "memory.swap.max", "max") - } return cg.rw.Set(version, "memory", "memory.swap.max", max) }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel