Merge lp:~allenap/maas/ns-tags-commissioning--bug-1255479--port-to-1.4 into lp:maas/1.4

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 1714
Proposed branch: lp:~allenap/maas/ns-tags-commissioning--bug-1255479--port-to-1.4
Merge into: lp:maas/1.4
Diff against target: 97 lines (+7/-49)
3 files modified
docs/development/tagging.rst (+7/-19)
src/metadataserver/models/commissioningscript.py (+0/-8)
src/metadataserver/models/tests/test_commissioningscript.py (+0/-22)
To merge this branch: bzr merge lp:~allenap/maas/ns-tags-commissioning--bug-1255479--port-to-1.4
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+197388@code.launchpad.net

Commit message

Backport trunk r1751: Don't recalculate tags in update_hardware_details(); only do it when commissioning finishes.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :
review: Approve
Revision history for this message
Gavin Panella (allenap) wrote :

Merged by hand; lander not operational.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/development/tagging.rst'
2--- docs/development/tagging.rst 2013-10-01 10:35:02 +0000
3+++ docs/development/tagging.rst 2013-12-02 14:37:37 +0000
4@@ -60,27 +60,15 @@
5 New or updated commissioning result
6 -----------------------------------
7
8-When a new commissioning result comes in containing ``lshw`` XML
9-output, every tag with an expression must be evaluated against the
10+When a new commissioning result comes in containing ``lshw`` or ``lldp``
11+XML output, every tag with an expression must be evaluated against the
12 result so that the node is correctly tagged.
13
14-To do this, ``maasserver.models.node.update_hardware_details`` is
15-called. This happens in the **region**. While it's a computationally
16-expensive operation, the overhead of spinning this work out to a
17-cluster controller negates any benefit that might gained by doing so.
18-
19-This:
20-
21-#. Saves the raw ``lshw`` XML.
22-
23-#. Extracts CPU, memory, and storage numbers from the hardware
24- information, and saves these. This does not affect tag processing,
25- but it's worth knowing that the first-class constraint axes that
26- are exposed via the ``acquire()`` API call are derived from the
27- same source as tag expressions consume.
28-
29-#. Evaluates each tag expression and updates the node's tags as
30- appropriate.
31+To do this, ``maasserver.api.VersionIndexHandler.signal`` calls
32+``populate_tags_for_single_node`` just before saving all the changes.
33+This happens in the **region**. While it's a computationally expensive
34+operation, the overhead of spinning this work out to a cluster
35+controller negates any benefit that might gained by doing so.
36
37
38 Manual tags, or tags without expressions
39
40=== modified file 'src/metadataserver/models/commissioningscript.py'
41--- src/metadataserver/models/commissioningscript.py 2013-10-09 20:28:02 +0000
42+++ src/metadataserver/models/commissioningscript.py 2013-12-02 14:37:37 +0000
43@@ -167,14 +167,6 @@
44 node.cpu_count = cpu_count or 0
45 node.memory = memory
46 node.storage = storage
47- for tag in Tag.objects.all():
48- if not tag.definition:
49- continue
50- has_tag = evaluator(tag.definition)
51- if has_tag:
52- node.tags.add(tag)
53- else:
54- node.tags.remove(tag)
55 node.save()
56
57
58
59=== modified file 'src/metadataserver/models/tests/test_commissioningscript.py'
60--- src/metadataserver/models/tests/test_commissioningscript.py 2013-10-09 22:32:55 +0000
61+++ src/metadataserver/models/tests/test_commissioningscript.py 2013-12-02 14:37:37 +0000
62@@ -39,7 +39,6 @@
63 from maasserver.testing import reload_object
64 from maasserver.testing.factory import factory
65 from maasserver.testing.testcase import MAASServerTestCase
66-from maasserver.utils import ignore_unused
67 from maastesting.matchers import ContainsAll
68 from maastesting.utils import sample_binary_data
69 from metadataserver.fields import Bin
70@@ -512,27 +511,6 @@
71 expected = (4294967296 + 3221225472 + 536879812) / mega
72 self.assertEqual(expected, node.memory)
73
74- def test_hardware_updates_tags_match(self):
75- tag1 = factory.make_tag(factory.getRandomString(10), "/node")
76- tag2 = factory.make_tag(factory.getRandomString(10), "//node")
77- node = factory.make_node()
78- xmlbytes = '<node/>'.encode("utf-8")
79- update_hardware_details(node, xmlbytes, 0)
80- node = reload_object(node)
81- self.assertEqual([tag1, tag2], list(node.tags.all()))
82-
83- def test_hardware_updates_tags_no_match(self):
84- tag1 = factory.make_tag(factory.getRandomString(10), "/missing")
85- ignore_unused(tag1)
86- tag2 = factory.make_tag(factory.getRandomString(10), "/nothing")
87- node = factory.make_node()
88- node.tags = [tag2]
89- node.save()
90- xmlbytes = '<node/>'.encode("utf-8")
91- update_hardware_details(node, xmlbytes, 0)
92- node = reload_object(node)
93- self.assertEqual([], list(node.tags.all()))
94-
95 def test_hardware_updates_ignores_empty_tags(self):
96 # Tags with empty definitions are ignored when
97 # update_hardware_details gets called.

Subscribers

People subscribed via source and target branches

to all changes: