Merge ~r00ta/maas:lp-2060687 into maas:master

Proposed by Jacopo Rota
Status: Merged
Approved by: Jacopo Rota
Approved revision: 73500b4b42cd3a9f1bbffa84d7b535f210912718
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~r00ta/maas:lp-2060687
Merge into: maas:master
Diff against target: 46 lines (+12/-3)
2 files modified
src/metadataserver/api.py (+4/-1)
src/metadataserver/tests/test_api.py (+8/-2)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Stamatis Katsaounis Approve
Review via email: mp+464020@code.launchpad.net

Commit message

fix: lp-2060687. Ensure release scripts are Included for machines in DISK_ERASING status.

Description of the change

When a machine is released with the option to erase the disks, it has the DISK_ERASING status.
When the machine retrieves the scripts to run, all the release scripts should be included if the machine is in such status.

To post a comment you must log in.
Revision history for this message
Stamatis Katsaounis (skatsaounis) :
Revision history for this message
Jacopo Rota (r00ta) :
Revision history for this message
Stamatis Katsaounis (skatsaounis) wrote :

LGTM +1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp-2060687 lp:~r00ta/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 73500b4b42cd3a9f1bbffa84d7b535f210912718

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/metadataserver/api.py b/src/metadataserver/api.py
2index 35f9a9e..40696f7 100644
3--- a/src/metadataserver/api.py
4+++ b/src/metadataserver/api.py
5@@ -1466,7 +1466,10 @@ class MAASScriptsHandler(OperationsHandler):
6 meta_data, key=itemgetter("name", "script_result_id")
7 )
8
9- if node.status == NODE_STATUS.RELEASING:
10+ if (
11+ node.status == NODE_STATUS.RELEASING
12+ or node.status == NODE_STATUS.DISK_ERASING
13+ ):
14 meta_data = self._add_script_set_to_tar(
15 node.current_release_script_set,
16 tar,
17diff --git a/src/metadataserver/tests/test_api.py b/src/metadataserver/tests/test_api.py
18index 89be8b0..6de3f30 100644
19--- a/src/metadataserver/tests/test_api.py
20+++ b/src/metadataserver/tests/test_api.py
21@@ -2454,10 +2454,10 @@ class TestMAASScripts(MAASServerTestCase):
22 meta_data,
23 )
24
25- def test_returns_release_scripts_when_releasing(self):
26+ def _test_release_scripts_are_returned(self, node_status: NODE_STATUS):
27 start_time = floor(time.time())
28 node = factory.make_Node(
29- status=NODE_STATUS.RELEASING, with_empty_script_sets=True
30+ status=node_status, with_empty_script_sets=True
31 )
32
33 script = factory.make_Script(script_type=SCRIPT_TYPE.RELEASE)
34@@ -2509,6 +2509,12 @@ class TestMAASScripts(MAASServerTestCase):
35 meta_data,
36 )
37
38+ def test_returns_release_scripts_when_releasing(self):
39+ self._test_release_scripts_are_returned(NODE_STATUS.RELEASING)
40+
41+ def test_returns_release_scripts_when_erasing_disks(self):
42+ self._test_release_scripts_are_returned(NODE_STATUS.DISK_ERASING)
43+
44
45 class TestMAASScriptsProperties(MAASServerTestCase):
46 def setUp(self):

Subscribers

People subscribed via source and target branches