Skip to content

Commit

Permalink
removing 'techinical-failure'
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanParish committed Dec 17, 2024
1 parent a73a804 commit 91258d3
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 38 deletions.
2 changes: 1 addition & 1 deletion app/celery/lookup_va_profile_id_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def lookup_va_profile_id(
except Exception as e:
message = (
f'Failed to retrieve VA Profile ID from MPI for notification: {notification_id} '
'Notification has been updated to technical-failure'
'Notification has been updated to permanent-failure'
)
current_app.logger.exception(message)
notifications_dao.update_notification_status_by_id(
Expand Down
17 changes: 0 additions & 17 deletions app/celery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,23 +376,6 @@ def update_letter_notifications_to_sent_to_dvla(
current_app.logger.info('Updated %s letter notifications to sending', updated_count)


# @notify_celery.task(bind=True, name='update-letter-notifications-to-error')
# @statsd(namespace='tasks')
# def update_letter_notifications_to_error(
# self,
# notification_references,
# ):
# # This task will be called by the FTP app to update notifications as sent to DVLA

# updated_count, _ = dao_update_notifications_by_reference(
# notification_references, {'status': NOTIFICATION_PERMANENT_FAILURE, 'updated_at': datetime.utcnow()}
# )
# message = 'Updated {} letter notifications to technical-failure with references {}'.format(
# updated_count, notification_references
# )
# raise NotificationTechnicalFailureException(message)


def handle_exception(
task,
notification,
Expand Down
2 changes: 1 addition & 1 deletion app/dao/fact_notification_status_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,11 +815,11 @@ def fetch_monthly_notification_statuses_per_service(
else_=0,
)
).label('count_delivered'),
# TODO: remove this after technical-failure is removed from the codebase
func.sum(
case(
[
(
# TODO: remove this after technical-failure is removed from the codebase
FactNotificationStatus.notification_status.in_(['technical-failure', NOTIFICATION_FAILED]),
FactNotificationStatus.notification_count,
)
Expand Down
6 changes: 3 additions & 3 deletions app/dao/notifications_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ def dao_timeout_notifications(timeout_period_in_seconds):
Timeout SMS and email notifications by the following rules:
we never sent the notification to the provider for some reason
created -> technical-failure
created -> permanent-failure
the notification was sent to the provider but there was not a delivery receipt
sending -> temporary-failure
Expand All @@ -840,7 +840,7 @@ def dao_timeout_notifications(timeout_period_in_seconds):
timeout = functools.partial(_timeout_notifications, timeout_start=timeout_start, updated_at=updated_at)

# Notifications still in created status are marked with a permanent-failure:
technical_failure_notifications = timeout(
unsent_failed_notifications = timeout(
current_statuses=[NOTIFICATION_CREATED],
new_status=NOTIFICATION_PERMANENT_FAILURE,
status_reason=STATUS_REASON_UNDELIVERABLE,
Expand All @@ -855,7 +855,7 @@ def dao_timeout_notifications(timeout_period_in_seconds):

db.session.commit()

return technical_failure_notifications, temporary_failure_notifications
return unsent_failed_notifications, temporary_failure_notifications


def is_delivery_slow_for_provider(
Expand Down
2 changes: 1 addition & 1 deletion app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ def get_letter_status(self):
elif self.status in [NOTIFICATION_DELIVERED, NOTIFICATION_RETURNED_LETTER]:
return NOTIFICATION_STATUS_LETTER_RECEIVED
else:
# Currently can only be technical-failure OR pending-virus-check OR validation-failed
# Currently can only be pending-virus-check OR validation-failed
return self.status

def get_created_by_name(self):
Expand Down
2 changes: 2 additions & 0 deletions app/service/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def format_admin_stats(statistics):
counts[row.notification_type]['test-key'] += row.count
else:
counts[row.notification_type]['total'] += row.count
# TODO: remove this after technical-failure is removed from the codebase
if row.status in ('technical-failure', 'permanent-failure', 'temporary-failure', 'virus-scan-failed'):
counts[row.notification_type]['failures'][row.status] += row.count

Expand All @@ -44,6 +45,7 @@ def create_stats_dict():
stats_dict[template][status] = 0

stats_dict[template]['failures'] = {
# TODO: remove this after technical-failure is removed from the codebase
'technical-failure': 0,
'permanent-failure': 0,
'temporary-failure': 0,
Expand Down
1 change: 0 additions & 1 deletion documents/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2202,7 +2202,6 @@ components:
- failed
- sending
- sent
- technical-failure
- temporary-failure
- pending
- pending-virus-check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3782,7 +3782,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"url\": \"https://some-url.com\",\n \"callback_type\": \"delivery_status\",\n \"callback_channel\": \"webhook\",\n \"bearer_token\": \"static-bearer-token-used-to-authenticate-request\",\n \"notification_statuses\": [\"sent\", \"delivered\", \"failed\", \"technical-failure\", \"temporary-failure\", \"permanent-failure\", \"preferences-declined\" ]\n}"
"raw": "{\n \"url\": \"https://some-url.com\",\n \"callback_type\": \"delivery_status\",\n \"callback_channel\": \"webhook\",\n \"bearer_token\": \"static-bearer-token-used-to-authenticate-request\",\n \"notification_statuses\": [\"sent\", \"delivered\", \"failed\", \"temporary-failure\", \"permanent-failure\", \"preferences-declined\" ]\n}"
},
"url": {
"raw": "{{notification-api-url}}/service/{{service-id}}/callback",
Expand Down
2 changes: 1 addition & 1 deletion load_testing/send_email_load_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _async_send_email(
self.report_status(start_time=start_time, response=notification_creation_response)
return

elif notification_status in ['technical-failure', 'permanent-failure']:
elif notification_status in ['permanent-failure']:
self.report_status(
start_time=start_time,
response=notification_creation_response,
Expand Down
2 changes: 1 addition & 1 deletion tests/app/celery/test_contact_information_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def test_lookup_contact_info_should_retry_on_timeout(
assert recipient_identifier.id_value == EXAMPLE_VA_PROFILE_ID


def test_should_update_notification_to_technical_failure_on_max_retries(
def test_should_update_notification_to_permanent_failure_on_max_retries(
client, mocker, sample_template, sample_notification
):
template = sample_template(template_type=EMAIL_TYPE)
Expand Down
4 changes: 2 additions & 2 deletions tests/app/celery/test_lookup_va_profile_id_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ def test_should_retry_on_retryable_exception(client, mocker, sample_notification
mocked_mpi_client.get_va_profile_id.assert_called_with(notification)


def test_should_update_notification_to_technical_failure_on_max_retries_and_should_call_callback(
def test_should_update_notification_to_permanent_failure_on_max_retries_and_should_call_callback(
client, mocker, sample_notification
):
"""
Raising MpiRetryableException and subsequently determining the the maximum number of retries has been
reached should result in a technical failure.
reached should result in a permanent failure.
"""

notification = sample_notification()
Expand Down
8 changes: 0 additions & 8 deletions tests/app/celery/test_process_delivery_status_result_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
_DELIVERED_UPDATES,
_TEMPORARY_FAILURE_UPDATES,
_PERMANENT_FAILURE_UPDATES,
_TECHNICAL_FAILURE_UPDATES,
_PREFERENCES_DECLINED_UPDATES,
)
from app.constants import (
NOTIFICATION_CREATED,
Expand All @@ -35,8 +33,6 @@
NOTIFICATION_SENT,
NOTIFICATION_PERMANENT_FAILURE,
PINPOINT_PROVIDER,
NOTIFICATION_PREFERENCES_DECLINED,
NOTIFICATION_TECHNICAL_FAILURE,
NOTIFICATION_TEMPORARY_FAILURE,
TWILIO_PROVIDER,
)
Expand Down Expand Up @@ -356,8 +352,6 @@ def test_sms_status_provider_payload_set_to_none(notify_api, mocker, sample_noti
*[(NOTIFICATION_DELIVERED, s) for s in _DELIVERED_UPDATES],
*[(NOTIFICATION_TEMPORARY_FAILURE, s) for s in _TEMPORARY_FAILURE_UPDATES],
*[(NOTIFICATION_PERMANENT_FAILURE, s) for s in _PERMANENT_FAILURE_UPDATES],
*[(NOTIFICATION_TECHNICAL_FAILURE, s) for s in _TECHNICAL_FAILURE_UPDATES],
*[(NOTIFICATION_PREFERENCES_DECLINED, s) for s in _PREFERENCES_DECLINED_UPDATES],
],
)
def test_sms_status_check_and_queue_called(notify_api, mocker, sample_notification, start_status, end_status):
Expand All @@ -381,8 +375,6 @@ def test_sms_status_check_and_queue_called(notify_api, mocker, sample_notificati
*[(NOTIFICATION_DELIVERED, s) for s in _DELIVERED_UPDATES],
*[(NOTIFICATION_TEMPORARY_FAILURE, s) for s in _TEMPORARY_FAILURE_UPDATES],
*[(NOTIFICATION_PERMANENT_FAILURE, s) for s in _PERMANENT_FAILURE_UPDATES],
*[(NOTIFICATION_TECHNICAL_FAILURE, s) for s in _TECHNICAL_FAILURE_UPDATES],
*[(NOTIFICATION_PREFERENCES_DECLINED, s) for s in _PREFERENCES_DECLINED_UPDATES],
],
)
def test_sms_status_check_and_queue_not_called(notify_api, mocker, sample_notification, start_status, end_status):
Expand Down
3 changes: 2 additions & 1 deletion tests/app/celery/test_service_callback_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
EMAIL_TYPE,
INBOUND_SMS_CALLBACK_TYPE,
LETTER_TYPE,
NOTIFICATION_PERMANENT_FAILURE,
NOTIFICATION_STATUS_TYPES,
SMS_TYPE,
)
Expand Down Expand Up @@ -206,7 +207,7 @@ def test_send_delivery_status_to_service_succeeds_if_sent_at_is_none(
callback_api, template = _set_up_test_data(EMAIL_TYPE, 'delivery_status', sample_service, sample_template)
datestr = datetime(2017, 6, 20)
notification = sample_notification(
template=template, created_at=datestr, updated_at=datestr, sent_at=None, status='technical-failure'
template=template, created_at=datestr, updated_at=datestr, sent_at=None, status=NOTIFICATION_PERMANENT_FAILURE
)
encrypted_data = _set_up_data_for_status_update(callback_api, notification)
with requests_mock.Mocker() as request_mock:
Expand Down

0 comments on commit 91258d3

Please sign in to comment.