[lxc-devel] [lxd/master] Fix devlxd failing to detect container

stgraber on Github lxc-bot at linuxcontainers.org
Tue Mar 15 03:19:16 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 609 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160315/703dceeb/attachment.bin>
-------------- next part --------------
From b623f504c683521dac6f57a636c108e57693e339 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 14 Mar 2016 23:17:22 -0400
Subject: [PATCH] Fix devlxd failing to detect container
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When some containers are stopped and devlxd is accessed through an
interactive LXD exec shell, the code fails to find what container the
request came from.

To fix that, just make sure we skip stopped containers.

This may be the source of #1751

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/devlxd.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lxd/devlxd.go b/lxd/devlxd.go
index 7fd9fff..ecb28e8 100644
--- a/lxd/devlxd.go
+++ b/lxd/devlxd.go
@@ -338,6 +338,10 @@ func findContainerForPid(pid int32, d *Daemon) (container, error) {
 			return nil, err
 		}
 
+		if !c.IsRunning() {
+			continue
+		}
+
 		initpid := c.InitPID()
 		pidNs, err := os.Readlink(fmt.Sprintf("/proc/%d/ns/pid", initpid))
 		if err != nil {


More information about the lxc-devel mailing list