[lxc-devel] [lxd/master] Device: Only validate disk source pool when an actual instance is set

tomponline on Github lxc-bot at linuxcontainers.org
Thu Nov 26 14:45:50 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 454 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201126/a4bcb62f/attachment.bin>
-------------- next part --------------
From 3b3590cfab36b727ec2d63e72308c8295d7254f2 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 26 Nov 2020 14:44:04 +0000
Subject: [PATCH] lxd/device/disk: Only validate disk source pool when an
 actual instance is set

Allows for migration of instances who have snapshots with invalid devices.

Fixes #8187

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/device/disk.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/device/disk.go b/lxd/device/disk.go
index da29808a40..8c405aecbc 100644
--- a/lxd/device/disk.go
+++ b/lxd/device/disk.go
@@ -170,7 +170,7 @@ func (d *disk) validateConfig(instConf instance.ConfigReader) error {
 
 		// Only perform expensive instance custom volume checks when not validating a profile and after
 		// device expansion has occurred (to avoid doing it twice during instance load).
-		if instConf.Type() != instancetype.Any && len(instConf.ExpandedDevices()) > 0 && d.config["source"] != "" && d.config["path"] != "/" {
+		if d.inst != nil && len(instConf.ExpandedDevices()) > 0 && d.config["source"] != "" && d.config["path"] != "/" {
 			poolID, err := d.state.Cluster.GetStoragePoolID(d.config["pool"])
 			if err != nil {
 				return fmt.Errorf("The %q storage pool doesn't exist", d.config["pool"])


More information about the lxc-devel mailing list