Merge ~newell-jensen/maas:lp1828310 into maas:master

Proposed by Newell Jensen
Status: Merged
Approved by: Newell Jensen
Approved revision: 854cd754bc5384cf8f7c8d5243a9fc0accafe598
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~newell-jensen/maas:lp1828310
Merge into: maas:master
Diff against target: 100 lines (+39/-11)
2 files modified
src/metadataserver/api_twisted.py (+5/-4)
src/metadataserver/tests/test_api_twisted.py (+34/-7)
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Blake Rouse (community) Approve
Review via email: mp+367703@code.launchpad.net

Commit message

LP: #1828310 -- Only log start and failure messages from cloud-init and curtin.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) :
review: Needs Information
Revision history for this message
Newell Jensen (newell-jensen) :
Revision history for this message
Blake Rouse (blake-rouse) :
~newell-jensen/maas:lp1828310 updated
0c315aa... by Newell Jensen

Review fixes.

Revision history for this message
Newell Jensen (newell-jensen) wrote :

Updated to use the original tests with 'start'. My previous changes didn't nullify the tests, it just took out the events that were no longer being created, however this shows that the previous tests also work with 'start' and that the events are created.

Revision history for this message
Blake Rouse (blake-rouse) wrote :

Thanks for the fixes.

review: Approve
Revision history for this message
Lee Trager (ltrager) wrote :

Looks good one small suggestion. maasserver.preseed defines CURTIN_INSTALL_LOG as /tmp/install.log. I would use that instead of hard coding it instead we ever need to change the location.

review: Approve
~newell-jensen/maas:lp1828310 updated
854cd75... by Newell Jensen

Replace /tmp/install.log with CURTIN_INSTALL_LOG

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/metadataserver/api_twisted.py b/src/metadataserver/api_twisted.py
2index 9b30d89..e1d5ded 100644
3--- a/src/metadataserver/api_twisted.py
4+++ b/src/metadataserver/api_twisted.py
5@@ -306,10 +306,11 @@ class StatusWorkerService(TimerService, object):
6 failed = result in ['FAIL', 'FAILURE']
7 default_exit_status = 1 if failed else 0
8
9- # Add this event to the node event log.
10- add_event_to_node_event_log(
11- node, origin, activity_name, description, event_type, result,
12- message['timestamp'])
13+ # Add this event to the node event log if 'start' or a 'failure'.
14+ if event_type == 'start' or failed:
15+ add_event_to_node_event_log(
16+ node, origin, activity_name, description, event_type, result,
17+ message['timestamp'])
18
19 # Group files together with the ScriptResult they belong.
20 results = {}
21diff --git a/src/metadataserver/tests/test_api_twisted.py b/src/metadataserver/tests/test_api_twisted.py
22index 81b6fbf..4c2add2 100644
23--- a/src/metadataserver/tests/test_api_twisted.py
24+++ b/src/metadataserver/tests/test_api_twisted.py
25@@ -376,6 +376,22 @@ class TestStatusWorkerService(MAASServerTestCase):
26 worker = StatusWorkerService(sentinel.dbtasks)
27 return worker._processMessage(node, payload)
28
29+ def test_process_message_logs_event_for_start_event_type(self):
30+ node = factory.make_Node(
31+ status=NODE_STATUS.DEPLOYING, with_empty_script_sets=True)
32+ payload = {
33+ 'event_type': 'start',
34+ 'origin': 'curtin',
35+ 'name': 'cmd-install',
36+ 'description': 'Installation has started.',
37+ 'timestamp': datetime.utcnow(),
38+ }
39+ self.processMessage(node, payload)
40+ event = Event.objects.last()
41+ self.assertEqual(
42+ event.description,
43+ CURTIN_INSTALL_LOG + " changed status from 'Pending' to 'Running'")
44+
45 def test_process_message_returns_false_when_node_deleted(self):
46 node1 = factory.make_Node(status=NODE_STATUS.DEPLOYING)
47 node1.delete()
48@@ -390,10 +406,15 @@ class TestStatusWorkerService(MAASServerTestCase):
49 self.assertFalse(self.processMessage(node1, payload))
50
51 def test_status_installation_result_does_not_affect_other_node(self):
52- node1 = factory.make_Node(status=NODE_STATUS.DEPLOYING)
53+ node1 = factory.make_Node(
54+ status=NODE_STATUS.DEPLOYING, with_empty_script_sets=True)
55 node2 = factory.make_Node(status=NODE_STATUS.DEPLOYING)
56+ script = factory.make_Script(may_reboot=True)
57+ factory.make_ScriptResult(
58+ script=script, script_set=node1.current_installation_script_set,
59+ status=SCRIPT_STATUS.RUNNING)
60 payload = {
61- 'event_type': 'finish',
62+ 'event_type': 'start',
63 'result': 'SUCCESS',
64 'origin': 'curtin',
65 'name': 'cmd-install',
66@@ -405,15 +426,21 @@ class TestStatusWorkerService(MAASServerTestCase):
67 NODE_STATUS.DEPLOYING, reload_object(node2).status)
68 # Check last node1 event.
69 self.assertEqual(
70- "'curtin' Command Install",
71+ CURTIN_INSTALL_LOG + " changed status from 'Pending' to 'Running'",
72 Event.objects.filter(node=node1).last().description)
73- # There must me no events for node2.
74+ # There must be no events for node2.
75 self.assertFalse(Event.objects.filter(node=node2).exists())
76
77 def test_status_installation_success_leaves_node_deploying(self):
78- node = factory.make_Node(interface=True, status=NODE_STATUS.DEPLOYING)
79+ node = factory.make_Node(
80+ interface=True, status=NODE_STATUS.DEPLOYING,
81+ with_empty_script_sets=True)
82+ script = factory.make_Script(may_reboot=True)
83+ factory.make_ScriptResult(
84+ script=script, script_set=node.current_installation_script_set,
85+ status=SCRIPT_STATUS.RUNNING)
86 payload = {
87- 'event_type': 'finish',
88+ 'event_type': 'start',
89 'result': 'SUCCESS',
90 'origin': 'curtin',
91 'name': 'cmd-install',
92@@ -424,7 +451,7 @@ class TestStatusWorkerService(MAASServerTestCase):
93 self.assertEqual(NODE_STATUS.DEPLOYING, reload_object(node).status)
94 # Check last node event.
95 self.assertEqual(
96- "'curtin' Command Install",
97+ "/tmp/install.log changed status from 'Pending' to 'Running'",
98 Event.objects.filter(node=node).last().description)
99
100 def test_status_commissioning_failure_leaves_node_failed(self):

Subscribers

People subscribed via source and target branches