Merge ~r00ta/maas:lp-2034014-add-retry-header-for-409-responses into maas:master

Proposed by Jacopo Rota
Status: Merged
Approved by: Jacopo Rota
Approved revision: c70d770b4da8bd401e96ce6bc0ed5a7c75d21638
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~r00ta/maas:lp-2034014-add-retry-header-for-409-responses
Merge into: maas:master
Diff against target: 33 lines (+6/-0)
2 files modified
src/maasserver/utils/tests/test_views.py (+1/-0)
src/maasserver/utils/views.py (+5/-0)
Reviewer Review Type Date Requested Status
Jack Lloyd-Walters Approve
MAAS Lander Approve
Review via email: mp+450867@code.launchpad.net

Commit message

add retry-after header in 409 responses

Description of the change

See https://bugs.launchpad.net/maas/+bug/2034014/comments/6 for more details about this change.

The PR on gomaasapi is here https://github.com/juju/gomaasapi/pull/101

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp-2034014-add-retry-header-for-409-responses lp:~r00ta/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: a8338c932351b70a0093eacc2de46f084d1cb355

review: Approve
c70d770... by Jacopo Rota

remove leftover

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

UNIT TESTS
-b lp-2034014-add-retry-header-for-409-responses lp:~r00ta/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: c70d770b4da8bd401e96ce6bc0ed5a7c75d21638

review: Approve
Revision history for this message
Jack Lloyd-Walters (lloydwaltersj) wrote :

LGTM, tests passing and change is small so... +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/utils/tests/test_views.py b/src/maasserver/utils/tests/test_views.py
2index e456a1e..f53dfd4 100644
3--- a/src/maasserver/utils/tests/test_views.py
4+++ b/src/maasserver/utils/tests/test_views.py
5@@ -382,6 +382,7 @@ class TestWebApplicationHandler(SerializationFailureTestCase):
6 MockCallsMatch(call(request), call(request), call(request)),
7 )
8 self.assertIsInstance(response, HttpResponseConflict)
9+ self.expectThat(response["Retry-After"], Equals("5"))
10 self.expectThat(response.status_code, Equals(http.client.CONFLICT))
11 self.expectThat(
12 response.reason_phrase,
13diff --git a/src/maasserver/utils/views.py b/src/maasserver/utils/views.py
14index 18b67b9..e20c5e1 100644
15--- a/src/maasserver/utils/views.py
16+++ b/src/maasserver/utils/views.py
17@@ -38,6 +38,8 @@ from provisioningserver.utils.twisted import retries
18
19 logger = logging.getLogger(__name__)
20
21+RETRY_AFTER_CONFLICT = 5
22+
23
24 class InternalErrorResponse(BaseException):
25 """Exception raised to exit the transaction context.
26@@ -149,6 +151,9 @@ class HttpResponseConflict(MAASDjangoTemplateResponse):
27
28 def __init__(self, response=None, exc_info=None):
29 super().__init__(response=response)
30+ # Responses with status code 409 should be retried by the clients
31+ # see https://bugs.launchpad.net/maas/+bug/2034014/comments/6 for more information
32+ self["Retry-After"] = RETRY_AFTER_CONFLICT
33 self.exc_info = exc_info
34
35

Subscribers

People subscribed via source and target branches