Skip to content

Commit

Permalink
ref(hybrid-cloud): Removes all region organization provisioning paths (
Browse files Browse the repository at this point in the history
  • Loading branch information
GabeVillalobos authored Oct 27, 2023
1 parent cb8d0f7 commit 583d15d
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 398 deletions.
4 changes: 1 addition & 3 deletions src/sentry/backup/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
RpcPrimaryKeyMap,
)
from sentry.services.hybrid_cloud.import_export.service import ImportExportService
from sentry.services.organization import should_use_control_provisioning
from sentry.silo.base import SiloMode
from sentry.silo.safety import unguarded_write
from sentry.utils import json
Expand Down Expand Up @@ -261,8 +260,7 @@ def resolve_org_slugs_from_pk_map(pk_map: PrimaryKeyMap):
else:
do_writes(pk_map)

if should_use_control_provisioning():
resolve_org_slugs_from_pk_map(pk_map)
resolve_org_slugs_from_pk_map(pk_map)

if deferred_org_auth_tokens:
do_write(pk_map, org_auth_token_model_name, deferred_org_auth_tokens)
Expand Down
3 changes: 0 additions & 3 deletions src/sentry/options/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -1492,9 +1492,6 @@
)

register("hybrid_cloud.outbox_rate", default=0.0, flags=FLAG_AUTOMATOR_MODIFIABLE)
register(
"hybrid_cloud.control-organization-provisioning", default=False, flags=FLAG_AUTOMATOR_MODIFIABLE
)

# Decides whether an incoming transaction triggers an update of the clustering rule applied to it.
register("txnames.bump-lifetime-sample-rate", default=0.1, flags=FLAG_AUTOMATOR_MODIFIABLE)
Expand Down
16 changes: 6 additions & 10 deletions src/sentry/receivers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
from sentry.models.team import Team
from sentry.services.hybrid_cloud.user.service import user_service
from sentry.services.hybrid_cloud.util import region_silo_function
from sentry.services.organization import (
organization_provisioning_service,
should_use_control_provisioning,
)
from sentry.services.organization import organization_provisioning_service
from sentry.signals import post_upgrade, project_created
from sentry.silo import SiloMode
from sentry.utils.env import in_test_environment
Expand Down Expand Up @@ -110,12 +107,11 @@ def create_default_project(id, name, slug, verbosity=2, **kwargs):
cursor = connection.cursor()
cursor.execute(PROJECT_SEQUENCE_FIX)

if should_use_control_provisioning():
# We need to provision an organization slug in control silo, so we do
# this by "changing" the slug, then re-replicating the org data.
organization_provisioning_service.change_organization_slug(
organization_id=org.id, slug="sentry"
)
# We need to provision an organization slug in control silo, so we do
# this by "changing" the slug, then re-replicating the org data.
organization_provisioning_service.change_organization_slug(
organization_id=org.id, slug="sentry"
)

org.handle_async_replication(org.id)

Expand Down
34 changes: 0 additions & 34 deletions src/sentry/services/hybrid_cloud/organization_actions/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@
from django.utils.text import slugify
from typing_extensions import TypedDict

from sentry import roles
from sentry.models.organization import Organization, OrganizationStatus
from sentry.models.organizationmember import OrganizationMember
from sentry.models.organizationmemberteam import OrganizationMemberTeam
from sentry.models.outbox import outbox_context
from sentry.services.hybrid_cloud.organization_actions.model import (
OrganizationAndMemberCreationResult,
)


class OrganizationCreateAndUpdateOptions(TypedDict, total=False):
Expand All @@ -25,34 +19,6 @@ class OrganizationCreateAndUpdateOptions(TypedDict, total=False):
default_role: int


def create_organization_with_outbox_message(
*, create_options: OrganizationCreateAndUpdateOptions
) -> Organization:
org: Organization = Organization.objects.create(**create_options)
return org


def create_organization_and_member_for_monolith(
organization_name: str,
user_id: int,
slug: str,
create_default_team: bool,
is_test: bool = False,
) -> OrganizationAndMemberCreationResult:
org = Organization.objects.create(name=organization_name, slug=slug, is_test=is_test)

om = OrganizationMember.objects.create(
user_id=user_id, organization=org, role=roles.get_top_dog().id
)

team = None
if create_default_team:
team = org.team_set.create(name=org.name)
OrganizationMemberTeam.objects.create(team=team, organizationmember=om, is_active=True)

return OrganizationAndMemberCreationResult(organization=org, org_member=om, team=team)


def update_organization_with_outbox_message(
*, org_id: int, update_data: OrganizationCreateAndUpdateOptions
) -> Organization:
Expand Down
20 changes: 5 additions & 15 deletions src/sentry/services/hybrid_cloud/organization_mapping/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
RpcOrganizationMappingUpdate,
)
from sentry.services.hybrid_cloud.organization_mapping.serial import serialize_organization_mapping
from sentry.services.organization import should_use_control_provisioning
from sentry.silo import unguarded_write


Expand Down Expand Up @@ -120,24 +119,15 @@ def upsert(self, organization_id: int, update: RpcOrganizationMappingUpdate) ->
update_dict["customer_id"] = update.customer_id[0]

with unguarded_write(using=router.db_for_write(OrganizationMapping)):
use_control_provisioning = should_use_control_provisioning()
if use_control_provisioning:
mapping_is_valid = self._check_organization_mapping_integrity(
org_id=organization_id, update=update
)
if not mapping_is_valid:
return
mapping_is_valid = self._check_organization_mapping_integrity(
org_id=organization_id, update=update
)
if not mapping_is_valid:
return

OrganizationMapping.objects.update_or_create(
organization_id=organization_id, defaults=update_dict
)

if not use_control_provisioning:
# If control provisioning is disabled, we have to manually write a slug
# reservation for the organization.
self._upsert_organization_slug_reservation_for_monolith(
organization_id=organization_id, mapping_update=update
)

def delete(self, organization_id: int) -> None:
OrganizationMapping.objects.filter(organization_id=organization_id).delete()

This file was deleted.

119 changes: 0 additions & 119 deletions src/sentry/services/hybrid_cloud/organization_provisioning/impl.py

This file was deleted.

This file was deleted.

Loading

0 comments on commit 583d15d

Please sign in to comment.