# What this PR does - Since send_alert_create_signal is inside transaction on_commit we can conclude that if it does not exist it was intentionally deleted before the task could run and the task can exit instead of retrying - Improve logging when send_alert_create_signal is called so both alert and alert group are in the same line so you don't need to search the logs as much - Improve logging on public api delete alert group so we can know what the alert group belonged to and the responsible user/org - Remove distribute_alerts (Stopped using a while back, code should be safe to remove now, no tasks running in system) ## Which issue(s) this PR closes Closes https://github.com/grafana/oncall-private/issues/2640 <!-- *Note*: if you have more than one GitHub issue that this PR closes, be sure to preface each issue link with a [closing keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue). This ensures that the issue(s) are auto-closed once the PR has been merged. --> ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] Added the relevant release notes label (see labels prefixed w/ `release:`). These labels dictate how your PR will show up in the autogenerated release notes.
27 lines
1,007 B
Python
27 lines
1,007 B
Python
from django.conf import settings
|
|
|
|
from apps.alerts.signals import alert_create_signal
|
|
from common.custom_celery_tasks import shared_dedicated_queue_retry_task
|
|
|
|
from .task_logger import task_logger
|
|
|
|
|
|
@shared_dedicated_queue_retry_task(
|
|
autoretry_for=(Exception,), retry_backoff=True, max_retries=1 if settings.DEBUG else None
|
|
)
|
|
def send_alert_create_signal(alert_id):
|
|
from apps.alerts.models import Alert, AlertReceiveChannel
|
|
|
|
task_logger.debug(f"Started send_alert_create_signal task for alert {alert_id}")
|
|
try:
|
|
alert = Alert.objects.get(pk=alert_id)
|
|
except Alert.DoesNotExist:
|
|
task_logger.info(f"Alert {alert_id} does not exist, likely parent alert group was deleted")
|
|
return
|
|
|
|
if alert.group.channel.maintenance_mode != AlertReceiveChannel.MAINTENANCE:
|
|
alert_create_signal.send(
|
|
sender=send_alert_create_signal,
|
|
alert=alert_id,
|
|
)
|
|
task_logger.debug(f"Finished send_alert_create_signal task for alert {alert_id} ")
|