Merge lp:~ltrager/maas/lp1603563_2.0 into lp:maas/2.0

Proposed by Lee Trager on 2016-10-27
Status: Merged
Approved by: Lee Trager on 2016-10-27
Approved revision: 5201
Merged at revision: 5201
Proposed branch: lp:~ltrager/maas/lp1603563_2.0
Merge into: lp:maas/2.0
Diff against target: 47 lines (+18/-0)
2 files modified
src/maasserver/models/node.py (+9/-0)
src/maasserver/models/tests/test_node.py (+9/-0)
To merge this branch: bzr merge lp:~ltrager/maas/lp1603563_2.0
Reviewer Review Type Date Requested Status
Lee Trager Approve on 2016-10-27
Review via email: mp+309416@code.launchpad.net

Commit message

Backport from 2.1.1 - Reset status_expires when a non-monitored status is set.

To post a comment you must log in.
Lee Trager (ltrager) :
review: Approve

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 2016-10-12 22:31:30 +0000
3+++ src/maasserver/models/node.py 2016-10-27 00:45:33 +0000
4@@ -122,6 +122,7 @@
5 COMMISSIONING_LIKE_STATUSES,
6 get_failed_status,
7 is_failed_status,
8+ MONITORED_STATUSES,
9 NODE_FAILURE_MONITORED_STATUS_TIMEOUTS,
10 NODE_TRANSITIONS,
11 )
12@@ -1329,7 +1330,15 @@
13 self.hostname, error)
14
15 def save(self, *args, **kwargs):
16+ # Reset the status_expires if not a monitored status. This prevents
17+ # a race condition seen in LP1603563 where an old status_expires caused
18+ # the node to do in a FAILED_RELEASING state due to an old
19+ # status_expire being set.
20+ if self.status not in MONITORED_STATUSES:
21+ self.status_expires = None
22+
23 super(Node, self).save(*args, **kwargs)
24+
25 # We let hostname be blank for the initial save, but fix it before the
26 # save completes. This is because set_random_hostname() operates by
27 # trying to re-save the node with a random hostname, and retrying until
28
29=== modified file 'src/maasserver/models/tests/test_node.py'
30--- src/maasserver/models/tests/test_node.py 2016-10-12 22:31:30 +0000
31+++ src/maasserver/models/tests/test_node.py 2016-10-27 00:45:33 +0000
32@@ -2332,6 +2332,15 @@
33 "Invalid transition: Retired -> Allocated.",
34 node.save)
35
36+ def test_save_resets_status_expires_on_non_monitored_status(self):
37+ # Regression test for LP:1603563
38+ node = factory.make_Node(status=NODE_STATUS.RELEASING)
39+ Node._set_status_expires(node.system_id, 60)
40+ node.status = NODE_STATUS.READY
41+ node.save()
42+ node = reload_object(node)
43+ self.assertIsNone(node.status_expires)
44+
45 def test_full_clean_checks_architecture_for_installable_nodes(self):
46 device = factory.make_Device(architecture='')
47 # Set type here so we don't cause exception while creating object

Subscribers

People subscribed via source and target branches

to all changes: