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

feat(uptime): Enforce per-domain limits #77857

Merged

Conversation

evanpurkhiser
Copy link
Member

Need to fix the test, but this will make it so you can no longer create
more monitors once the per domain limit is reached

@evanpurkhiser evanpurkhiser requested a review from a team as a code owner September 20, 2024 17:32
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 20, 2024
Copy link

codecov bot commented Sep 20, 2024

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
21630 3 21627 205
View the top 3 failed tests by shortest run time
tests.sentry.uptime.endpoints.test_project_uptime_alert_index.ProjectUptimeAlertIndexPostEndpointTest test_mode_superadmin
Stack Traces | 3.77s run time
#x1B[1m#x1B[.../uptime/endpoints/test_project_uptime_alert_index.py#x1B[0m:86: in test_mode_superadmin
    resp = self.get_success_response(
#x1B[1m#x1B[.../sentry/testutils/cases.py#x1B[0m:771: in get_success_response
    assert_status_code(response, 200, 300)
#x1B[1m#x1B[.../sentry/testutils/asserts.py#x1B[0m:39: in assert_status_code
    assert minimum <= response.status_code < maximum, (
#x1B[1m#x1B[31mE   AssertionError: (500, b'{"detail":"Internal Error","errorId":null}')#x1B[0m
#x1B[1m#x1B[31mE   assert 500 < 300#x1B[0m
#x1B[1m#x1B[31mE    +  where 500 = <Response status_code=500, "application/json">.status_code#x1B[0m
tests.sentry.uptime.endpoints.test_project_uptime_alert_index.ProjectUptimeAlertIndexPostEndpointTest test
Stack Traces | 3.81s run time
#x1B[1m#x1B[.../uptime/endpoints/test_project_uptime_alert_index.py#x1B[0m:29: in test
    resp = self.get_success_response(
#x1B[1m#x1B[.../sentry/testutils/cases.py#x1B[0m:771: in get_success_response
    assert_status_code(response, 200, 300)
#x1B[1m#x1B[.../sentry/testutils/asserts.py#x1B[0m:39: in assert_status_code
    assert minimum <= response.status_code < maximum, (
#x1B[1m#x1B[31mE   AssertionError: (500, b'{"detail":"Internal Error","errorId":null}')#x1B[0m
#x1B[1m#x1B[31mE   assert 500 < 300#x1B[0m
#x1B[1m#x1B[31mE    +  where 500 = <Response status_code=500, "application/json">.status_code#x1B[0m
tests.sentry.uptime.endpoints.test_project_uptime_alert_index.ProjectUptimeAlertIndexPostEndpointTest test_no_owner
Stack Traces | 3.97s run time
#x1B[1m#x1B[.../uptime/endpoints/test_project_uptime_alert_index.py#x1B[0m:49: in test_no_owner
    resp = self.get_success_response(
#x1B[1m#x1B[.../sentry/testutils/cases.py#x1B[0m:771: in get_success_response
    assert_status_code(response, 200, 300)
#x1B[1m#x1B[.../sentry/testutils/asserts.py#x1B[0m:39: in assert_status_code
    assert minimum <= response.status_code < maximum, (
#x1B[1m#x1B[31mE   AssertionError: (500, b'{"detail":"Internal Error","errorId":null}')#x1B[0m
#x1B[1m#x1B[31mE   assert 500 < 300#x1B[0m
#x1B[1m#x1B[31mE    +  where 500 = <Response status_code=500, "application/json">.status_code#x1B[0m

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

Comment on lines +52 to +56
url_parts = extract_domain_parts(url)
existing_count = ProjectUptimeSubscription.objects.filter(
uptime_subscription__url_domain=url_parts.domain,
uptime_subscription__url_domain_suffix=url_parts.suffix,
).count()
Copy link
Member

Choose a reason for hiding this comment

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

One thought here is that maybe this should happen specifically in the creation function. Since we have the de-duping, it's valid to create a monitor on an existing url even if we're at the limit, since it doesn't cause any more hits to that url.

Maybe the create function could raise an exception that we catch and translate in save?

Maybe also just an edge case and not a big deal

Copy link
Member Author

Choose a reason for hiding this comment

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

oh right, hmm. But you can edit a monitor to change the url as well right. Yeah I guess it could be an exception.

Let's not worry about it for now.

@evanpurkhiser evanpurkhiser merged commit 89de409 into master Sep 20, 2024
49 checks passed
@evanpurkhiser evanpurkhiser deleted the evanpurkhiser/feat-uptime-enforce-per-domain-limits branch September 20, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants