[lxc-devel] [lxd/master] lxd/containers: Fix crash on refresh of non-existing

stgraber on Github lxc-bot at linuxcontainers.org
Tue Apr 2 03:46:25 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190401/b5044573/attachment.bin>
-------------- next part --------------
From a9b8da5a7162a616d7fa4f64a2a8081699604d85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 1 Apr 2019 23:46:01 -0400
Subject: [PATCH] lxd/containers: Fix crash on refresh of non-existing
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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

diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index 3411aa2ca6..5d6229e36b 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -320,9 +320,7 @@ func createFromMigration(d *Daemon, project string, req *api.ContainersPost) Res
 		c, err = containerLoadByProjectAndName(d.State(), project, req.Name)
 		if err != nil {
 			req.Source.Refresh = false
-		}
-
-		if c.IsRunning() {
+		} else if c.IsRunning() {
 			return BadRequest(fmt.Errorf("Cannot refresh a running container"))
 		}
 	}


More information about the lxc-devel mailing list