[lxc-devel] [lxd/master] Don't destroy ephemeral container on restart
stgraber on Github
lxc-bot at linuxcontainers.org
Tue Oct 25 19:24:50 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161025/283c4d9e/attachment.bin>
-------------- next part --------------
From 3fa287c5a35b73eaf3c623cdc164e744d27047d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 25 Oct 2016 15:24:12 -0400
Subject: [PATCH] Don't destroy ephemeral container on restart
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #2555
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/container_state.go | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/lxd/container_state.go b/lxd/container_state.go
index 2b73320..c01cefc 100644
--- a/lxd/container_state.go
+++ b/lxd/container_state.go
@@ -109,6 +109,30 @@ func containerStatePut(d *Daemon, r *http.Request) Response {
}
case shared.Restart:
do = func(op *operation) error {
+ ephemeral := c.IsEphemeral()
+
+ if ephemeral {
+ // Unset ephemeral flag
+ args := containerArgs{
+ Architecture: c.Architecture(),
+ Config: c.LocalConfig(),
+ Devices: c.LocalDevices(),
+ Ephemeral: false,
+ Profiles: c.Profiles(),
+ }
+
+ err := c.Update(args, false)
+ if err != nil {
+ return err
+ }
+
+ // On function return, set the flag back on
+ defer func() {
+ args.Ephemeral = ephemeral
+ c.Update(args, true)
+ }()
+ }
+
if raw.Timeout == 0 || raw.Force {
err = c.Stop(false)
if err != nil {
More information about the lxc-devel
mailing list