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

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) ===
Signed-off-by: Stéphane Graber <[email protected]>
From 905d24aa8216832a84b02737f3fd2bcd440b765b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]>
Date: Thu, 26 Apr 2018 13:26:51 -0400
Subject: [PATCH] lxc/list: Reduce number of API calls
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <[email protected]>
---
 lxc/list.go | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/lxc/list.go b/lxc/list.go
index a4d590bf1..68b497e29 100644
--- a/lxc/list.go
+++ b/lxc/list.go
@@ -201,7 +201,7 @@ func (c *cmdList) shouldShow(filters []string, state 
*api.Container) bool {
        return true
 }
 
-func (c *cmdList) listContainers(conf *config.Config, remote string, cinfos 
[]api.Container, filters []string, columns []column) error {
+func (c *cmdList) listContainers(conf *config.Config, d lxd.ContainerServer, 
cinfos []api.Container, filters []string, columns []column) error {
        headers := []string{}
        for _, column := range columns {
                headers = append(headers, column.Name)
@@ -225,22 +225,12 @@ func (c *cmdList) listContainers(conf *config.Config, 
remote string, cinfos []ap
        for i := 0; i < threads; i++ {
                cStatesWg.Add(1)
                go func() {
-                       var d lxd.ContainerServer
-                       var err error
                        for {
                                cName, more := <-cStatesQueue
                                if !more {
                                        break
                                }
 
-                               if d == nil {
-                                       d, err = conf.GetContainerServer(remote)
-                                       if err != nil {
-                                               cStatesWg.Done()
-                                               return
-                                       }
-                               }
-
                                state, _, err := d.GetContainerState(cName)
                                if err != nil {
                                        continue
@@ -255,23 +245,12 @@ func (c *cmdList) listContainers(conf *config.Config, 
remote string, cinfos []ap
 
                cSnapshotsWg.Add(1)
                go func() {
-                       var d lxd.ContainerServer
-                       var err error
                        for {
                                cName, more := <-cSnapshotsQueue
                                if !more {
                                        break
                                }
 
-                               if d == nil {
-                                       d, err = conf.GetContainerServer(remote)
-                                       if err != nil {
-                                               cSnapshotsWg.Done()
-                                               return
-                                       }
-
-                               }
-
                                snaps, err := d.GetContainerSnapshots(cName)
                                if err != nil {
                                        continue
@@ -460,7 +439,7 @@ func (c *cmdList) Run(cmd *cobra.Command, args []string) 
error {
        }
 
        // Fetch any remaining data and render the table
-       return c.listContainers(conf, remote, cts, filters, columns)
+       return c.listContainers(conf, d, cts, filters, columns)
 }
 
 func (c *cmdList) parseColumns(clustered bool) ([]column, error) {
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to