diff --git a/src/sentry/integrations/pagerduty/actions/form.py b/src/sentry/integrations/pagerduty/actions/form.py index 71dff4fa0b6c44..a2ca1331abafb4 100644 --- a/src/sentry/integrations/pagerduty/actions/form.py +++ b/src/sentry/integrations/pagerduty/actions/form.py @@ -49,14 +49,14 @@ def _validate_service(self, service_id: int, integration_id: int) -> None: "service": dict(self.fields["service"].choices).get(service_id), } - ois = integration_service.get_organization_integrations( + org_integrations = integration_service.get_organization_integrations( integration_id=integration_id, providers=[ExternalProviders.PAGERDUTY.name], ) if not any( pds - for oi in ois + for oi in org_integrations for pds in oi.config.get("pagerduty_services", []) if pds["id"] == service_id ): diff --git a/src/sentry/models/integrations/pagerduty_service.py b/src/sentry/models/integrations/pagerduty_service.py index 1996d3f69b2dbc..a2aa0899a37e2a 100644 --- a/src/sentry/models/integrations/pagerduty_service.py +++ b/src/sentry/models/integrations/pagerduty_service.py @@ -13,12 +13,10 @@ class PagerDutyService(DefaultFieldsModel): __include_in_export__ = False - # organization_integration_id = HybridCloudForeignKey( organization_integration = FlexibleForeignKey( "sentry.OrganizationIntegration", on_delete=CASCADE, db_constraint=False ) - # organization_id = BoundedBigIntegerField(db_index=True) organization_id = HybridCloudForeignKey("sentry.Organization", on_delete="cascade") # From a region point of view, you really only have per organization scoping. diff --git a/src/sentry/services/hybrid_cloud/integration/serial.py b/src/sentry/services/hybrid_cloud/integration/serial.py index cc0ffbdcebc00e..062ed105825d54 100644 --- a/src/sentry/services/hybrid_cloud/integration/serial.py +++ b/src/sentry/services/hybrid_cloud/integration/serial.py @@ -17,9 +17,6 @@ def serialize_integration(integration: Integration) -> RpcIntegration: def serialize_organization_integration(oi: OrganizationIntegration) -> RpcOrganizationIntegration: - # if oi.integration - # i for i in integrations if i.provider == ExternalProviders.PAGERDUTY.name - # if config: Dict[str, Any] = dict(**oi.config) if oi.integration.provider == ExternalProviders.PAGERDUTY.name: config["pagerduty_services"] = [ diff --git a/tests/sentry/db/test_silo_models.py b/tests/sentry/db/test_silo_models.py index 9648b2fb40991a..19cf80c1b6b419 100644 --- a/tests/sentry/db/test_silo_models.py +++ b/tests/sentry/db/test_silo_models.py @@ -1,4 +1,5 @@ from sentry.api.serializers.base import registry +from sentry.models import OrganizationIntegration, PagerDutyService from sentry.testutils.silo import ( validate_models_have_silos, validate_no_cross_silo_deletions, @@ -6,7 +7,8 @@ ) decorator_exemptions = set() -fk_exemptions = set() +# Temporary, remove after finishing changes on getsentry side +fk_exemptions = {(PagerDutyService, OrganizationIntegration)} def test_models_have_silos(): diff --git a/tests/sentry/integrations/pagerduty/test_notify_action.py b/tests/sentry/integrations/pagerduty/test_notify_action.py index 6eb4553fd73dc0..f4219a62a6474a 100644 --- a/tests/sentry/integrations/pagerduty/test_notify_action.py +++ b/tests/sentry/integrations/pagerduty/test_notify_action.py @@ -28,13 +28,14 @@ class PagerDutyNotifyActionTest(RuleTestCase, PerformanceIssueTestCase): rule_cls = PagerDutyNotifyServiceAction def setUp(self): - self.integration = Integration.objects.create( - provider="pagerduty", - name="Example", - external_id=EXTERNAL_ID, - metadata={"services": SERVICES}, - ) - self.integration.add_organization(self.organization, self.user) + with assume_test_silo_mode(SiloMode.CONTROL): + self.integration = Integration.objects.create( + provider="pagerduty", + name="Example", + external_id=EXTERNAL_ID, + metadata={"services": SERVICES}, + ) + self.integration.add_organization(self.organization, self.user) self.service = PagerDutyService.objects.create( service_name=SERVICES[0]["service_name"], integration_key=SERVICES[0]["integration_key"],