[lxc-devel] [lxd/master] stateful stop: remove snapshot from db on failure too

tych0 on Github lxc-bot at linuxcontainers.org
Fri Mar 18 19:38:54 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 451 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160318/eda9dfd5/attachment.bin>
-------------- next part --------------
From 32bd1c02186cba9227851394a5b65671618ef73e Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Fri, 18 Mar 2016 13:38:04 -0600
Subject: [PATCH] stateful stop: remove snapshot from db on failure too

We deleted the snapshot contents on failure, but not the db state. Let's do
that too.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 lxd/container_lxc.go | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index f6e80b7..c2b1f05 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -1101,22 +1101,24 @@ func (c *containerLXC) Start(stateful bool) error {
 			return fmt.Errorf("Container has no existing state to restore.")
 		}
 
+
 		err := c.c.Restore(lxc.RestoreOptions{
 			Directory: c.StatePath(),
 			Verbose:   true,
 		})
 
 		err2 := os.RemoveAll(c.StatePath())
-		if err2 != nil {
-			return err2
+
+		c.stateful = false
+		err3 := dbContainerSetStateful(c.daemon.db, c.id, false)
+		if err3 != nil {
+			return err3
 		}
 
-		if err != nil {
-			return err
+		if err2 != nil {
+			return err2
 		}
 
-		c.stateful = false
-		err = dbContainerSetStateful(c.daemon.db, c.id, false)
 		if err != nil {
 			return err
 		}


More information about the lxc-devel mailing list