[lxc-devel] [lxd/master] lxd/container: Early check for running container refresh
stgraber on Github
lxc-bot at linuxcontainers.org
Wed May 8 20:39:42 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/20190508/d1208673/attachment.bin>
-------------- next part --------------
From 1be2f80afeed0ccee761f795d3c70c98d7f828a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 8 May 2019 16:38:22 -0400
Subject: [PATCH] lxd/container: Early check for running container refresh
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 | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index 0151b59eee..fdfa2b972a 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -267,6 +267,7 @@ func createFromMigration(d *Daemon, project string, req *api.ContainersPost) Res
args.Devices[localRootDiskDeviceKey]["pool"] = storagePool
}
+ // Early check for refresh
if req.Source.Refresh {
// Check if the container exists
c, err = containerLoadByProjectAndName(d.State(), project, req.Name)
@@ -545,6 +546,17 @@ func createFromCopy(d *Daemon, project string, req *api.ContainersPost) Response
}
}
+ // Early check for refresh
+ if req.Source.Refresh {
+ // Check if the container exists
+ c, err := containerLoadByProjectAndName(d.State(), targetProject, req.Name)
+ if err != nil {
+ req.Source.Refresh = false
+ } else if c.IsRunning() {
+ return BadRequest(fmt.Errorf("Cannot refresh a running container"))
+ }
+ }
+
args := db.ContainerArgs{
Project: targetProject,
Architecture: source.Architecture(),
More information about the lxc-devel
mailing list