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

Refactor create_alert task #3759

Merged
merged 5 commits into from
Jan 30, 2024
Merged

Refactor create_alert task #3759

merged 5 commits into from
Jan 30, 2024

Conversation

iskhakov
Copy link
Contributor

@iskhakov iskhakov commented Jan 26, 2024

What this PR does

This PR simplifies alert group/alert creation, so the alert created and escalation started in the same task.

Which issue(s) this PR fixes

Checklist

  • Unit, integration, and e2e (if applicable) tests updated
  • Documentation added (or pr:no public docs PR label added if not required)
  • CHANGELOG.md updated (or pr:no changelog PR label added if not required)

@iskhakov iskhakov force-pushed the iskhakov/refactor-alert-creation branch from 0235c6e to 64fe5e1 Compare January 26, 2024 03:35
Comment on lines 139 to 140
if group_created:
alert_group_escalation_snapshot_built.send(sender=cls.__class__, alert_group=alert.group)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snapshot generation will happen synchronously in this task (previously it was done in distribute_alert)
TODO: check if it is not too heavy

Comment on lines +135 to +137
if group_created or alert.group.pause_escalation:
# Build escalation snapshot if needed and start escalation
alert.group.start_escalation_if_needed(countdown=TASK_DELAY_SECONDS)
Copy link
Contributor Author

@iskhakov iskhakov Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start escalation here
(instead of checking if it is the first alert in distribute alert task https://github.com/grafana/oncall/pull/3759/files#diff-e0f70dd85cf6da1d72318bfb28759b3ebf069a28c16717ac233bf760df488a55R31)

else:
transaction.on_commit(
partial(tasks.distribute_alert.apply_async, (alert.pk,), countdown=TASK_DELAY_SECONDS)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this task anymore
TODO: don't forget to change alerts and dashboards

if not group.acknowledged and mark_as_acknowledged:
group.acknowledge_by_source()

# Create alert
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved alert creation and group creation together
TODO: consider adding transaction

@iskhakov iskhakov marked this pull request as ready for review January 30, 2024 01:20
@iskhakov iskhakov requested a review from a team January 30, 2024 01:20
@iskhakov iskhakov changed the title Refactor alert creation Refactor create_alert task Jan 30, 2024
@iskhakov iskhakov added the pr:no public docs Added to a PR that does not require public documentation updates label Jan 30, 2024
@iskhakov iskhakov added this pull request to the merge queue Jan 30, 2024
Merged via the queue into dev with commit 401d279 Jan 30, 2024
21 checks passed
@iskhakov iskhakov deleted the iskhakov/refactor-alert-creation branch January 30, 2024 08:48
iskhakov added a commit that referenced this pull request Feb 20, 2024
# What this PR does

This PR simplifies alert group/alert creation, so the alert created and
escalation started in the same task.

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants