Merge ~andreserl/maas:lp1548402 into maas:master

Proposed by Andres Rodriguez
Status: Merged
Merge reported by: Andres Rodriguez
Merged at revision: 68948d1f59b3f1c3b482a36ef423e9c850b18d8d
Proposed branch: ~andreserl/maas:lp1548402
Merge into: maas:master
Diff against target: 42 lines (+13/-0)
2 files modified
src/maasserver/api/machines.py (+7/-0)
src/maasserver/node_action.py (+6/-0)
Reviewer Review Type Date Requested Status
Blake Rouse (community) Needs Fixing
Newell Jensen (community) Needs Fixing
Review via email: mp+327054@code.launchpad.net

Commit message

LP: #1548402 - Handle errors in preseeds

Ensure that MAAS prevents starting the deployment of a machine if the preseeds fail to render.

To post a comment you must log in.
~andreserl/maas:lp1548402 updated
68948d1... by Andres Rodriguez

Fix format

Revision history for this message
Andres Rodriguez (andreserl) wrote :

So I have a few questions here:

1. Should we prevent if all the curtin preseed rendering fails, or only if curtin_userdata ?
2. Raising the error via the API forms causes an issue we have discussed before, which is some errors so in json format (like {"distro_series": ["'asdfadsf' is not a valid distro_series... ']} ) but this would show as plain text. Since we discussed plain output vs structured output... how should we handle this?
3. Why do we have different actions for the API vs the UI? It would seem to me that deploying via the UI should be done exactly like the API.

Revision history for this message
Newell Jensen (newell-jensen) wrote :

Seems like from your comment above that you are uncertain about how to handle this but I have reviewed what you have below based on the code itself. You are missing unit tests and I also made a suggestion.

review: Needs Fixing
Revision history for this message
Blake Rouse (blake-rouse) wrote :

I think this is good.

The reason for doing it in 2 places is really just legacy. We have been doing it that way from the beginning as for why I don't know as that pre-dates me. I think it would be better to combine them of-course, but that could cause more bugs.

review: Approve
Revision history for this message
Newell Jensen (newell-jensen) wrote :

> I think this is good.
>
> The reason for doing it in 2 places is really just legacy. We have been doing
> it that way from the beginning as for why I don't know as that pre-dates me. I
> think it would be better to combine them of-course, but that could cause more
> bugs.

Still needs tests.

Revision history for this message
Blake Rouse (blake-rouse) wrote :

Ah true, missing tests.

review: Needs Fixing
Revision history for this message
Andres Rodriguez (andreserl) wrote :

This was already landed by another branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/machines.py b/src/maasserver/api/machines.py
2index 58d9dfd..dfca107 100644
3--- a/src/maasserver/api/machines.py
4+++ b/src/maasserver/api/machines.py
5@@ -443,6 +443,13 @@ class MachineHandler(NodeHandler, OwnerDataMixin, PowerMixin):
6 form.save()
7 else:
8 raise MAASAPIValidationError(form.errors)
9+ # Check that the curtin preseeds renders correctly.
10+ try:
11+ get_curtin_merged_config(machine)
12+ except Exception as e:
13+ raise MAASAPIBadRequest(
14+ "Failed to render preseed: %s" % e)
15+
16 return self.power_on(request, system_id)
17
18 @operation(idempotent=False)
19diff --git a/src/maasserver/node_action.py b/src/maasserver/node_action.py
20index fc48bb0..2a064b4 100644
21--- a/src/maasserver/node_action.py
22+++ b/src/maasserver/node_action.py
23@@ -44,6 +44,7 @@ from maasserver.node_status import (
24 is_failed_status,
25 NON_MONITORED_STATUSES,
26 )
27+from maasserver.preseed import get_curtin_config
28 from maasserver.utils.orm import post_commit_do
29 from maasserver.utils.osystems import (
30 validate_hwe_kernel,
31@@ -346,6 +347,11 @@ class Deploy(NodeAction):
32 raise NodeActionError(e)
33
34 try:
35+ get_curtin_config(self.node)
36+ except Exception as e:
37+ raise NodeActionError(e)
38+
39+ try:
40 self.node.start(self.user)
41 except StaticIPAddressExhaustion:
42 raise NodeActionError(

Subscribers

People subscribed via source and target branches