The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6593

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
We're dealing with a single namespace for both containers and VMs, so we
need to extract the combined list.

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From b85ca4b42de28851e16972bd4c4d49fb847b94a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 11 Dec 2019 16:38:29 -0500
Subject: [PATCH] lxd/db: Rename ContainerNames to InstanceNames
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We're dealing with a single namespace for both containers and VMs, so we
need to extract the combined list.

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/containers_post.go | 5 +++--
 lxd/db/containers.go   | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index ab9daf5544..d2d78fcf63 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -876,7 +876,7 @@ func containersPost(d *Daemon, r *http.Request) 
response.Response {
                var names []string
                err := d.cluster.Transaction(func(tx *db.ClusterTx) error {
                        var err error
-                       names, err = tx.ContainerNames(project)
+                       names, err = tx.InstanceNames(project)
                        return err
                })
                if err != nil {
@@ -892,9 +892,10 @@ func containersPost(d *Daemon, r *http.Request) 
response.Response {
                        }
 
                        if i > 100 {
-                               return 
response.InternalError(fmt.Errorf("couldn't generate a new unique name after 
100 tries"))
+                               return 
response.InternalError(fmt.Errorf("Couldn't generate a new unique name after 
100 tries"))
                        }
                }
+
                logger.Debugf("No name provided, creating %s", req.Name)
        }
 
diff --git a/lxd/db/containers.go b/lxd/db/containers.go
index dd9b8e4644..351a37b6ab 100644
--- a/lxd/db/containers.go
+++ b/lxd/db/containers.go
@@ -170,14 +170,14 @@ type InstanceBackupArgs struct {
        CompressionAlgorithm string
 }
 
-// ContainerNames returns the names of all containers the given project.
-func (c *ClusterTx) ContainerNames(project string) ([]string, error) {
+// InstanceNames returns the names of all containers the given project.
+func (c *ClusterTx) InstanceNames(project string) ([]string, error) {
        stmt := `
 SELECT instances.name FROM instances
   JOIN projects ON projects.id = instances.project_id
   WHERE projects.name = ? AND instances.type = ?
 `
-       return query.SelectStrings(c.tx, stmt, project, instancetype.Container)
+       return query.SelectStrings(c.tx, stmt, project, instancetype.Any)
 }
 
 // ContainerNodeAddress returns the address of the node hosting the container
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to