Browse Source

feat(hybrid): Add silo mode limit decorators (#38613)

Apply ./scripts/silo/all_decorators.sh to place SiloLimit decorators
on all applicable classes. Activate SiloLimitCoverageTest.
Ryan Skonnord 2 years ago
parent
commit
aabc784d11

+ 2 - 1
src/sentry/api/endpoints/accept_organization_invite.py

@@ -3,12 +3,13 @@ from rest_framework import status
 from rest_framework.request import Request
 from rest_framework.request import Request
 from rest_framework.response import Response
 from rest_framework.response import Response
 
 
-from sentry.api.base import Endpoint
+from sentry.api.base import Endpoint, region_silo_endpoint
 from sentry.api.invite_helper import ApiInviteHelper, add_invite_cookie, remove_invite_cookie
 from sentry.api.invite_helper import ApiInviteHelper, add_invite_cookie, remove_invite_cookie
 from sentry.models import AuthProvider, OrganizationMember
 from sentry.models import AuthProvider, OrganizationMember
 from sentry.utils import auth
 from sentry.utils import auth
 
 
 
 
+@region_silo_endpoint
 class AcceptOrganizationInvite(Endpoint):
 class AcceptOrganizationInvite(Endpoint):
     # Disable authentication and permission requirements.
     # Disable authentication and permission requirements.
     permission_classes = []
     permission_classes = []

+ 2 - 1
src/sentry/api/endpoints/accept_project_transfer.py

@@ -6,7 +6,7 @@ from rest_framework.request import Request
 from rest_framework.response import Response
 from rest_framework.response import Response
 
 
 from sentry import audit_log, roles
 from sentry import audit_log, roles
-from sentry.api.base import Endpoint, SessionAuthentication
+from sentry.api.base import Endpoint, SessionAuthentication, region_silo_endpoint
 from sentry.api.decorators import sudo_required
 from sentry.api.decorators import sudo_required
 from sentry.api.serializers import serialize
 from sentry.api.serializers import serialize
 from sentry.api.serializers.models.organization import (
 from sentry.api.serializers.models.organization import (
@@ -21,6 +21,7 @@ class InvalidPayload(Exception):
     pass
     pass
 
 
 
 
+@region_silo_endpoint
 class AcceptProjectTransferEndpoint(Endpoint):
 class AcceptProjectTransferEndpoint(Endpoint):
     authentication_classes = (SessionAuthentication,)
     authentication_classes = (SessionAuthentication,)
     permission_classes = (IsAuthenticated,)
     permission_classes = (IsAuthenticated,)

+ 2 - 1
src/sentry/api/endpoints/api_application_details.py

@@ -4,7 +4,7 @@ from rest_framework.permissions import IsAuthenticated
 from rest_framework.request import Request
 from rest_framework.request import Request
 from rest_framework.response import Response
 from rest_framework.response import Response
 
 
-from sentry.api.base import Endpoint, SessionAuthentication
+from sentry.api.base import Endpoint, SessionAuthentication, pending_silo_endpoint
 from sentry.api.exceptions import ResourceDoesNotExist
 from sentry.api.exceptions import ResourceDoesNotExist
 from sentry.api.serializers import serialize
 from sentry.api.serializers import serialize
 from sentry.api.serializers.rest_framework import ListField
 from sentry.api.serializers.rest_framework import ListField
@@ -30,6 +30,7 @@ class ApiApplicationSerializer(serializers.Serializer):
     )
     )
 
 
 
 
+@pending_silo_endpoint
 class ApiApplicationDetailsEndpoint(Endpoint):
 class ApiApplicationDetailsEndpoint(Endpoint):
     authentication_classes = (SessionAuthentication,)
     authentication_classes = (SessionAuthentication,)
     permission_classes = (IsAuthenticated,)
     permission_classes = (IsAuthenticated,)

+ 2 - 1
src/sentry/api/endpoints/api_applications.py

@@ -2,12 +2,13 @@ from rest_framework.permissions import IsAuthenticated
 from rest_framework.request import Request
 from rest_framework.request import Request
 from rest_framework.response import Response
 from rest_framework.response import Response
 
 
-from sentry.api.base import Endpoint, SessionAuthentication
+from sentry.api.base import Endpoint, SessionAuthentication, pending_silo_endpoint
 from sentry.api.paginator import OffsetPaginator
 from sentry.api.paginator import OffsetPaginator
 from sentry.api.serializers import serialize
 from sentry.api.serializers import serialize
 from sentry.models import ApiApplication, ApiApplicationStatus
 from sentry.models import ApiApplication, ApiApplicationStatus
 
 
 
 
+@pending_silo_endpoint
 class ApiApplicationsEndpoint(Endpoint):
 class ApiApplicationsEndpoint(Endpoint):
     authentication_classes = (SessionAuthentication,)
     authentication_classes = (SessionAuthentication,)
     permission_classes = (IsAuthenticated,)
     permission_classes = (IsAuthenticated,)

+ 2 - 1
src/sentry/api/endpoints/api_authorizations.py

@@ -3,12 +3,13 @@ from rest_framework.permissions import IsAuthenticated
 from rest_framework.request import Request
 from rest_framework.request import Request
 from rest_framework.response import Response
 from rest_framework.response import Response
 
 
-from sentry.api.base import Endpoint, SessionAuthentication
+from sentry.api.base import Endpoint, SessionAuthentication, pending_silo_endpoint
 from sentry.api.paginator import OffsetPaginator
 from sentry.api.paginator import OffsetPaginator
 from sentry.api.serializers import serialize
 from sentry.api.serializers import serialize
 from sentry.models import ApiApplicationStatus, ApiAuthorization, ApiToken
 from sentry.models import ApiApplicationStatus, ApiAuthorization, ApiToken
 
 
 
 
+@pending_silo_endpoint
 class ApiAuthorizationsEndpoint(Endpoint):
 class ApiAuthorizationsEndpoint(Endpoint):
     authentication_classes = (SessionAuthentication,)
     authentication_classes = (SessionAuthentication,)
     permission_classes = (IsAuthenticated,)
     permission_classes = (IsAuthenticated,)

+ 2 - 1
src/sentry/api/endpoints/api_tokens.py

@@ -4,7 +4,7 @@ from rest_framework.permissions import IsAuthenticated
 from rest_framework.request import Request
 from rest_framework.request import Request
 from rest_framework.response import Response
 from rest_framework.response import Response
 
 
-from sentry.api.base import Endpoint, SessionAuthentication
+from sentry.api.base import Endpoint, SessionAuthentication, pending_silo_endpoint
 from sentry.api.fields import MultipleChoiceField
 from sentry.api.fields import MultipleChoiceField
 from sentry.api.serializers import serialize
 from sentry.api.serializers import serialize
 from sentry.models import ApiToken
 from sentry.models import ApiToken
@@ -15,6 +15,7 @@ class ApiTokenSerializer(serializers.Serializer):
     scopes = MultipleChoiceField(required=True, choices=settings.SENTRY_SCOPES)
     scopes = MultipleChoiceField(required=True, choices=settings.SENTRY_SCOPES)
 
 
 
 
+@pending_silo_endpoint
 class ApiTokensEndpoint(Endpoint):
 class ApiTokensEndpoint(Endpoint):
     authentication_classes = (SessionAuthentication,)
     authentication_classes = (SessionAuthentication,)
     permission_classes = (IsAuthenticated,)
     permission_classes = (IsAuthenticated,)

+ 2 - 1
src/sentry/api/endpoints/assistant.py

@@ -8,7 +8,7 @@ from rest_framework.permissions import IsAuthenticated
 from rest_framework.request import Request
 from rest_framework.request import Request
 from rest_framework.response import Response
 from rest_framework.response import Response
 
 
-from sentry.api.base import Endpoint
+from sentry.api.base import Endpoint, pending_silo_endpoint
 from sentry.assistant import manager
 from sentry.assistant import manager
 from sentry.models import AssistantActivity
 from sentry.models import AssistantActivity
 
 
@@ -46,6 +46,7 @@ class AssistantSerializer(serializers.Serializer):
         return attrs
         return attrs
 
 
 
 
+@pending_silo_endpoint
 class AssistantEndpoint(Endpoint):
 class AssistantEndpoint(Endpoint):
     permission_classes = (IsAuthenticated,)
     permission_classes = (IsAuthenticated,)
 
 

+ 2 - 1
src/sentry/api/endpoints/auth_config.py

@@ -5,7 +5,7 @@ from rest_framework.request import Request
 from rest_framework.response import Response
 from rest_framework.response import Response
 
 
 from sentry import newsletter
 from sentry import newsletter
-from sentry.api.base import Endpoint
+from sentry.api.base import Endpoint, control_silo_endpoint
 from sentry.constants import WARN_SESSION_EXPIRED
 from sentry.constants import WARN_SESSION_EXPIRED
 from sentry.http import get_server_hostname
 from sentry.http import get_server_hostname
 from sentry.models import Organization
 from sentry.models import Organization
@@ -19,6 +19,7 @@ from sentry.web.frontend.auth_login import additional_context
 from sentry.web.frontend.base import OrganizationMixin
 from sentry.web.frontend.base import OrganizationMixin
 
 
 
 
+@control_silo_endpoint
 class AuthConfigEndpoint(Endpoint, OrganizationMixin):
 class AuthConfigEndpoint(Endpoint, OrganizationMixin):
     # Disable authentication and permission requirements.
     # Disable authentication and permission requirements.
     permission_classes = []
     permission_classes = []

+ 2 - 1
src/sentry/api/endpoints/auth_index.py

@@ -11,7 +11,7 @@ from rest_framework.response import Response
 
 
 from sentry import features
 from sentry import features
 from sentry.api.authentication import QuietBasicAuthentication
 from sentry.api.authentication import QuietBasicAuthentication
-from sentry.api.base import Endpoint
+from sentry.api.base import Endpoint, control_silo_endpoint
 from sentry.api.exceptions import SsoRequired
 from sentry.api.exceptions import SsoRequired
 from sentry.api.serializers import DetailedSelfUserSerializer, serialize
 from sentry.api.serializers import DetailedSelfUserSerializer, serialize
 from sentry.api.validators import AuthVerifyValidator
 from sentry.api.validators import AuthVerifyValidator
@@ -36,6 +36,7 @@ DISABLE_SU_FORM_U2F_CHECK_FOR_LOCAL = getattr(
 )
 )
 
 
 
 
+@control_silo_endpoint
 class AuthIndexEndpoint(Endpoint):
 class AuthIndexEndpoint(Endpoint):
     """
     """
     Manage session authentication
     Manage session authentication

+ 2 - 1
src/sentry/api/endpoints/auth_login.py

@@ -2,7 +2,7 @@ from rest_framework.request import Request
 from rest_framework.response import Response
 from rest_framework.response import Response
 
 
 from sentry import ratelimits as ratelimiter
 from sentry import ratelimits as ratelimiter
-from sentry.api.base import Endpoint
+from sentry.api.base import Endpoint, control_silo_endpoint
 from sentry.api.serializers.base import serialize
 from sentry.api.serializers.base import serialize
 from sentry.api.serializers.models.user import DetailedSelfUserSerializer
 from sentry.api.serializers.models.user import DetailedSelfUserSerializer
 from sentry.utils import auth, metrics
 from sentry.utils import auth, metrics
@@ -11,6 +11,7 @@ from sentry.web.forms.accounts import AuthenticationForm
 from sentry.web.frontend.base import OrganizationMixin
 from sentry.web.frontend.base import OrganizationMixin
 
 
 
 
+@control_silo_endpoint
 class AuthLoginEndpoint(Endpoint, OrganizationMixin):
 class AuthLoginEndpoint(Endpoint, OrganizationMixin):
     # Disable authentication and permission requirements.
     # Disable authentication and permission requirements.
     permission_classes = []
     permission_classes = []

Some files were not shown because too many files changed in this diff