mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-07 20:08:26 -04:00
Merge pull request #2001 from GSA/noquota
add log statement when our send quota is used up
This commit is contained in:
@@ -7,6 +7,7 @@ from flask import current_app
|
|||||||
|
|
||||||
from app.clients import AWS_CLIENT_CONFIG, Client
|
from app.clients import AWS_CLIENT_CONFIG, Client
|
||||||
from app.cloudfoundry_config import cloud_config
|
from app.cloudfoundry_config import cloud_config
|
||||||
|
from app.utils import hilite
|
||||||
|
|
||||||
|
|
||||||
class AwsCloudwatchClient(Client):
|
class AwsCloudwatchClient(Client):
|
||||||
@@ -178,6 +179,19 @@ class AwsCloudwatchClient(Client):
|
|||||||
)
|
)
|
||||||
failed_event_set = self._get_receipts(log_group_name, start, end)
|
failed_event_set = self._get_receipts(log_group_name, start, end)
|
||||||
current_app.logger.info((f"Failed message count: {len(failed_event_set)}"))
|
current_app.logger.info((f"Failed message count: {len(failed_event_set)}"))
|
||||||
|
raise_exception = False
|
||||||
|
for failure in failed_event_set:
|
||||||
|
try:
|
||||||
|
failure = json.loads(failure)
|
||||||
|
if "No quota left for account" == failure["delivery.providerResponse"]:
|
||||||
|
current_app.logger.warning(
|
||||||
|
hilite("**********NO QUOTA LEFT TO SEND MESSAGES!!!**********")
|
||||||
|
)
|
||||||
|
raise_exception = True
|
||||||
|
except Exception:
|
||||||
|
current_app.logger.exception("Malformed delivery receipt")
|
||||||
|
if raise_exception:
|
||||||
|
raise Exception("No Quota Left")
|
||||||
|
|
||||||
return delivered_event_set, failed_event_set
|
return delivered_event_set, failed_event_set
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user