[lxc-devel] [lxd/master] lxd/storage: Pass config when deleting images

monstermunchkin on Github lxc-bot at linuxcontainers.org
Tue Jan 28 15:06:05 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 462 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200128/9fd1b5c0/attachment.bin>
-------------- next part --------------
From 056d48b6aaee68405ad916291406b285f3fa738e Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Tue, 28 Jan 2020 14:25:50 +0100
Subject: [PATCH] lxd/storage: Pass config when deleting images

When deleting images, some drivers need to know the config in order to
handle zombie volumes properly.

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 lxd/storage/backend_lxd.go | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go
index 82180a3b88..0ef9fb0c49 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -1997,7 +1997,14 @@ func (b *lxdBackend) DeleteImage(fingerprint string, op *operations.Operation) e
 		contentType = drivers.ContentTypeBlock
 	}
 
-	vol := b.newVolume(drivers.VolumeTypeImage, contentType, fingerprint, nil)
+	// Load the storage volume in order to get the volume config which is needed
+	// for some drivers.
+	_, storageVol, err := b.state.Cluster.StoragePoolNodeVolumeGetType(fingerprint, db.StoragePoolVolumeTypeImage, b.ID())
+	if err != nil {
+		return err
+	}
+
+	vol := b.newVolume(drivers.VolumeTypeImage, contentType, fingerprint, storageVol.Config)
 
 	err = b.driver.DeleteVolume(vol, op)
 	if err != nil {


More information about the lxc-devel mailing list