[lxc-devel] [lxd/master] {daemon, patches}: adapt SetupStorageDriver()

brauner on Github lxc-bot at linuxcontainers.org
Sun Mar 12 00:58:06 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 443 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170312/525f90e3/attachment.bin>
-------------- next part --------------
From 5ebc164f37ee42e253d676bc6d1914eb694d531f Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sun, 12 Mar 2017 01:56:18 +0100
Subject: [PATCH] {daemon,patches}: adapt SetupStorageDriver()

We need a way to force a check right at the end of the storage api upgrade.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/daemon.go  | 6 +++---
 lxd/patches.go | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lxd/daemon.go b/lxd/daemon.go
index e4b626e..6ebe8ed 100644
--- a/lxd/daemon.go
+++ b/lxd/daemon.go
@@ -355,7 +355,7 @@ func (d *Daemon) createCmd(version string, c Command) {
 	})
 }
 
-func (d *Daemon) SetupStorageDriver() error {
+func (d *Daemon) SetupStorageDriver(forceCheck bool) error {
 	pools, err := dbStoragePools(d.db)
 	if err != nil {
 		if err == NoSuchObjectError {
@@ -372,7 +372,7 @@ func (d *Daemon) SetupStorageDriver() error {
 	// looking at the patches db: If we already have a storage pool defined
 	// but the upgrade somehow got messed up then there will be no
 	// "storage_api" entry in the db.
-	if len(pools) > 0 {
+	if len(pools) > 0 && !forceCheck {
 		appliedPatches, err := dbPatches(d.db)
 		if err != nil {
 			return err
@@ -870,7 +870,7 @@ func (d *Daemon) Init() error {
 
 	if !d.MockMode {
 		/* Read the storage pools */
-		err = d.SetupStorageDriver()
+		err = d.SetupStorageDriver(false)
 		if err != nil {
 			return err
 		}
diff --git a/lxd/patches.go b/lxd/patches.go
index 1fc7f89..93068f8 100644
--- a/lxd/patches.go
+++ b/lxd/patches.go
@@ -268,7 +268,7 @@ func patchStorageApi(name string, d *Daemon) error {
 	daemonConfig["storage.zfs_remove_snapshots"].Set(d, "")
 	daemonConfig["storage.zfs_use_refquota"].Set(d, "")
 
-	return d.SetupStorageDriver()
+	return d.SetupStorageDriver(true)
 }
 
 func upgradeFromStorageTypeBtrfs(name string, d *Daemon, defaultPoolName string, defaultStorageTypeName string, cRegular []string, cSnapshots []string, imgPublic []string, imgPrivate []string) error {


More information about the lxc-devel mailing list