Merge ~newell-jensen/maas:lp1702751 into maas:master

Proposed by Newell Jensen
Status: Rejected
Rejected by: Adam Collard
Proposed branch: ~newell-jensen/maas:lp1702751
Merge into: maas:master
Diff against target: 32 lines (+13/-0)
2 files modified
src/maasserver/api/auth.py (+4/-0)
src/maasserver/api/tests/test_auth.py (+9/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Andres Rodriguez (community) Needs Information
Review via email: mp+334493@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

This seems to be a work around to the issue. Why would this be needed in auth.py ? This is not an authentication issue.

That said, it seems to me we should allow adding a machine even with incorrect power parameters.

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

UNIT TESTS
-b lp1702751 lp:~newell-jensen/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: a869c7116cae886a2a3f625451ef9169988081b3

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

> This seems to be a work around to the issue. Why would this be needed in
> auth.py ? This is not an authentication issue.

A nonce has to do with authentication.

>
> That said, it seems to me we should allow adding a machine even with incorrect
> power parameters.

This is a partial workaround because nonce's have to do with authentication but the fact that this pops up very rarely with these IPMI BMCs is where the workaround comes into play. We have a nonce cleanup method that runs daily in the region event loop so finding out why it is trying to use the same nonce is the real issue here it seems although that may be a rabbit hole into oauth territory.

The machine is still created, it just fails to commission and goes back to the NEW state.

Unmerged commits

a869c71... by Newell Jensen

LP: #1702751 -- Change nonce error that is being surfaced to the api when a bmc cannot be reached.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/auth.py b/src/maasserver/api/auth.py
2index a14ba60..3bb5c1d 100644
3--- a/src/maasserver/api/auth.py
4+++ b/src/maasserver/api/auth.py
5@@ -26,6 +26,10 @@ class OAuthUnauthorized(Unauthorized):
6 # user-friendly error message.
7 if error.message == "Invalid consumer.":
8 self.error.message = "Authorization Error: Invalid API key."
9+ # XXX newell 2017-11-29 bug=1702751: Change the error message to
10+ # something that we know causes this issue.
11+ elif "Nonce already used" in error.message:
12+ self.error.message = "BMC can't be reached."
13 else:
14 self.error.message = "Authorization Error: %r" % error.message
15
16diff --git a/src/maasserver/api/tests/test_auth.py b/src/maasserver/api/tests/test_auth.py
17index febcb25..cb43cd2 100644
18--- a/src/maasserver/api/tests/test_auth.py
19+++ b/src/maasserver/api/tests/test_auth.py
20@@ -30,3 +30,12 @@ class TestOAuthUnauthorized(MAASTestCase):
21 self.assertThat(
22 str(maas_exception),
23 Contains("Authorization Error: Invalid API key."))
24+
25+ # XXX newell 2017-11-29 bug=1702751: Change the error message to
26+ # something that we know causes this issue.
27+ def test_exception_unicode_includes_bmc_cannot_be_reached_message(self):
28+ original_exception = oauth.OAuthError('Nonce already used')
29+ maas_exception = OAuthUnauthorized(original_exception)
30+ self.assertThat(
31+ str(maas_exception),
32+ Contains("BMC can't be reached."))

Subscribers

People subscribed via source and target branches