diff --git a/doc/release/RELEASE-NOTES.md b/doc/release/RELEASE-NOTES.md index 3f4097884..168a8926c 100644 --- a/doc/release/RELEASE-NOTES.md +++ b/doc/release/RELEASE-NOTES.md @@ -28,6 +28,7 @@ to modify moderation event `status`. * [OSDEV-1347](https://opensupplyhub.atlassian.net/browse/OSDEV-1347) - Create GET request for `v1/moderation-events/{moderation_id}` endpoint. * Update `/v1/production-locations/{os_id}` endpoint to return a single object instead of multiple objects. Also, add unit tests for the `ProductionLocationsViewSet`. * The RDS instance has been upgraded as follows: for `production` and `preprod`, it is now `db.m6in.8xlarge`, and for `test`, it has been upgraded to `db.t3.xlarge`. +* [OSDEV-1467](https://opensupplyhub.atlassian.net/browse/OSDEV-1467) - Implemented disabling endpoint `POST /api/facilities/` during the release process. It is raising an error message with status code 503. ### Architecture/Environment changes * Increased the memory for the Dedupe Hub instance from 8GB to 12GB in the `production` and `pre-prod` environments to reduce the risk of container overload and minimize the need for reindexing in the future. diff --git a/src/django/api/constants.py b/src/django/api/constants.py index 7c3d0a3ac..daf153080 100644 --- a/src/django/api/constants.py +++ b/src/django/api/constants.py @@ -194,6 +194,9 @@ class NumberOfWorkersRanges: class ErrorMessages: GEOCODED_NO_RESULTS = "The address you submitted can not be geocoded." + MAINTENANCE_MODE = ('Open Supply Hub is undergoing maintenance and ' + 'not accepting new data at the moment. Please ' + 'try again in a few minutes.') class FacilitiesDownloadSettings: diff --git a/src/django/api/exceptions.py b/src/django/api/exceptions.py index 55d9eefe5..8eadffcf1 100644 --- a/src/django/api/exceptions.py +++ b/src/django/api/exceptions.py @@ -10,6 +10,6 @@ class BadRequestException(APIException): class ServiceUnavailableException(APIException): status_code = status.HTTP_503_SERVICE_UNAVAILABLE - default_detail = 'Service is temporarily unavailable due to maintenance \ - work. Please try again later.' + default_detail = ('Service is temporarily unavailable due to maintenance' + 'work. Please try again later.') default_code = 'service_unavailable' diff --git a/src/django/api/views/facility/facilities_view_set.py b/src/django/api/views/facility/facilities_view_set.py index 472fdb496..ca46f4248 100644 --- a/src/django/api/views/facility/facilities_view_set.py +++ b/src/django/api/views/facility/facilities_view_set.py @@ -11,6 +11,7 @@ from contricleaner.lib.exceptions.handler_not_set_error \ import HandlerNotSetError +from api.exceptions import ServiceUnavailableException from api.helpers.helpers import validate_workers_count from oar.settings import ( MAX_ATTACHMENT_SIZE_IN_BYTES, @@ -67,7 +68,8 @@ FacilityMergeQueryParams, ProcessingAction, UpdateLocationParams, - FacilityClaimStatuses + FacilityClaimStatuses, + ErrorMessages, ) from ...exceptions import BadRequestException from ...facility_history import ( @@ -576,6 +578,8 @@ def create(self, request): """ # noqa # Adding the @permission_classes decorator was not working so we # explicitly invoke our custom permission class. + if switch_is_active('disable_list_uploading'): + raise ServiceUnavailableException(ErrorMessages.MAINTENANCE_MODE) if not IsRegisteredAndConfirmed().has_permission(request, self): return Response(status=status.HTTP_401_UNAUTHORIZED) if not flag_is_active(request._request, diff --git a/src/django/api/views/facility/facility_list_view_set.py b/src/django/api/views/facility/facility_list_view_set.py index a29c87735..69a19b77e 100644 --- a/src/django/api/views/facility/facility_list_view_set.py +++ b/src/django/api/views/facility/facility_list_view_set.py @@ -27,6 +27,7 @@ from api.constants import ( FacilityListItemsQueryParams, ProcessingAction, + ErrorMessages, ) from api.exceptions import ServiceUnavailableException from ...facility_history import create_dissociate_match_change_reason @@ -92,10 +93,7 @@ def create(self, request): } """ if switch_is_active('disable_list_uploading'): - raise ServiceUnavailableException('Open Supply Hub is undergoing \ - maintenance and not accepting new \ - data at the moment. Please try again \ - in a few minutes.') + raise ServiceUnavailableException(ErrorMessages.MAINTENANCE_MODE) if 'file' not in request.data: raise ValidationError('No file specified.') uploaded_file = request.data['file']