Merge lp:~allenap/maas/dont-crash-when-selecting-fpi--bug-1293676--1.5 into lp:maas/1.5

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 2222
Proposed branch: lp:~allenap/maas/dont-crash-when-selecting-fpi--bug-1293676--1.5
Merge into: lp:maas/1.5
Diff against target: 132 lines (+59/-4)
3 files modified
src/maasserver/models/node.py (+4/-4)
src/maasserver/node_action.py (+25/-0)
src/maasserver/tests/test_node_action.py (+30/-0)
To merge this branch: bzr merge lp:~allenap/maas/dont-crash-when-selecting-fpi--bug-1293676--1.5
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+213917@code.launchpad.net

Commit message

Backport from trunk r2221: Inhibit the controls to change between fast and default installers when the use-fastpath-installer tag is defined with an expression.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

This looks like a straight backport. Feel free to self-approve those, assuming there are no conflicts.

However I do have a few notes about the code changes that also apply to what's already in trunk. It might be worth addressing them, and then backporting the updated version of the changes:

.

The big warning strings strike me as a bit confusing. Updated? In what way? By whom? Why? These situations often start with the passive voice. Don't do it. The imperative is fine when you're telling the user something they need to do in order to accomplish something — you don't even need to say “please.”

.

Both the ‘inhibit’ methods in node_action.py have this weird indentation:

            return dedent("""\
            The use-fastpath-installer tag is defined with an

Did tabs sneak in? I would expect the text inside an argument to the function call to be indented further than the line that starts the function call.

If that makes the indentation too deep for comfortable text flow, why not extract these two identical-looking methods, or parts thereof, into a function outside the classes? In fact, with these two near-identical explanations both repeated, why not extract them into global constants?

Jeroen

review: Approve
Revision history for this message
Gavin Panella (allenap) wrote :

> This looks like a straight backport.  Feel free to self-approve those,
> assuming there are no conflicts.

I was thinking that Julian ought to be gatekeeper on what we're going to
spend time trying to get into Trusty from here on, but a consensus is
good too.

>
> However I do have a few notes about the code changes that also apply to what's
> already in trunk.  It might be worth addressing them, and then backporting the
> updated version of the changes:
>
> .
>
> The big warning strings strike me as a bit confusing.  Updated?  In what way?
> By whom?  Why?  These situations often start with the passive voice.  Don't do
> it.  The imperative is fine when you're telling the user something they need
> to do in order to accomplish something — you don't even need to say “please.”

I can see that might be an improvement, but it also strikes me as a tiny
one. I don't know if that's because English is my first language, or
because I'm me. The passive voice here comes across as more polite; I'm
not telling you what to do, but I am telling you what must be done to
achieve your goal.

>
> .
>
> Both the ‘inhibit’ methods in node_action.py have this weird indentation:
>
>             return dedent("""\
>             The use-fastpath-installer tag is defined with an
>
> Did tabs sneak in?  I would expect the text inside an argument to the function
> call to be indented further than the line that starts the function call.
>
> If that makes the indentation too deep for comfortable text flow, why not
> extract these two identical-looking methods, or parts thereof, into a function
> outside the classes?  In fact, with these two near-identical explanations both
> repeated, why not extract them into global constants?

I just reflexively used python-mode's default indentation for this, and
I'm happy with that tbh. I'd be happy with it another 4 spaces further
in too. My shed's purple, yours is aubergine :-/

I think the pain of another branch and another back-port far outweighs
the gain of fixing either or both of these issues. Sorry.

Thanks for being so thorough though!

Revision history for this message
Julian Edwards (julian-edwards) wrote :

On Thursday 03 Apr 2014 20:19:01 you wrote:
> > This looks like a straight backport. Feel free to self-approve those,
> > assuming there are no conflicts.
>
> I was thinking that Julian ought to be gatekeeper on what we're going to
> spend time trying to get into Trusty from here on, but a consensus is
> good too.

It's probably a good idea to run it by me, but yes if I am not around and you
all agree please JFDI, don't block on me.

Anything landing in the 1.5 branch from now on will get CPed in packaging
anyway, so sadly the package in trusty won't necessarily entirely reflect
what's in the 1.5 branch.

> > The big warning strings strike me as a bit confusing. Updated? In what
> > way? By whom? Why? These situations often start with the passive voice.
> > Don't do it. The imperative is fine when you're telling the user
> > something they need to do in order to accomplish something — you don't
> > even need to say “please.”
> I can see that might be an improvement, but it also strikes me as a tiny
> one. I don't know if that's because English is my first language, or
> because I'm me. The passive voice here comes across as more polite; I'm
> not telling you what to do, but I am telling you what must be done to
> achieve your goal.

I agree with jtv here, UI instructions should generally be more direct and
explicit. Using the passive voice is usually frowned upon IIRC.

Dammit, I wish we had a UI expert on the team still :(

J

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models/node.py'
2--- src/maasserver/models/node.py 2014-03-27 17:52:53 +0000
3+++ src/maasserver/models/node.py 2014-04-02 19:45:27 +0000
4@@ -837,8 +837,8 @@
5 if uti_tag.is_defined:
6 raise RuntimeError(
7 "The use-fastpath-installer tag is defined with an "
8- "expression. This expression must be updated to prevent "
9- "this node from booting with the Fast Path installer.")
10+ "expression. This expression must instead be updated to set "
11+ "this node to install with the default installer.")
12 self.tags.remove(uti_tag)
13
14 def use_fastpath_installer(self):
15@@ -856,6 +856,6 @@
16 if uti_tag.is_defined:
17 raise RuntimeError(
18 "The use-fastpath-installer tag is defined with an "
19- "expression. This expression must be updated to make this "
20- "node boot with the Fast Path Installer.")
21+ "expression. This expression must instead be updated to set "
22+ "this node to install with the fast installer.")
23 self.tags.add(uti_tag)
24
25=== modified file 'src/maasserver/node_action.py'
26--- src/maasserver/node_action.py 2013-11-15 18:15:51 +0000
27+++ src/maasserver/node_action.py 2014-04-02 19:45:27 +0000
28@@ -44,6 +44,7 @@
29 Node,
30 SSHKey,
31 )
32+from maasserver.models.tag import Tag
33 from maasserver.utils import map_enum
34
35 # All node statuses.
36@@ -198,6 +199,18 @@
37 self.node.use_fastpath_installer()
38 return "Node marked as using curtin for install."
39
40+ def inhibit(self):
41+ """Inhibit if ``use-fastpath-installer`` uses an expression."""
42+ tag, _ = Tag.objects.get_or_create(name="use-fastpath-installer")
43+ if tag.is_defined:
44+ return dedent("""\
45+ The use-fastpath-installer tag is defined with an
46+ expression. This expression must instead be updated to set
47+ this node to install with the fast installer.
48+ """)
49+ else:
50+ return None
51+
52
53 class UseDI(NodeAction):
54 """Set this node to use d-i for installation."""
55@@ -216,6 +229,18 @@
56 self.node.use_traditional_installer()
57 return "Node marked as using the default installer."
58
59+ def inhibit(self):
60+ """Inhibit if ``use-fastpath-installer`` uses an expression."""
61+ tag, _ = Tag.objects.get_or_create(name="use-fastpath-installer")
62+ if tag.is_defined:
63+ return dedent("""\
64+ The use-fastpath-installer tag is defined with an
65+ expression. This expression must instead be updated to set
66+ this node to install with the default installer.
67+ """)
68+ else:
69+ return None
70+
71
72 class StartNode(NodeAction):
73 """Acquire and start a node."""
74
75=== modified file 'src/maasserver/tests/test_node_action.py'
76--- src/maasserver/tests/test_node_action.py 2014-01-14 00:43:21 +0000
77+++ src/maasserver/tests/test_node_action.py 2014-04-02 19:45:27 +0000
78@@ -23,6 +23,7 @@
79 NODE_STATUS_CHOICES_DICT,
80 )
81 from maasserver.exceptions import Redirect
82+from maasserver.models import Tag
83 from maasserver.node_action import (
84 Commission,
85 compile_node_actions,
86@@ -264,6 +265,11 @@
87 self.celery.tasks[0]['task'].name)
88
89
90+def make_use_fastpath_installer_tag_with_expression():
91+ Tag.objects.get_or_create(
92+ name="use-fastpath-installer", definition="true()")
93+
94+
95 class TestUseCurtinNodeAction(MAASServerTestCase):
96
97 def test_sets_tag(self):
98@@ -287,6 +293,18 @@
99 user = factory.make_admin()
100 self.assertFalse(UseCurtin(node, user).is_permitted())
101
102+ def test_inhibited_if_use_fastpath_installer_tag_uses_expr(self):
103+ make_use_fastpath_installer_tag_with_expression()
104+ node = factory.make_node()
105+ user = factory.make_admin()
106+ self.assertDocTestMatches(
107+ """\
108+ The use-fastpath-installer tag is defined with an
109+ expression. This expression must instead be updated to set
110+ this node to install with the fast installer.
111+ """,
112+ UseCurtin(node, user).inhibit())
113+
114
115 class TestUseDINodeAction(MAASServerTestCase):
116
117@@ -310,3 +328,15 @@
118 node.use_traditional_installer()
119 user = factory.make_admin()
120 self.assertFalse(UseDI(node, user).is_permitted())
121+
122+ def test_inhibited_if_use_fastpath_installer_tag_uses_expr(self):
123+ make_use_fastpath_installer_tag_with_expression()
124+ node = factory.make_node()
125+ user = factory.make_admin()
126+ self.assertDocTestMatches(
127+ """\
128+ The use-fastpath-installer tag is defined with an
129+ expression. This expression must instead be updated to set
130+ this node to install with the default installer.
131+ """,
132+ UseDI(node, user).inhibit())

Subscribers

People subscribed via source and target branches

to all changes: