[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lxc-devel
Subject:    [lxc-devel] [lxd/master] lxc/list: Reduce number of API calls
From:       stgraber on Github <lxc-bot () linuxcontainers ! org>
Date:       2018-04-26 17:27:12
Message-ID: 20180426172712.C74F75561B () mailman01 ! srv ! dcmtl ! stgraber ! net
[Download RAW message or body]

[Attachment #2 (text/x-mailbox)]

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 <stgraber@ubuntu.com>

[Attachment #3 (text/plain)]

From 905d24aa8216832a84b02737f3fd2bcd440b765b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stéphane Graber?= <stgraber@ubuntu.com>
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 <stgraber@ubuntu.com>
---
 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) {


[Attachment #4 (text/plain)]

_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic