[lxc-devel] [lxd/master] Patches bugfixes

stgraber on Github lxc-bot at linuxcontainers.org
Tue Sep 5 07:06:26 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170905/b32e1093/attachment.bin>
-------------- next part --------------
From 513d99c6846e4d9c85916353c488014850fd5ee8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sun, 3 Sep 2017 22:04:42 -0400
Subject: [PATCH 1/2] patches: Move patch to the right part of the file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/patches.go | 170 ++++++++++++++++++++++++++++-----------------------------
 1 file changed, 85 insertions(+), 85 deletions(-)

diff --git a/lxd/patches.go b/lxd/patches.go
index 65a2257d8..0b6c88777 100644
--- a/lxd/patches.go
+++ b/lxd/patches.go
@@ -2390,6 +2390,91 @@ func patchStorageZFSVolumeSize(name string, d *Daemon) error {
 	return nil
 }
 
+func patchNetworkDnsmasqHosts(name string, d *Daemon) error {
+	// Get the list of networks
+	networks, err := db.Networks(d.db)
+	if err != nil {
+		return err
+	}
+
+	for _, network := range networks {
+		// Remove the old dhcp-hosts file (will be re-generated on startup)
+		if shared.PathExists(shared.VarPath("networks", network, "dnsmasq.hosts")) {
+			err = os.Remove(shared.VarPath("networks", network, "dnsmasq.hosts"))
+			if err != nil {
+				return err
+			}
+		}
+	}
+
+	return nil
+}
+
+func patchStorageApiDirBindMount(name string, d *Daemon) error {
+	pools, err := db.StoragePools(d.db)
+	if err != nil && err == db.NoSuchObjectError {
+		// No pool was configured in the previous update. So we're on a
+		// pristine LXD instance.
+		return nil
+	} else if err != nil {
+		// Database is screwed.
+		logger.Errorf("Failed to query database: %s", err)
+		return err
+	}
+
+	for _, poolName := range pools {
+		_, pool, err := db.StoragePoolGet(d.db, poolName)
+		if err != nil {
+			logger.Errorf("Failed to query database: %s", err)
+			return err
+		}
+
+		// We only care about dir
+		if pool.Driver != "dir" {
+			continue
+		}
+
+		source := pool.Config["source"]
+		if source == "" {
+			msg := fmt.Sprintf(`No "source" property for storage `+
+				`pool "%s" found`, poolName)
+			logger.Errorf(msg)
+			return fmt.Errorf(msg)
+		}
+		cleanSource := filepath.Clean(source)
+		poolMntPoint := getStoragePoolMountPoint(poolName)
+
+		if cleanSource == poolName {
+			continue
+		}
+
+		if shared.PathExists(poolMntPoint) {
+			err := os.Remove(poolMntPoint)
+			if err != nil {
+				return err
+			}
+		}
+
+		err = os.MkdirAll(poolMntPoint, 0711)
+		if err != nil {
+			return err
+		}
+
+		mountSource := cleanSource
+		mountFlags := syscall.MS_BIND
+
+		err = syscall.Mount(mountSource, poolMntPoint, "", uintptr(mountFlags), "")
+		if err != nil {
+			logger.Errorf(`Failed to mount DIR storage pool "%s" onto `+
+				`"%s": %s`, mountSource, poolMntPoint, err)
+			return err
+		}
+
+	}
+
+	return nil
+}
+
 // Patches end here
 
 // Here are a couple of legacy patches that were originally in
@@ -2599,88 +2684,3 @@ func patchUpdateFromV30(d *Daemon) error {
 
 	return nil
 }
-
-func patchNetworkDnsmasqHosts(name string, d *Daemon) error {
-	// Get the list of networks
-	networks, err := db.Networks(d.db)
-	if err != nil {
-		return err
-	}
-
-	for _, network := range networks {
-		// Remove the old dhcp-hosts file (will be re-generated on startup)
-		if shared.PathExists(shared.VarPath("networks", network, "dnsmasq.hosts")) {
-			err = os.Remove(shared.VarPath("networks", network, "dnsmasq.hosts"))
-			if err != nil {
-				return err
-			}
-		}
-	}
-
-	return nil
-}
-
-func patchStorageApiDirBindMount(name string, d *Daemon) error {
-	pools, err := db.StoragePools(d.db)
-	if err != nil && err == db.NoSuchObjectError {
-		// No pool was configured in the previous update. So we're on a
-		// pristine LXD instance.
-		return nil
-	} else if err != nil {
-		// Database is screwed.
-		logger.Errorf("Failed to query database: %s", err)
-		return err
-	}
-
-	for _, poolName := range pools {
-		_, pool, err := db.StoragePoolGet(d.db, poolName)
-		if err != nil {
-			logger.Errorf("Failed to query database: %s", err)
-			return err
-		}
-
-		// We only care about dir
-		if pool.Driver != "dir" {
-			continue
-		}
-
-		source := pool.Config["source"]
-		if source == "" {
-			msg := fmt.Sprintf(`No "source" property for storage `+
-				`pool "%s" found`, poolName)
-			logger.Errorf(msg)
-			return fmt.Errorf(msg)
-		}
-		cleanSource := filepath.Clean(source)
-		poolMntPoint := getStoragePoolMountPoint(poolName)
-
-		if cleanSource == poolName {
-			continue
-		}
-
-		if shared.PathExists(poolMntPoint) {
-			err := os.Remove(poolMntPoint)
-			if err != nil {
-				return err
-			}
-		}
-
-		err = os.MkdirAll(poolMntPoint, 0711)
-		if err != nil {
-			return err
-		}
-
-		mountSource := cleanSource
-		mountFlags := syscall.MS_BIND
-
-		err = syscall.Mount(mountSource, poolMntPoint, "", uintptr(mountFlags), "")
-		if err != nil {
-			logger.Errorf(`Failed to mount DIR storage pool "%s" onto `+
-				`"%s": %s`, mountSource, poolMntPoint, err)
-			return err
-		}
-
-	}
-
-	return nil
-}

From d02daa298911dd0a4b1b84e5ad1a627c9ff0e534 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 5 Sep 2017 03:04:36 -0400
Subject: [PATCH 2/2] patches: Fix broken directory migration
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/patches.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/patches.go b/lxd/patches.go
index 0b6c88777..7f3aed559 100644
--- a/lxd/patches.go
+++ b/lxd/patches.go
@@ -2444,7 +2444,7 @@ func patchStorageApiDirBindMount(name string, d *Daemon) error {
 		cleanSource := filepath.Clean(source)
 		poolMntPoint := getStoragePoolMountPoint(poolName)
 
-		if cleanSource == poolName {
+		if cleanSource == poolMntPoint {
 			continue
 		}
 


More information about the lxc-devel mailing list