[lxc-devel] [lxd/master] lxd/db/instances: Ensure correct pool name is returned in GetInstancePool

tomponline on Github lxc-bot at linuxcontainers.org
Thu Aug 20 15:34:44 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 678 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200820/023d30d0/attachment.bin>
-------------- next part --------------
From 6dd0893c021b3ac5ec077cc56e4cc9274ceb4a62 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 20 Aug 2020 16:31:35 +0100
Subject: [PATCH] lxd/db/instances: Ensure correct pool name is returned in
 GetInstancePool

This fixes an issue when:

 - Two storage pools
 - Two projects
 - Instance called `c1` is created in first project and storage pool
 - Instance called `c1` is created in second project and storage pool

This breaks because this function returns the name of the first storage pool for the second container.

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/db/instances.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lxd/db/instances.go b/lxd/db/instances.go
index 20a0a1d80c..b4362c4d11 100644
--- a/lxd/db/instances.go
+++ b/lxd/db/instances.go
@@ -677,6 +677,7 @@ SELECT storage_pools.name FROM storage_pools
    AND storage_volumes_all.node_id=?
    AND storage_volumes_all.name=?
    AND storage_volumes_all.type IN(?,?)
+   AND storage_volumes_all.project_id = instances.project_id
 `
 	inargs := []interface{}{project, c.nodeID, instanceName, StoragePoolVolumeTypeContainer, StoragePoolVolumeTypeVM}
 	outargs := []interface{}{&poolName}


More information about the lxc-devel mailing list