[lxc-devel] [lxd/master] lxd/storage/pools: Improves delete pool error info

tomponline on Github lxc-bot at linuxcontainers.org
Thu May 21 08:01:56 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 581 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200521/4948ab7e/attachment.bin>
-------------- next part --------------
From cf5900aec46790458d2631d0b711d74883a63faa Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 21 May 2020 09:00:33 +0100
Subject: [PATCH] lxd/storage/pools: Improves delete pool error info

When a storage pool has image volumes in the database but the image record itself has been deleted, trying to delete the storage pool results in cryptic "not found" errors.

This improves the context of the errors.

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/storage_pools.go | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lxd/storage_pools.go b/lxd/storage_pools.go
index ca4a838e1a..6241441bbc 100644
--- a/lxd/storage_pools.go
+++ b/lxd/storage_pools.go
@@ -8,6 +8,7 @@ import (
 	"sync"
 
 	"github.com/gorilla/mux"
+	"github.com/pkg/errors"
 
 	lxd "github.com/lxc/lxd/client"
 	"github.com/lxc/lxd/lxd/cluster"
@@ -557,8 +558,7 @@ func storagePoolDelete(d *Daemon, r *http.Request) response.Response {
 		}
 	}
 
-	// Check if the pool is pending, if so we just need to delete it from
-	// the database.
+	// Check if the pool is pending, if so we just need to delete it from the database.
 	_, dbPool, err := d.cluster.GetStoragePool(poolName)
 	if err != nil {
 		return response.SmartError(err)
@@ -579,7 +579,7 @@ func storagePoolDelete(d *Daemon, r *http.Request) response.Response {
 
 	pool, err := storagePools.GetPoolByName(d.State(), poolName)
 	if err != nil {
-		return response.InternalError(err)
+		return response.InternalError(errors.Wrapf(err, "Error loading pool %q", poolName))
 	}
 
 	// Only delete images if locally stored or running on initial member.
@@ -587,12 +587,12 @@ func storagePoolDelete(d *Daemon, r *http.Request) response.Response {
 		for _, volume := range volumeNames {
 			_, imgInfo, err := d.cluster.GetImage(projectParam(r), volume, false, false)
 			if err != nil {
-				return response.InternalError(err)
+				return response.InternalError(errors.Wrapf(err, "Failed getting image info for %q", volume))
 			}
 
 			err = doDeleteImageFromPool(d.State(), imgInfo.Fingerprint, poolName)
 			if err != nil {
-				return response.InternalError(err)
+				return response.InternalError(errors.Wrapf(err, "Error deleting image %q from pool", volume))
 			}
 		}
 	}


More information about the lxc-devel mailing list