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

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) ===

From cf0a8fbccd441902431628427f877ac39eabbdc1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 24 Jun 2020 17:43:39 -0400
Subject: [PATCH 1/2] lxd/db: Consider personalities in
 GetNodeWithLeastInstances
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/db/node.go | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/lxd/db/node.go b/lxd/db/node.go
index 5d74420109..1e22920877 100644
--- a/lxd/db/node.go
+++ b/lxd/db/node.go
@@ -641,8 +641,29 @@ func (c *ClusterTx) GetNodeWithLeastInstances(archs []int) 
(string, error) {
                        continue
                }
 
-               if len(archs) > 0 && !shared.IntInSlice(node.Architecture, 
archs) {
-                       continue
+               if len(archs) > 0 {
+                       // Get personalities too.
+                       personalities, err := 
osarch.ArchitecturePersonalities(node.Architecture)
+                       if err != nil {
+                               return "", err
+                       }
+
+                       supported := []int{node.Architecture}
+                       supported = append(supported, personalities...)
+
+                       match := false
+                       fmt.Printf("stgraber: supported=%v requested=%v\n", 
supported, archs)
+                       for _, entry := range supported {
+                               if shared.IntInSlice(entry, archs) {
+                                       fmt.Printf("stgraber: supported\n")
+                                       match = true
+                               }
+                       }
+
+                       if !match {
+                               fmt.Printf("stgraber: unsupported\n")
+                               continue
+                       }
                }
 
                // Fetch the number of containers already created on this node.

From 8bc058e036b09460f224fc4b74c2ceae9ee5d9a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 24 Jun 2020 18:01:09 -0400
Subject: [PATCH 2/2] lxd/db: Avoid test failure in arch matching
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/db/node_test.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lxd/db/node_test.go b/lxd/db/node_test.go
index f111fd3998..99c1c47f34 100644
--- a/lxd/db/node_test.go
+++ b/lxd/db/node_test.go
@@ -372,7 +372,12 @@ func TestGetNodeWithLeastInstances_Architecture(t 
*testing.T) {
        localArch, err := osarch.ArchitectureGetLocalID()
        require.NoError(t, err)
 
-       _, err = tx.CreateNodeWithArch("buzz", "1.2.3.4:666", localArch+1)
+       testArch := osarch.ARCH_64BIT_S390_BIG_ENDIAN
+       if localArch == testArch {
+               testArch = osarch.ARCH_64BIT_INTEL_X86
+       }
+
+       _, err = tx.CreateNodeWithArch("buzz", "1.2.3.4:666", testArch)
        require.NoError(t, err)
 
        // Add a container to the default node (ID 1)
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to