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

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
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 (community) Approve
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.
Revision history for this message
Lee Trager (ltrager) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py 2016-10-12 22:31:30 +0000
+++ src/maasserver/models/node.py 2016-10-27 00:45:33 +0000
@@ -122,6 +122,7 @@
122 COMMISSIONING_LIKE_STATUSES,122 COMMISSIONING_LIKE_STATUSES,
123 get_failed_status,123 get_failed_status,
124 is_failed_status,124 is_failed_status,
125 MONITORED_STATUSES,
125 NODE_FAILURE_MONITORED_STATUS_TIMEOUTS,126 NODE_FAILURE_MONITORED_STATUS_TIMEOUTS,
126 NODE_TRANSITIONS,127 NODE_TRANSITIONS,
127)128)
@@ -1329,7 +1330,15 @@
1329 self.hostname, error)1330 self.hostname, error)
13301331
1331 def save(self, *args, **kwargs):1332 def save(self, *args, **kwargs):
1333 # Reset the status_expires if not a monitored status. This prevents
1334 # a race condition seen in LP1603563 where an old status_expires caused
1335 # the node to do in a FAILED_RELEASING state due to an old
1336 # status_expire being set.
1337 if self.status not in MONITORED_STATUSES:
1338 self.status_expires = None
1339
1332 super(Node, self).save(*args, **kwargs)1340 super(Node, self).save(*args, **kwargs)
1341
1333 # We let hostname be blank for the initial save, but fix it before the1342 # We let hostname be blank for the initial save, but fix it before the
1334 # save completes. This is because set_random_hostname() operates by1343 # save completes. This is because set_random_hostname() operates by
1335 # trying to re-save the node with a random hostname, and retrying until1344 # trying to re-save the node with a random hostname, and retrying until
13361345
=== modified file 'src/maasserver/models/tests/test_node.py'
--- src/maasserver/models/tests/test_node.py 2016-10-12 22:31:30 +0000
+++ src/maasserver/models/tests/test_node.py 2016-10-27 00:45:33 +0000
@@ -2332,6 +2332,15 @@
2332 "Invalid transition: Retired -> Allocated.",2332 "Invalid transition: Retired -> Allocated.",
2333 node.save)2333 node.save)
23342334
2335 def test_save_resets_status_expires_on_non_monitored_status(self):
2336 # Regression test for LP:1603563
2337 node = factory.make_Node(status=NODE_STATUS.RELEASING)
2338 Node._set_status_expires(node.system_id, 60)
2339 node.status = NODE_STATUS.READY
2340 node.save()
2341 node = reload_object(node)
2342 self.assertIsNone(node.status_expires)
2343
2335 def test_full_clean_checks_architecture_for_installable_nodes(self):2344 def test_full_clean_checks_architecture_for_installable_nodes(self):
2336 device = factory.make_Device(architecture='')2345 device = factory.make_Device(architecture='')
2337 # Set type here so we don't cause exception while creating object2346 # Set type here so we don't cause exception while creating object

Subscribers

People subscribed via source and target branches

to all changes: