mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-15 17:52:26 -05:00
Don't try failover for canary
No point trying, it's the same lambda. As `_invoke_lambda` currently takes a bytes payload, rather than a json payload, it meant the decision between encoding the payload in the canary or moving the encoding into the `_invoke_lambda` function. We decided to go for the former as the lesser of two evils. We may end up doing the encoding twice in the case of a failover but this avoids us having to put the encoding in our code in several places (for example the canary and also soon to be the link tests).
This commit is contained in:
@@ -109,17 +109,17 @@ class CBCProxyClientBase(ABC):
|
||||
pass
|
||||
|
||||
def _invoke_lambda_with_failover(self, payload):
|
||||
payload_bytes = bytes(json.dumps(payload), encoding='utf8')
|
||||
result = self._invoke_lambda(self.lambda_name, payload_bytes)
|
||||
result = self._invoke_lambda(self.lambda_name, payload)
|
||||
|
||||
if not result:
|
||||
failover_result = self._invoke_lambda(self.failover_lambda_name, payload_bytes)
|
||||
failover_result = self._invoke_lambda(self.failover_lambda_name, payload)
|
||||
if not failover_result:
|
||||
raise CBCProxyException(f'Lambda failed for both {self.lambda_name} and {self.failover_lambda_name}')
|
||||
|
||||
return result
|
||||
|
||||
def _invoke_lambda(self, lambda_name, payload_bytes):
|
||||
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,
|
||||
@@ -168,7 +168,7 @@ class CBCProxyCanary(CBCProxyClientBase):
|
||||
self,
|
||||
identifier,
|
||||
):
|
||||
self._invoke_lambda_with_failover(payload={'identifier': identifier})
|
||||
self._invoke_lambda(self.lambda_name, payload={'identifier': identifier})
|
||||
|
||||
|
||||
class CBCProxyEE(CBCProxyClientBase):
|
||||
|
||||
Reference in New Issue
Block a user