From a15d81ea1454fd95913414e78743d067d3a7c114 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 12 Dec 2024 09:11:59 -0500 Subject: [PATCH] Revert "12/11/2024 Production Deployment API hotfixes" --- app/celery/provider_tasks.py | 14 ++++---------- app/clients/cloudwatch/aws_cloudwatch.py | 2 +- app/config.py | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/celery/provider_tasks.py b/app/celery/provider_tasks.py index 4bc8b99e1..1e6c7e96f 100644 --- a/app/celery/provider_tasks.py +++ b/app/celery/provider_tasks.py @@ -1,6 +1,5 @@ import json import os -import random from datetime import timedelta from botocore.exceptions import ClientError @@ -30,7 +29,8 @@ @notify_celery.task( bind=True, name="check_sms_delivery_receipt", - max_retries=72, + max_retries=48, + default_retry_delay=300, ) def check_sms_delivery_receipt(self, message_id, notification_id, sent_at): """ @@ -62,10 +62,7 @@ def check_sms_delivery_receipt(self, message_id, notification_id, sent_at): carrier=carrier, provider_response=provider_response, ) - base_delay = 3600 # one hour - jitter = random.randint(-1200, +1200) # nosec B311 - retry_delay = base_delay + jitter - raise self.retry(countdown=retry_delay, exc=ntfe) + raise self.retry(exc=ntfe) except ClientError as err: # Probably a ThrottlingException but could be something else error_code = err.response["Error"]["Code"] @@ -80,10 +77,7 @@ def check_sms_delivery_receipt(self, message_id, notification_id, sent_at): carrier=carrier, provider_response=provider_response, ) - base_delay = 3600 # one hour - jitter = random.randint(-1200, +1200) # nosec B311 - retry_delay = base_delay + jitter - raise self.retry(countdown=retry_delay, exc=err) + raise self.retry(exc=err) if status == "success": status = NotificationStatus.DELIVERED diff --git a/app/clients/cloudwatch/aws_cloudwatch.py b/app/clients/cloudwatch/aws_cloudwatch.py index 8ef34abac..36bcf5dca 100644 --- a/app/clients/cloudwatch/aws_cloudwatch.py +++ b/app/clients/cloudwatch/aws_cloudwatch.py @@ -158,7 +158,7 @@ def check_sms(self, message_id, notification_id, created_at): message["delivery"].get("phoneCarrier", "Unknown Carrier"), ) - if time_now > (created_at + timedelta(hours=73)): + if time_now > (created_at + timedelta(hours=3)): # see app/models.py Notification. This message corresponds to "permanent-failure", # but we are copy/pasting here to avoid circular imports. return "failure", "Unable to find carrier response." diff --git a/app/config.py b/app/config.py index 1ec8abd59..12159e289 100644 --- a/app/config.py +++ b/app/config.py @@ -167,7 +167,7 @@ class Config(object): current_minute = (datetime.now().minute + 1) % 60 CELERY = { - "worker_max_tasks_per_child": 2000, + "worker_max_tasks_per_child": 500, "broker_url": REDIS_URL, "broker_transport_options": { "visibility_timeout": 310,