Skip to content

Do not support sub-minute cron intervals#2172

Merged
antonpirker merged 3 commits intomasterfrom
antonpirker/sub-minute-intervals-sentry-crons
Jun 16, 2023
Merged

Do not support sub-minute cron intervals#2172
antonpirker merged 3 commits intomasterfrom
antonpirker/sub-minute-intervals-sentry-crons

Conversation

@antonpirker
Copy link
Contributor

@antonpirker antonpirker commented Jun 15, 2023

In Celery you can run task in intervals shorter than one minute. Sentry crons does not support this, so in a case where a sub-minute interval is specified, just print a warning and do not set a schedule configuration.

Fixes #2168

interval = int(seconds / divider)
return (interval, unit)

return (1, "minute")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before we just set everything that is under one minute to exactly one minute. Now We return the correct second interval.

Comment on lines +402 to +406
if schedule_unit == "second":
logger.warning(
"Intervals shorter than one minute are not supported by Sentry Crons."
)
return {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

And when a second interval is returned, we print a warning and do not return a monitor config (this is the behavior the backend guys requested, because then they ignore the checkins)

Comment on lines +449 to +450
is_supported_schedule = bool(monitor_config)
if is_supported_schedule:
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 now only create the "in_progress" checkin for supported schedule types (so if the schedule is sub-minute interval, the check in will not be sent)

Also because the headers are not set in case it is an unsupported type, the ok/failure checkins will also not be sent.

@antonpirker antonpirker marked this pull request as ready for review June 15, 2023 07:11
Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

lgtm

@antonpirker antonpirker merged commit 4f0ab40 into master Jun 16, 2023
@antonpirker antonpirker deleted the antonpirker/sub-minute-intervals-sentry-crons branch June 16, 2023 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sub minute intervals for Celery Cron integrations

2 participants