add CBC_PROXY_ENABLED config flag to control if tasks are triggered

previously we made some incorrect assumptions about set-up on staging
and prod - they currently don't have any cbc_proxy aws creds at all.

We shoudn't be attempting canaries or link tests when there's no AWS
infrastructure to connect to.

We also shouldn't bother writing a row into the database at all for the
broadcast_provider_message since we're not even attempting to send, and
we shouldn't get confused between messages that failed and messages we
never wanted to send at all.
This commit is contained in:
Leo Hemsted
2020-11-25 17:39:32 +00:00
parent 54fecf2182
commit e2fa0116a0
7 changed files with 57 additions and 8 deletions

View File

@@ -298,13 +298,15 @@ def check_for_services_with_high_failure_rates_or_sending_to_tv_numbers():
@notify_celery.task(name='send-canary-to-cbc-proxy')
def send_canary_to_cbc_proxy():
identifier = str(uuid.uuid4())
message = f"Sending a canary message to CBC proxy with ID {identifier}"
current_app.logger.info(message)
cbc_proxy_client.get_proxy('canary').send_canary(identifier)
if current_app.config['CBC_PROXY_ENABLED']:
identifier = str(uuid.uuid4())
message = f"Sending a canary message to CBC proxy with ID {identifier}"
current_app.logger.info(message)
cbc_proxy_client.get_proxy('canary').send_canary(identifier)
@notify_celery.task(name='trigger-link-tests')
def trigger_link_tests():
for cbc_name in current_app.config['ENABLED_CBCS']:
trigger_link_test.apply_async(kwargs={'provider': cbc_name}, queue=QueueNames.NOTIFY)
if current_app.config['CBC_PROXY_ENABLED']:
for cbc_name in current_app.config['ENABLED_CBCS']:
trigger_link_test.apply_async(kwargs={'provider': cbc_name}, queue=QueueNames.NOTIFY)