[lxc-devel] [lxd/master] storage: Count custom volumes in pool UsedBy
stgraber on Github
lxc-bot at linuxcontainers.org
Tue Aug 8 19:30:43 UTC 2017
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/20170808/98352a2a/attachment.bin>
-------------- next part --------------
From 06506a0e4a68d84fa775a13c44c878dba2238410 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 8 Aug 2017 15:30:19 -0400
Subject: [PATCH] storage: Count custom volumes in pool UsedBy
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_pools_utils.go | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lxd/storage_pools_utils.go b/lxd/storage_pools_utils.go
index 95761c4ff..e1f3100ec 100644
--- a/lxd/storage_pools_utils.go
+++ b/lxd/storage_pools_utils.go
@@ -81,7 +81,7 @@ func storagePoolUpdate(d *Daemon, name, newDescription string, newConfig map[str
// /1.0/profiles/default
func storagePoolUsedByGet(db *sql.DB, poolID int64, poolName string) ([]string, error) {
// Retrieve all non-custom volumes that exist on this storage pool.
- volumes, err := dbStoragePoolVolumesGet(db, poolID, []int{storagePoolVolumeTypeContainer, storagePoolVolumeTypeImage})
+ volumes, err := dbStoragePoolVolumesGet(db, poolID, []int{storagePoolVolumeTypeContainer, storagePoolVolumeTypeImage, storagePoolVolumeTypeCustom})
if err != nil && err != NoSuchObjectError {
return []string{}, err
}
@@ -112,8 +112,7 @@ func storagePoolUsedByGet(db *sql.DB, poolID int64, poolName string) ([]string,
case storagePoolVolumeAPIEndpointImages:
poolUsedBy[i] = fmt.Sprintf("/%s/images/%s", version.APIVersion, volumes[i].Name)
case storagePoolVolumeAPIEndpointCustom:
- // Bug
- return []string{}, fmt.Errorf("database function returned volume type \"%s\" although not queried for it", volumes[i].Type)
+ poolUsedBy[i] = fmt.Sprintf("/%s/storage-pools/%s/volumes/%s/%s", version.APIVersion, poolName, volumes[i].Type, volumes[i].Name)
default:
// If that happens the db is busted, so report an error.
return []string{}, fmt.Errorf("invalid storage type for storage volume \"%s\"", volumes[i].Name)
More information about the lxc-devel
mailing list