[lxc-devel] [lxd/master] don't fail db upgrade if $LXD_DIR/containers doesn't exist

tych0 on Github lxc-bot at linuxcontainers.org
Tue Jul 12 14:39:42 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 490 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160712/33ae2993/attachment.bin>
-------------- next part --------------
From c3c749cb78fe2c13a12dececdddd9eb7fd68aac0 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Tue, 12 Jul 2016 08:38:31 -0600
Subject: [PATCH] don't fail db upgrade if $LXD_DIR/containers doesn't exist

The user may not have actually started LXD or imported any containers, so
let's not fail in this case.

Launchpad #1602025

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 lxd/db_update.go | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lxd/db_update.go b/lxd/db_update.go
index db5c913..b3c6894 100644
--- a/lxd/db_update.go
+++ b/lxd/db_update.go
@@ -136,6 +136,13 @@ func dbUpdateFromV30(currentVersion int, version int, d *Daemon) error {
 
 	entries, err := ioutil.ReadDir(shared.VarPath("containers"))
 	if err != nil {
+		/* If the directory didn't exist before, the user had never
+		 * started containers, so we don't need to fix up permissions
+		 * on anything.
+		 */
+		if os.IsNotExist(err) {
+			return nil
+		}
 		return err
 	}
 


More information about the lxc-devel mailing list