Merge ~ltrager/maas:lp1878923_lp1878685 into maas:master

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: e92ccb39d681fdb00906faf882c5af0b9fbb2057
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1878923_lp1878685
Merge into: maas:master
Diff against target: 101 lines (+46/-10)
3 files modified
src/machine-resources/src/machine-resources/Gopkg.lock (+2/-1)
src/metadataserver/builtin_scripts/hooks.py (+8/-9)
src/metadataserver/builtin_scripts/tests/test_hooks.py (+36/-0)
Reviewer Review Type Date Requested Status
Dougal Matthews (community) Approve
MAAS Lander Approve
Review via email: mp+384202@code.launchpad.net

Commit message

LP: #1878923, #1878685 - Fix incorrect memory detection.

LXD was only detecting the amount of available memory in user space.
Memory reserved by the kernel was not shown as available. This caused MAAS
to show slightly less RAM then the system actually had.

MAAS was assuming that a NUMA node always had memory assigned to it. When
0 memory was assigned to a node commissioning would raise an exception and
fail.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1878923_lp1878685 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 5c22723945be2ffa8359f9d50569030cf2fb93fd

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1878923_lp1878685 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: e92ccb39d681fdb00906faf882c5af0b9fbb2057

review: Approve
Revision history for this message
Dougal Matthews (d0ugal) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/machine-resources/src/machine-resources/Gopkg.lock b/src/machine-resources/src/machine-resources/Gopkg.lock
index e4b0113..6c2f652 100644
--- a/src/machine-resources/src/machine-resources/Gopkg.lock
+++ b/src/machine-resources/src/machine-resources/Gopkg.lock
@@ -24,9 +24,10 @@
24 revision = "3fe23663418fc1d724868c84f21b7519bbac7441"24 revision = "3fe23663418fc1d724868c84f21b7519bbac7441"
2525
26[[projects]]26[[projects]]
27 branch = "master"
27 name = "github.com/lxc/lxd"28 name = "github.com/lxc/lxd"
28 packages = ["lxd/resources","shared","shared/api","shared/cancel","shared/ioprogress","shared/logger","shared/osarch","shared/units","shared/usbid","shared/version"]29 packages = ["lxd/resources","shared","shared/api","shared/cancel","shared/ioprogress","shared/logger","shared/osarch","shared/units","shared/usbid","shared/version"]
29 version = "lxd-4.0.1"30 revision = "7516f0a2968b025efd1ea5066e78b16d6646b1c8"
3031
31[[projects]]32[[projects]]
32 name = "github.com/mitchellh/go-homedir"33 name = "github.com/mitchellh/go-homedir"
diff --git a/src/metadataserver/builtin_scripts/hooks.py b/src/metadataserver/builtin_scripts/hooks.py
index a65d06a..76c2614 100644
--- a/src/metadataserver/builtin_scripts/hooks.py
+++ b/src/metadataserver/builtin_scripts/hooks.py
@@ -438,7 +438,7 @@ def _process_lxd_resources(node, data):
438 data438 data
439 )439 )
440 # Update memory.440 # Update memory.
441 node.memory, numa_nodes = _parse_memory(data, numa_nodes)441 node.memory, numa_nodes = _parse_memory(data.get("memory", {}), numa_nodes)
442442
443 # Create or update NUMA nodes.443 # Create or update NUMA nodes.
444 numa_nodes = [444 numa_nodes = [
@@ -470,17 +470,16 @@ def _process_lxd_resources(node, data):
470 _process_system_information(node, data.get("system", {}))470 _process_system_information(node, data.get("system", {}))
471471
472472
473def _parse_memory(data, numa_nodes):473def _parse_memory(memory, numa_nodes):
474 total_memory = data.get("memory", {}).get("total", 0)474 total_memory = memory.get("total", 0)
475 default_numa_node = {"numa_node": 0, "total": total_memory}475 default_numa_node = {"numa_node": 0, "total": total_memory}
476 for memory_node in data.get("memory", {}).get(476
477 "nodes", [default_numa_node]477 for memory_node in memory.get("nodes", [default_numa_node]):
478 ):478 numa_nodes[memory_node["numa_node"]]["memory"] = int(
479 numa_nodes[memory_node["numa_node"]]["memory"] = (479 memory_node.get("total", 0) / 1024 ** 2
480 memory_node["total"] / 1024 / 1024
481 )480 )
482481
483 return total_memory / 1024 / 1024, numa_nodes482 return int(total_memory / 1024 ** 2), numa_nodes
484483
485484
486def get_tags_from_block_info(block_info):485def get_tags_from_block_info(block_info):
diff --git a/src/metadataserver/builtin_scripts/tests/test_hooks.py b/src/metadataserver/builtin_scripts/tests/test_hooks.py
index dfc7d89..de3424a 100644
--- a/src/metadataserver/builtin_scripts/tests/test_hooks.py
+++ b/src/metadataserver/builtin_scripts/tests/test_hooks.py
@@ -1412,6 +1412,42 @@ class TestProcessLXDResults(MAASServerTestCase):
1412 for numa_node in numa_nodes:1412 for numa_node in numa_nodes:
1413 self.assertEqual(int(total_memory / 1024 / 1024), numa_node.memory)1413 self.assertEqual(int(total_memory / 1024 / 1024), numa_node.memory)
14141414
1415 def test__accepts_numa_node_zero_memory(self):
1416 # Regression test for LP:1878923
1417 node = factory.make_Node()
1418 self.patch(hooks_module, "update_node_network_information")
1419 data = make_lxd_output()
1420 data["resources"]["memory"] = {
1421 "nodes": [
1422 {
1423 "numa_node": 0,
1424 "hugepages_used": 0,
1425 "hugepages_total": 0,
1426 "used": 1314131968,
1427 "total": 33720463360,
1428 },
1429 {
1430 "numa_node": 1,
1431 "hugepages_used": 0,
1432 "hugepages_total": 0,
1433 "used": 0,
1434 "total": 0,
1435 },
1436 ],
1437 "hugepages_total": 0,
1438 "hugepages_used": 0,
1439 "hugepages_size": 2097152,
1440 "used": 602902528,
1441 "total": 33720463360,
1442 }
1443
1444 process_lxd_results(node, json.dumps(data).encode(), 0)
1445
1446 self.assertEquals(32158, node.memory)
1447 self.assertItemsEqual(
1448 [32158, 0], [numa.memory for numa in node.numanode_set.all()]
1449 )
1450
1415 def test__updates_cpu_numa_nodes(self):1451 def test__updates_cpu_numa_nodes(self):
1416 node = factory.make_Node()1452 node = factory.make_Node()
1417 self.patch(hooks_module, "update_node_network_information")1453 self.patch(hooks_module, "update_node_network_information")

Subscribers

People subscribed via source and target branches