-
Notifications
You must be signed in to change notification settings - Fork 507
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
Do not support sub-minute cron intervals #2172
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,7 +375,7 @@ def _get_humanized_interval(seconds): | |
interval = int(seconds / divider) | ||
return (interval, unit) | ||
|
||
return (1, "minute") | ||
return (int(seconds), "second") | ||
|
||
|
||
def _get_monitor_config(celery_schedule, app): | ||
|
@@ -400,6 +400,12 @@ def _get_monitor_config(celery_schedule, app): | |
celery_schedule.seconds | ||
) | ||
|
||
if schedule_unit == "second": | ||
logger.warning( | ||
"Intervals shorter than one minute are not supported by Sentry Crons." | ||
) | ||
return {} | ||
Comment on lines
+403
to
+407
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
||
|
||
else: | ||
logger.warning( | ||
"Celery schedule type '%s' not supported by Sentry Crons.", | ||
|
@@ -441,24 +447,27 @@ def sentry_apply_entry(*args, **kwargs): | |
|
||
monitor_config = _get_monitor_config(celery_schedule, app) | ||
|
||
headers = schedule_entry.options.pop("headers", {}) | ||
headers.update( | ||
{ | ||
"sentry-monitor-slug": monitor_name, | ||
"sentry-monitor-config": monitor_config, | ||
} | ||
) | ||
|
||
check_in_id = capture_checkin( | ||
monitor_slug=monitor_name, | ||
monitor_config=monitor_config, | ||
status=MonitorStatus.IN_PROGRESS, | ||
) | ||
headers.update({"sentry-monitor-check-in-id": check_in_id}) | ||
is_supported_schedule = bool(monitor_config) | ||
if is_supported_schedule: | ||
Comment on lines
+450
to
+451
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
headers = schedule_entry.options.pop("headers", {}) | ||
headers.update( | ||
{ | ||
"sentry-monitor-slug": monitor_name, | ||
"sentry-monitor-config": monitor_config, | ||
} | ||
) | ||
|
||
check_in_id = capture_checkin( | ||
monitor_slug=monitor_name, | ||
monitor_config=monitor_config, | ||
status=MonitorStatus.IN_PROGRESS, | ||
) | ||
headers.update({"sentry-monitor-check-in-id": check_in_id}) | ||
|
||
# Set the Sentry configuration in the options of the ScheduleEntry. | ||
# Those will be picked up in `apply_async` and added to the headers. | ||
schedule_entry.options["headers"] = headers | ||
|
||
# Set the Sentry configuration in the options of the ScheduleEntry. | ||
# Those will be picked up in `apply_async` and added to the headers. | ||
schedule_entry.options["headers"] = headers | ||
return original_apply_entry(*args, **kwargs) | ||
|
||
Scheduler.apply_entry = sentry_apply_entry | ||
|
There was a problem hiding this comment.
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.