Merge lp:~jtv/maas/bug-987629 into lp:~maas-committers/maas/trunk

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 515
Proposed branch: lp:~jtv/maas/bug-987629
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 71 lines (+26/-2)
4 files modified
src/maasserver/fixtures/dev_fixture.yaml (+1/-1)
src/maasserver/forms.py (+9/-1)
src/maasserver/models/__init__.py (+5/-0)
src/maasserver/tests/test_views_nodes.py (+11/-0)
To merge this branch: bzr merge lp:~jtv/maas/bug-987629
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+103416@code.launchpad.net

Commit message

Allow admin to retry failed commissioning of a node.

Description of the change

There was nobody around to pre-imp this with, so I just went ahead and did the absolute minimum that bug 987629 required: if a node is in Failed Tests state, allow an admin to retry the commissioning process (e.g. after swapping out bad hardware or remembering to plug the machine into the network).

In order of diff:

In the sampledata, node “moon” was in state Failed Tests but had an owner. This is unrealistic. A node in this state does not have an owner. (And thus, it can be deleted which makes a lot of sense!)

In NODE_ACTIONS, I added the retry button (as well as a missing comma at the end of the last entry in the preceding dict). All it does is send the node straight back into commissioning. There's no need to send it back into Declared state first, which would only have added unnecessary code paths.

Why is there no need? As you see in NODE_TRANSITIONS, all I had to do was allow the node transition from Failed Tests back to Commissioning. In fact we didn't have any transitions from that state defined, so I defined what seemed sensible — a superset of what we actually use.

I did *not* add a “Retire” button for failed nodes, although I did allow the transition. The reason is that we don't seem to have that option anywhere else in the UI, and we might as well add that, wherever appropriate, in one fell swoop. Including it in this branch would water down its purpose, and doing it only for failed nodes would give a false impression that the job was done.

Oh, and finally of course there's a test. There's no negative test to prove that non-admins can't do this; that's purely data-driven, so essentially a configuration matter. There's little point in a test duplicating that information.

I toyed with making the Retry button require only View permission on the node, since after all at this stage there's no longer any objection to wiping its disks. The only scenario I could think of where it mattered was if an admin owned a node that failed commissioning, and then lost admin privileges but remained a valid user of the MAAS; they could then retain responsibility for dealing with the broken node. —And then I realized that a Failed node does not have an owner. Never mind; Admin is nice and simple.

Jeroen

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

> In the sampledata, node “moon” was in state Failed Tests but had an
> owner. This is unrealistic. A node in this state does not have an
> owner. (And thus, it can be deleted which makes a lot of sense!)

I thought that the owner is set when going into commissioning... is it
unset when test results are posted?

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Yes, the owner field is unset when the node comes out of commissioning.

Revision history for this message
Gavin Panella (allenap) :
review: Approve
Revision history for this message
Francis J. Lacoste (flacoste) wrote :

Can we get this backported on the released branch also? I think this is a good thing to have as part of the SRU.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

A backport is up for review.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/fixtures/dev_fixture.yaml'
2--- src/maasserver/fixtures/dev_fixture.yaml 2012-03-12 07:25:31 +0000
3+++ src/maasserver/fixtures/dev_fixture.yaml 2012-04-25 07:21:18 +0000
4@@ -7,7 +7,7 @@
5 pk: 15
6 - fields: {
7 created: 2012-01-24, hostname: moon, architecture: i386,
8- owner: 106, status: 2,
9+ owner: null, status: 2,
10 system_id: node-29d7ad70-4671-11e1-93b8-00225f89f211,
11 updated: !!timestamp '2012-01-24 10:52:44.507777'}
12 model: maasserver.node
13
14=== modified file 'src/maasserver/forms.py'
15--- src/maasserver/forms.py 2012-04-25 02:23:38 +0000
16+++ src/maasserver/forms.py 2012-04-25 07:21:18 +0000
17@@ -287,7 +287,15 @@
18 'display': "Accept & commission",
19 'permission': NODE_PERMISSION.ADMIN,
20 'execute': start_commissioning_node,
21- 'message': "Node commissioning started."
22+ 'message': "Node commissioning started.",
23+ },
24+ ],
25+ NODE_STATUS.FAILED_TESTS: [
26+ {
27+ 'display': "Retry commissioning",
28+ 'permission': NODE_PERMISSION.ADMIN,
29+ 'execute': start_commissioning_node,
30+ 'message': "Started a new attempt to commission this node.",
31 },
32 ],
33 NODE_STATUS.READY: [
34
35=== modified file 'src/maasserver/models/__init__.py'
36--- src/maasserver/models/__init__.py 2012-04-24 16:06:16 +0000
37+++ src/maasserver/models/__init__.py 2012-04-25 07:21:18 +0000
38@@ -159,6 +159,11 @@
39 NODE_STATUS.RETIRED,
40 NODE_STATUS.MISSING,
41 ],
42+ NODE_STATUS.FAILED_TESTS: [
43+ NODE_STATUS.COMMISSIONING,
44+ NODE_STATUS.MISSING,
45+ NODE_STATUS.RETIRED,
46+ ],
47 NODE_STATUS.READY: [
48 NODE_STATUS.ALLOCATED,
49 NODE_STATUS.RESERVED,
50
51=== modified file 'src/maasserver/tests/test_views_nodes.py'
52--- src/maasserver/tests/test_views_nodes.py 2012-04-25 02:23:38 +0000
53+++ src/maasserver/tests/test_views_nodes.py 2012-04-25 07:21:18 +0000
54@@ -265,6 +265,17 @@
55 self.assertEqual(
56 NODE_STATUS.COMMISSIONING, reload_object(node).status)
57
58+ def test_view_node_POST_admin_can_retry_failed_commissioning(self):
59+ self.become_admin()
60+ node = factory.make_node(status=NODE_STATUS.FAILED_TESTS)
61+ node_link = reverse('node-view', args=[node.system_id])
62+ response = self.client.post(
63+ node_link,
64+ data={NodeActionForm.input_name: "Retry commissioning"})
65+ self.assertEqual(httplib.FOUND, response.status_code)
66+ self.assertEqual(
67+ NODE_STATUS.COMMISSIONING, reload_object(node).status)
68+
69 def perform_action_and_get_node_page(self, node, action_name):
70 """POST to perform a node action, then load the resulting page."""
71 node_link = reverse('node-view', args=[node.system_id])