# What this PR does This PR: - modifies the `check_escalation_finished_task` celery task to: - do stricter escalation validation based on the alert group's escalation snapshot (see the `audit_alert_group_escalation` method in `engine/apps/alerts/tasks/check_escalation_finished.py` for the validation logic) - use a read-only database for querying alert-groups if one is configured, otherwise use the "default" one - ping a configurable heartbeat (new env var `ALERT_GROUP_ESCALATION_AUDITOR_CELERY_TASK_HEARTBEAT_URL` added) - increase the task frequency from every 10 to every 13 minutes (this can be configured via an env variable) - adds public documentation on how to configure this auditor task - modifies the local celery startup command to properly take into consideration all celery related env vars (similar to the ones we use in `engine/celery_with_exporter.sh`; this made it easier to enable `celery beat` locally for testing) - removes the following code: - removes references to `AlertGroup.estimate_escalation_finish_time` and marks the model field as deprecated using the [`django-deprecate-fields` library](https://pypi.org/project/django-deprecate-fields/). This field was only used for the previous version of this validation task - `EscalationSnapshotMixin.calculate_eta_for_finish_escalation` was only used to calculate the value for `AlertGroup.estimate_escalation_finish_time` - `calculate_escalation_finish_time` celery task ## Which issue(s) this PR fixes https://github.com/grafana/oncall-private/issues/1558 ## Checklist - [x] Tests updated - [x] Documentation added - [x] `CHANGELOG.md` updated
28 lines
1.2 KiB
Python
28 lines
1.2 KiB
Python
from rest_framework import serializers
|
|
|
|
from apps.alerts.escalation_snapshot.serializers import (
|
|
ChannelFilterSnapshotSerializer,
|
|
EscalationChainSnapshotSerializer,
|
|
EscalationPolicySnapshotSerializer,
|
|
)
|
|
|
|
|
|
class EscalationSnapshotSerializer(serializers.Serializer):
|
|
channel_filter_snapshot = ChannelFilterSnapshotSerializer(allow_null=True, default=None)
|
|
escalation_chain_snapshot = EscalationChainSnapshotSerializer(allow_null=True, default=None)
|
|
last_active_escalation_policy_order = serializers.IntegerField(allow_null=True, default=None)
|
|
escalation_policies_snapshots = EscalationPolicySnapshotSerializer(many=True, default=list)
|
|
slack_channel_id = serializers.CharField(allow_null=True, default=None)
|
|
pause_escalation = serializers.BooleanField(allow_null=True, default=False)
|
|
next_step_eta = serializers.DateTimeField(allow_null=True, default=None)
|
|
|
|
class Meta:
|
|
fields = [
|
|
"channel_filter_snapshot",
|
|
"escalation_chain_snapshot",
|
|
"last_active_escalation_policy_order",
|
|
"escalation_policies_snapshots",
|
|
"slack_channel_id",
|
|
"pause_escalation",
|
|
"next_step_eta",
|
|
]
|