[lxc-devel] [lxd/master] Add socket number to resources API

stgraber on Github lxc-bot at linuxcontainers.org
Wed Mar 13 23:54:34 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 567 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190313/d2283268/attachment.bin>
-------------- next part --------------
From f3ce3ac849af23ba06ce59fb1bb7f73cbea41ba4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 13 Mar 2019 19:05:08 -0400
Subject: [PATCH 1/4] shared/api: Add CPU socket to resources
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>
---
 shared/api/resource.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/shared/api/resource.go b/shared/api/resource.go
index 93a1104502..b0b6b76c61 100644
--- a/shared/api/resource.go
+++ b/shared/api/resource.go
@@ -16,6 +16,9 @@ type ResourcesCPUSocket struct {
 	Name           string `json:"name,omitempty" yaml:"name,omitempty"`
 	Vendor         string `json:"vendor,omitempty" yaml:"vendor,omitempty"`
 	Threads        uint64 `json:"threads" yaml:"threads"`
+
+	// API extension: resources_socket
+	Socket         uint64 `json:"socket" yaml:"socket"`
 }
 
 // ResourcesCPU represents the cpu resources available on the system

From 2116ff1c3217dae9c6eab015d943b8bbd038e1cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 13 Mar 2019 19:08:13 -0400
Subject: [PATCH 2/4] api: Add resources_socket API extension
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>
---
 doc/api-extensions.md | 3 +++
 shared/version/api.go | 1 +
 2 files changed, 4 insertions(+)

diff --git a/doc/api-extensions.md b/doc/api-extensions.md
index ab31de6d55..350fcd8e5c 100644
--- a/doc/api-extensions.md
+++ b/doc/api-extensions.md
@@ -698,3 +698,6 @@ snapshot's expiry at creation time.
 Introductes a "Location" field in the leases list.
 This is used when querying a cluster to show what node a particular
 lease was found on.
+
+## resources\_socket
+Add Socket field to CPU resources in case we get out of order socket information.
diff --git a/shared/version/api.go b/shared/version/api.go
index 81f5b67f79..505d9f9a68 100644
--- a/shared/version/api.go
+++ b/shared/version/api.go
@@ -140,6 +140,7 @@ var APIExtensions = []string{
 	"container_backup_override_pool",
 	"snapshot_expiry_creation",
 	"network_leases_location",
+	"resources_socket",
 }
 
 // APIExtensionsCount returns the number of available API extensions.

From aac3b50c0e692df7072d5dfdb11ead011c747b20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 13 Mar 2019 19:08:48 -0400
Subject: [PATCH 3/4] lxd/resources: Export Socket number
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/util/resources.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lxd/util/resources.go b/lxd/util/resources.go
index 0fef6955b4..330a98ae89 100644
--- a/lxd/util/resources.go
+++ b/lxd/util/resources.go
@@ -256,6 +256,7 @@ func CPUResource() (*api.ResourcesCPU, error) {
 			cur = &c.Sockets[v.socketID]
 		}
 
+		cur.Socket = v.socketID
 		cur.Threads++
 		cur.Name = v.name
 		cur.Vendor = v.vendor

From 301c70c73beba485c8dd78f77aa3ce071e87ef01 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 13 Mar 2019 19:49:41 -0400
Subject: [PATCH 4/4] lxc/info: Use socket information
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>
---
 lxc/info.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lxc/info.go b/lxc/info.go
index 008b514e6e..dc61953a82 100644
--- a/lxc/info.go
+++ b/lxc/info.go
@@ -122,8 +122,8 @@ func (c *cmdInfo) remoteInfo(d lxd.ContainerServer) error {
 			renderCPU(resources.CPU.Sockets[0], "  ")
 		} else if len(resources.CPU.Sockets) > 1 {
 			fmt.Printf(i18n.G("CPUs:") + "\n")
-			for id, cpu := range resources.CPU.Sockets {
-				fmt.Printf("  "+i18n.G("Socket %d:")+"\n", id)
+			for _, cpu := range resources.CPU.Sockets {
+				fmt.Printf("  "+i18n.G("Socket %d:")+"\n", cpu.Socket)
 				renderCPU(cpu, "    ")
 			}
 		}


More information about the lxc-devel mailing list