[lxc-devel] [lxd/master] Bugfixes
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Nov 4 20:52:14 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161104/a0651c12/attachment.bin>
-------------- next part --------------
From c591d8d730841dc53b9214f3c4181452a9681430 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 4 Nov 2016 14:48:18 -0600
Subject: [PATCH 1/2] Timeout container freeze on stop
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Sometimes we can't actually freeze the container, so give up after 5
seconds, restore the processes so that LXC can then normally kill them.
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/container_lxc.go | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index f8e840a..89301ce 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -1750,7 +1750,17 @@ func (c *containerLXC) Stop(stateful bool) error {
}
// Attempt to freeze the container first, helps massively with fork bombs
- c.Freeze()
+ freezer := make(chan bool, 1)
+ go func() {
+ c.Freeze()
+ freezer <- true
+ }()
+
+ select {
+ case <-freezer:
+ case <-time.After(time.Second * 5):
+ c.Unfreeze()
+ }
if err := c.c.Stop(); err != nil {
op.Done(err)
From fcd2a0bbbcb7191ab4fed751656a90c6fb26e30e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 4 Nov 2016 14:51:11 -0600
Subject: [PATCH 2/2] Add /snap/bin to PATH even if only /snap exists
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
/snap/bin is created later on by snapd, so lets just assume that it will
exist and append /snap/bin so long as /snap exists.
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/container_exec.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/container_exec.go b/lxd/container_exec.go
index 4272b4e..9a020c3 100644
--- a/lxd/container_exec.go
+++ b/lxd/container_exec.go
@@ -340,7 +340,7 @@ func containerExecPost(d *Daemon, r *http.Request) Response {
_, ok := env["PATH"]
if !ok {
env["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
- if shared.PathExists(fmt.Sprintf("%s/snap/bin", c.RootfsPath())) {
+ if shared.PathExists(fmt.Sprintf("%s/snap", c.RootfsPath())) {
env["PATH"] = fmt.Sprintf("%s:/snap/bin", env["PATH"])
}
}
More information about the lxc-devel
mailing list