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

Retry perform_notification with Telegram ratelimit countdown on RetryAfter error #3744

Merged
merged 5 commits into from
Jan 24, 2024

Conversation

Ferril
Copy link
Member

@Ferril Ferril commented Jan 24, 2024

What this PR does

Use Telegram ratelimit countdown when retry perform_notification task on RetryAfter error

Which issue(s) this PR fixes

https://github.com/grafana/oncall-private/issues/2451

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)

@Ferril Ferril added the pr:no public docs Added to a PR that does not require public documentation updates label Jan 24, 2024
@Ferril Ferril requested a review from a team January 24, 2024 10:19
TelegramToUserConnector.notify_user(user, alert_group, notification_policy)
except RetryAfter as e:
countdown = getattr(e, "retry_after", 3)
perform_notification.retry((log_record_pk,), countdown=countdown, exc=e)
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, I think retry will raise an exception (besides queuing a new task), and since we have the autoretry_for set for Exception, you will end having 2 new tasks from this (the retry because of the exception, and the task added by the retry call). See here too.

Copy link
Member Author

@Ferril Ferril Jan 24, 2024

Choose a reason for hiding this comment

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

hm, thanks for the information 👍 I wasn't able to reproduce it locally though, I can see only one retrying task, but it probably makes sense to change the call to apply_async here just in case 🤔
UPD: or use dont_autoretry_for=(Retry,)

@iskhakov iskhakov self-requested a review January 24, 2024 12:33
@Ferril Ferril requested a review from matiasb January 24, 2024 13:19
@Ferril Ferril added this pull request to the merge queue Jan 24, 2024
Merged via the queue into dev with commit 19cae80 Jan 24, 2024
21 checks passed
@Ferril Ferril deleted the handle-telegram-ratelimit-error branch January 24, 2024 15:40
iskhakov pushed a commit that referenced this pull request Feb 20, 2024
…tryAfter` error (#3744)

# What this PR does
Use Telegram ratelimit countdown when retry `perform_notification` task
on `RetryAfter` error
## Which issue(s) this PR fixes
grafana/oncall-private#2451

## 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] `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.

3 participants