[lxc-devel] [lxd/master] images: don't fail deleting when the storage delete fails

tych0 on Github lxc-bot at linuxcontainers.org
Thu May 5 19:03:49 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 597 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160505/38ba62e1/attachment.bin>
-------------- next part --------------
From ee5073ee12ef3e0baa6c3a5ed543d42d250a8055 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Thu, 5 May 2016 14:02:36 -0500
Subject: [PATCH] images: don't fail deleting when the storage delete fails

e.g. if someone deletes the zpool manually, they then can't delete an
image, because we can't detect the filesystem type for the path, because it
doesn't exist any more. Let's not fail so hard when we can't detect the
filesystem.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 lxd/images.go | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lxd/images.go b/lxd/images.go
index 632b753..5013787 100644
--- a/lxd/images.go
+++ b/lxd/images.go
@@ -911,12 +911,12 @@ func doDeleteImage(d *Daemon, fingerprint string) error {
 	// look at the path
 	s, err := storageForImage(d, imgInfo)
 	if err != nil {
-		return err
-	}
-
-	// Remove the image from storage backend
-	if err = s.ImageDelete(imgInfo.Fingerprint); err != nil {
-		return err
+		shared.Log.Error("error detecting image storage backend", log.Ctx{"fingerprint": imgInfo.Fingerprint, "err": err})
+	} else {
+		// Remove the image from storage backend
+		if err = s.ImageDelete(imgInfo.Fingerprint); err != nil {
+			shared.Log.Error("error deleting the image from storage backend", log.Ctx{"fingerprint": imgInfo.Fingerprint, "err": err})
+		}
 	}
 
 	// Remove main image file


More information about the lxc-devel mailing list