mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
catch boto exceptions
these will happen if, for example, you have issues connecting to AWS or permission issues. Still failover if we get one of these exceptions, as I think it might be possible to have a problem only related to one of the lambdas.
This commit is contained in:
@@ -2,6 +2,7 @@ import json
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
import boto3
|
||||
import botocore
|
||||
from flask import current_app
|
||||
from notifications_utils.template import non_gsm_characters
|
||||
|
||||
@@ -127,13 +128,16 @@ class CBCProxyClientBase(ABC):
|
||||
|
||||
def _invoke_lambda(self, lambda_name, payload):
|
||||
payload_bytes = bytes(json.dumps(payload), encoding='utf8')
|
||||
current_app.logger.info(f"Calling lambda {lambda_name}")
|
||||
result = self._lambda_client.invoke(
|
||||
FunctionName=lambda_name,
|
||||
InvocationType='RequestResponse',
|
||||
Payload=payload_bytes,
|
||||
)
|
||||
current_app.logger.info(f"Finished calling lambda {lambda_name}")
|
||||
try:
|
||||
result = self._lambda_client.invoke(
|
||||
FunctionName=lambda_name,
|
||||
InvocationType='RequestResponse',
|
||||
Payload=payload_bytes,
|
||||
)
|
||||
except botocore.exceptions.ClientError as exc:
|
||||
current_app.logger.exception(f'Boto ClientError calling lambda {lambda_name}')
|
||||
success = False
|
||||
return success
|
||||
|
||||
if result['StatusCode'] > 299:
|
||||
current_app.logger.info(
|
||||
|
||||
Reference in New Issue
Block a user