[lxc-devel] [lxd/master] lxd: Fix failing backup import

monstermunchkin on Github lxc-bot at linuxcontainers.org
Mon Feb 18 12:09:44 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 511 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190218/6aaf82e4/attachment.bin>
-------------- next part --------------
From e7904f0862ce230988b02ef65261f0c3037f348e Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Mon, 18 Feb 2019 13:06:11 +0100
Subject: [PATCH] lxd: Fix failing backup import

Instead of failing right away when no root device can be found in
devices, check expanded devices as well. Fail only if no root device
could be found.

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 lxd/backup.go | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/lxd/backup.go b/lxd/backup.go
index 0948cf85c0..237aac13be 100644
--- a/lxd/backup.go
+++ b/lxd/backup.go
@@ -262,25 +262,28 @@ func backupFixStoragePool(c *db.Cluster, b backupInfo, useDefaultPool bool) erro
 			return err
 		}
 
+		rootDiskDeviceFound := false
+
 		// Change the pool in the backup.yaml
 		backup.Pool = pool
 		if backup.Container.Devices != nil {
 			devName, _, err := shared.GetRootDiskDevice(backup.Container.Devices)
-			if err != nil {
-				return err
+			if err == nil {
+				backup.Container.Devices[devName]["pool"] = poolName
+				rootDiskDeviceFound = true
 			}
-
-			backup.Container.Devices[devName]["pool"] = poolName
-
 		}
 
 		if backup.Container.ExpandedDevices != nil {
 			devName, _, err := shared.GetRootDiskDevice(backup.Container.ExpandedDevices)
-			if err != nil {
-				return err
+			if err == nil {
+				backup.Container.ExpandedDevices[devName]["pool"] = poolName
+				rootDiskDeviceFound = true
 			}
+		}
 
-			backup.Container.ExpandedDevices[devName]["pool"] = poolName
+		if !rootDiskDeviceFound {
+			return fmt.Errorf("No root device could be found")
 		}
 
 		file, err := os.Create(path)


More information about the lxc-devel mailing list