[lxc-devel] [lxd/master] lxd/storage: Better handle broken volumes
stgraber on Github
lxc-bot at linuxcontainers.org
Thu Jun 25 19:36:46 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200625/35093343/attachment.bin>
-------------- next part --------------
From 83cbe4880b3578be47e7c29da2b4ca0b1039136d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 25 Jun 2020 15:35:02 -0400
Subject: [PATCH] lxd/storage: Better handle broken volumes
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/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 2a2cb7873d..037648d86d 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -2071,7 +2071,14 @@ func (b *lxdBackend) EnsureImage(fingerprint string, op *operations.Operation) e
// Check if we already have a suitable volume on storage device.
if b.driver.HasVolume(imgVol) {
- return nil
+ if imgDBVol != nil {
+ // We already have a valid volume, just return.
+ return nil
+ }
+
+ // We somehow have an unrecorded on-disk volume, assume it's a partial unpack and delete it.
+ logger.Warn("Deleting leftover/partially unpacked image volume")
+ b.driver.DeleteVolume(imgVol, op)
}
volFiller := drivers.VolumeFiller{
More information about the lxc-devel
mailing list