[lxc-devel] [lxd/master] don't try to chmod zfs.img when testing db upgrades

tych0 on Github lxc-bot at linuxcontainers.org
Wed Jun 1 22:17:19 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 361 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160601/14bdf30d/attachment.bin>
-------------- next part --------------
From c3fdaec54e299b3ab991018c8ba92ea5d00d80f3 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Wed, 1 Jun 2016 22:16:18 +0000
Subject: [PATCH] don't try to chmod zfs.img when testing db upgrades

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

diff --git a/lxd/db_update.go b/lxd/db_update.go
index c7e9159..d8056d8 100644
--- a/lxd/db_update.go
+++ b/lxd/db_update.go
@@ -57,7 +57,13 @@ func dbUpdateFromV30(db *sql.DB, mockMode bool) error {
 	return err
 }
 
-func dbUpdateFromV29(db *sql.DB) error {
+func dbUpdateFromV29(db *sql.DB, mockMode bool) error {
+	if mockMode {
+		stmt := `INSERT INTO schema (version, updated_at) VALUES (?, strftime("%s"));`
+		_, err := db.Exec(stmt, 30)
+		return err
+	}
+
 	if shared.PathExists(shared.VarPath("zfs.img")) {
 		err := os.Chmod(shared.VarPath("zfs.img"), 0600)
 		if err != nil {
@@ -1055,7 +1061,7 @@ func dbUpdate(d *Daemon, prevVersion int) error {
 		}
 	}
 	if prevVersion < 30 {
-		err = dbUpdateFromV29(db)
+		err = dbUpdateFromV29(db, d.MockMode)
 		if err != nil {
 			return err
 		}


More information about the lxc-devel mailing list