The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4327

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) ===
Closes #4326

Signed-off-by: St├ęphane Graber <stgra...@ubuntu.com>
From f5b21ce632b81bf4e95353b6fc9641d65daa2d90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 13 Mar 2018 13:06:14 -0400
Subject: [PATCH] lxd/containers: Fix crash on container error
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #4326

Signed-off-by: St├ęphane Graber <stgra...@ubuntu.com>
---
 lxd/containers_get.go | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lxd/containers_get.go b/lxd/containers_get.go
index 75c95400a..3a4fe94e4 100644
--- a/lxd/containers_get.go
+++ b/lxd/containers_get.go
@@ -94,6 +94,7 @@ func doContainersGet(d *Daemon, r *http.Request) 
(interface{}, error) {
                        for _, container := range containers {
                                resultAppend(container, api.Container{}, 
fmt.Errorf("unavailable"))
                        }
+
                        continue
                }
 
@@ -104,17 +105,21 @@ func doContainersGet(d *Daemon, r *http.Request) 
(interface{}, error) {
                        go func(address string, containers []string) {
                                defer wg.Done()
                                cert := d.endpoints.NetworkCert()
+
                                cs, err := doContainersGetFromNode(address, 
cert)
                                if err != nil {
                                        for _, name := range containers {
                                                resultAppend(name, 
api.Container{}, err)
                                        }
+
                                        return
                                }
+
                                for _, c := range cs {
                                        resultAppend(c.Name, c, nil)
                                }
                        }(address, containers)
+
                        continue
                }
 
@@ -126,7 +131,11 @@ func doContainersGet(d *Daemon, r *http.Request) 
(interface{}, error) {
                        }
 
                        c, err := doContainerGet(d.State(), container)
-                       resultAppend(container, *c, err)
+                       if err != nil {
+                               resultAppend(container, api.Container{}, err)
+                       } else {
+                               resultAppend(container, *c, err)
+                       }
                }
        }
        wg.Wait()
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to