Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix silence for paused escalations or alert groups with empty escalation chain #2929

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fix issue with helm chart when specifying `broker.type=rabbitmq` where Redis environment variables
were not longer being injected @joeyorlando ([#2927](https://github.com/grafana/oncall/pull/2927))
- Fix silence for alert groups with empty escalation chain @Ferril ([#2929](https://github.com/grafana/oncall/pull/2929))
- Fixed NPE when migrating legacy Grafana Alerting integrations
([#2908](https://github.com/grafana/oncall/issues/2908))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ def update_next_step_eta(self, increase_by_timedelta: datetime.timedelta) -> typ
return None

raw_next_step_eta = self.raw_escalation_snapshot.get("next_step_eta")
if not raw_next_step_eta: # empty escalation chain or paused escalations
return self.raw_escalation_snapshot

next_step_eta = parse(raw_next_step_eta).replace(tzinfo=pytz.UTC)
updated_next_step_eta = next_step_eta + increase_by_timedelta
self.raw_escalation_snapshot["next_step_eta"] = updated_next_step_eta.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
Expand Down
21 changes: 21 additions & 0 deletions engine/apps/alerts/tests/test_escalation_snapshot_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,3 +684,24 @@ def test_update_next_step_eta(
alert_group.refresh_from_db()

assert alert_group.raw_escalation_snapshot["next_step_eta"] == updated_raw_next_step_eta


@pytest.mark.django_db
def test_update_next_step_eta_none(
make_organization_and_user,
make_alert_receive_channel,
make_alert_group,
):
increase_by_timedelta = datetime.timedelta(minutes=120)

organization, _ = make_organization_and_user()
alert_receive_channel = make_alert_receive_channel(organization)
alert_group = make_alert_group(alert_receive_channel)
alert_group.raw_escalation_snapshot = alert_group.build_raw_escalation_snapshot()

assert alert_group.raw_escalation_snapshot is not None
assert alert_group.raw_escalation_snapshot.get("next_step_eta") is None

updated_snapshot = alert_group.update_next_step_eta(increase_by_timedelta)
assert updated_snapshot == alert_group.build_raw_escalation_snapshot()
assert updated_snapshot.get("next_step_eta") is None