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

Proposed by Jacopo Rota
Status: Merged
Approved by: Jacopo Rota
Approved revision: 44decb1c68a741cd9a1cd2efea992c2db8f6428a
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~r00ta/maas:lp-2034014-add-retry-header-for-409-responses-3.2
Merge into: maas:3.2
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
MAAS Lander Approve
Jacopo Rota Approve
Review via email: mp+451150@code.launchpad.net

Commit message

add retry-after header in 409 responses - cherry pick e8aa5d01a5272c536a2aa3e23bd3fc11b580bd90

Description of the change

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

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-3.2 lp:~r00ta/maas/+git/maas into -b 3.2 lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/3515/console
COMMIT: 64f3902528bd43092af2ca09d0d70e6b7a22bc19

review: Needs Fixing
Revision history for this message
Jacopo Rota (r00ta) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

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

STATUS: SUCCESS
COMMIT: 44decb1c68a741cd9a1cd2efea992c2db8f6428a

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 df08682..2ee457b 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.assertThat(response, IsInstance(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 5240a40..b8925ec 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