[lxc-devel] [lxd/master] lxd: Ensure all use of db.InstanceFilter defines instance type
tomponline on Github
lxc-bot at linuxcontainers.org
Mon Sep 21 15:24:18 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 436 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200921/009f2a5c/attachment.bin>
-------------- next part --------------
From 7a408f07b9b002e0a35373d392f8977d044582b0 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 21 Sep 2020 16:22:37 +0100
Subject: [PATCH] lxd: Ensure all use of db.InstanceFilter defines instance
type
To avoid unexpectedly only filtering for container types.
Fixes 7897
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/db/instances.go | 4 +++-
lxd/project/permissions.go | 5 ++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lxd/db/instances.go b/lxd/db/instances.go
index d05267cb40..4a17a53e71 100644
--- a/lxd/db/instances.go
+++ b/lxd/db/instances.go
@@ -324,7 +324,9 @@ SELECT instances.name, nodes.id, nodes.address, nodes.heartbeat
// Load all instances across all projects and expands their config and devices
// using the profiles they are associated to.
func (c *ClusterTx) instanceListExpanded() ([]Instance, error) {
- instances, err := c.GetInstances(InstanceFilter{})
+ instances, err := c.GetInstances(InstanceFilter{
+ Type: instancetype.Any,
+ })
if err != nil {
return nil, errors.Wrap(err, "Load instances")
}
diff --git a/lxd/project/permissions.go b/lxd/project/permissions.go
index c24bed6ed6..8a238d25ba 100644
--- a/lxd/project/permissions.go
+++ b/lxd/project/permissions.go
@@ -854,7 +854,10 @@ func fetchProject(tx *db.ClusterTx, projectName string, skipIfNoLimits bool) (*p
return nil, errors.Wrap(err, "Fetch profiles from database")
}
- instances, err := tx.GetInstances(db.InstanceFilter{Project: projectName})
+ instances, err := tx.GetInstances(db.InstanceFilter{
+ Type: instancetype.Any,
+ Project: projectName,
+ })
if err != nil {
return nil, errors.Wrap(err, "Fetch project instances from database")
}
More information about the lxc-devel
mailing list