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

Proposed by Jacopo Rota
Status: Merged
Approved by: Jacopo Rota
Approved revision: 5c16f5e62b7459b6495270e16d3328f9e44d49e5
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~r00ta/maas:lp-2034014-add-retry-header-for-409-responses-3.3
Merge into: maas:3.3
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+451151@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
Jacopo Rota (r00ta) :
review: Approve
Revision history for this message
Jacopo Rota (r00ta) wrote :

jenkins: !test

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

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

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/3520/console
COMMIT: 5c16f5e62b7459b6495270e16d3328f9e44d49e5

review: Needs Fixing
Revision history for this message
Jacopo Rota (r00ta) wrote :

jenkins: !test

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

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

STATUS: SUCCESS
COMMIT: 5c16f5e62b7459b6495270e16d3328f9e44d49e5

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