[lxc-devel] [lxd/master] Fix placement in cluster for foreign arch

stgraber on Github lxc-bot at linuxcontainers.org
Wed Jun 24 22:06:30 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200624/09908229/attachment.bin>
-------------- next part --------------
From cf0a8fbccd441902431628427f877ac39eabbdc1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at 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 <stgraber at 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?= <stgraber at 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 <stgraber at 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)


More information about the lxc-devel mailing list