mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 08:21:13 -05:00
dont try and send broadccast event if it's already in technical-failure
this gives us an option to manually set a status in the database and avoid things being stuck in a retry loop forever
This commit is contained in:
@@ -51,6 +51,15 @@ def check_provider_message_should_send(broadcast_event, provider):
|
|||||||
4. If you need to re-send this task off again, you'll need to run the following command on paas:
|
4. If you need to re-send this task off again, you'll need to run the following command on paas:
|
||||||
`send_broadcast_provider_message.apply_async(args=(broadcast_event_id, provider), queue=QueueNames.BROADCASTS)`
|
`send_broadcast_provider_message.apply_async(args=(broadcast_event_id, provider), queue=QueueNames.BROADCASTS)`
|
||||||
"""
|
"""
|
||||||
|
current_provider_message = broadcast_event.get_provider_message(provider)
|
||||||
|
# if this is the first time a task is being executed, it won't have a provider message yet
|
||||||
|
if current_provider_message and current_provider_message.status == BroadcastProviderMessageStatus.TECHNICAL_FAILURE:
|
||||||
|
raise CBCProxyFatalException(
|
||||||
|
f'Cannot send broadcast_event {broadcast_event.id} ' +
|
||||||
|
f'to provider {provider}: ' +
|
||||||
|
f'It is already in status technical-failure'
|
||||||
|
)
|
||||||
|
|
||||||
if broadcast_event.transmitted_finishes_at < datetime.utcnow():
|
if broadcast_event.transmitted_finishes_at < datetime.utcnow():
|
||||||
# TODO: This should be a different kind of exception to distinguish "We should know something went wrong, but
|
# TODO: This should be a different kind of exception to distinguish "We should know something went wrong, but
|
||||||
# no immediate action" from "We need to fix this immediately"
|
# no immediate action" from "We need to fix this immediately"
|
||||||
|
|||||||
@@ -709,8 +709,10 @@ def test_check_provider_message_should_send_doesnt_raise_if_newer_event_not_acke
|
|||||||
BroadcastProviderMessageStatus.ACK,
|
BroadcastProviderMessageStatus.ACK,
|
||||||
BroadcastProviderMessageStatus.ERR,
|
BroadcastProviderMessageStatus.ERR,
|
||||||
|
|
||||||
# TODO: Make this case fail - so we have a way of aborting a send if it's stuck in retry loop
|
pytest.param(
|
||||||
BroadcastProviderMessageStatus.TECHNICAL_FAILURE,
|
BroadcastProviderMessageStatus.TECHNICAL_FAILURE,
|
||||||
|
marks=pytest.mark.xfail(raises=CBCProxyFatalException)
|
||||||
|
),
|
||||||
])
|
])
|
||||||
def test_check_provider_message_should_send_doesnt_raise_if_current_event_already_has_provider_message(
|
def test_check_provider_message_should_send_doesnt_raise_if_current_event_already_has_provider_message(
|
||||||
sample_template,
|
sample_template,
|
||||||
|
|||||||
Reference in New Issue
Block a user