Skip to content
Merged
2 changes: 0 additions & 2 deletions src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3290,8 +3290,6 @@ def custom_parameter_sort(parameter: dict) -> tuple[str, int]:
{
"name": "us",
"snowflake_id": 1,
# TODO(cells): Deprecate category
"category": "MULTI_TENANT",
Comment thread
cursor[bot] marked this conversation as resolved.
"address": f"http://127.0.0.1:{region_port}",
}
]
Expand Down
1 change: 0 additions & 1 deletion src/sentry/conf/types/cell_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class CellConfig(TypedDict):
name: str
snowflake_id: int
address: str
Comment thread
sentry[bot] marked this conversation as resolved.
category: str # TODO(cells): drop once category is fully moved to LocalityConfig
api_gateway_address: NotRequired[str]
visible: NotRequired[bool]

Expand Down
4 changes: 2 additions & 2 deletions src/sentry/testutils/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from django.test import override_settings

from sentry.types.cell import Cell, CellDirectory, Locality, get_global_directory
from sentry.types.cell import Cell, CellDirectory, Locality, RegionCategory, get_global_directory


class TestEnvCellDirectory(CellDirectory):
Expand All @@ -24,7 +24,7 @@ def _apply_cells(
Locality(
name=c.name,
cells=frozenset([c.name]),
category=c.category,
category=RegionCategory.MULTI_TENANT,
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
visible=c.visible,
new_org_cell=c.name,
)
Expand Down
3 changes: 1 addition & 2 deletions src/sentry/testutils/helpers/apigateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from sentry.api.bases.organization import ControlSiloOrganizationEndpoint, OrganizationEndpoint
from sentry.feedback.endpoints.error_page_embed import ErrorEmbedResolver
from sentry.testutils.cases import APITestCase
from sentry.types.cell import Cell, RegionCategory
from sentry.types.cell import Cell
from sentry.utils import json


Expand Down Expand Up @@ -243,7 +243,6 @@ class ApiGatewayTestCase(APITestCase):
name="us",
snowflake_id=1,
address="http://us.internal.sentry.io",
category=RegionCategory.MULTI_TENANT,
)

def setUp(self):
Expand Down
3 changes: 1 addition & 2 deletions src/sentry/testutils/pytest/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from sentry.testutils.pytest import xdist
from sentry.testutils.silo import monkey_patch_single_process_silo_mode_state
from sentry.types import cell
from sentry.types.cell import Cell, RegionCategory
from sentry.types.cell import Cell
from sentry.utils.warnings import UnsupportedBackend

K = TypeVar("K")
Expand Down Expand Up @@ -82,7 +82,6 @@ def _configure_test_env_cells() -> None:
cell_name,
cell_snowflake_id,
settings.SENTRY_OPTIONS["system.url-prefix"],
RegionCategory.MULTI_TENANT,
)

settings.SENTRY_LOCAL_CELL = cell_name
Expand Down
10 changes: 2 additions & 8 deletions src/sentry/testutils/silo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from sentry.silo.base import SiloMode, SingleProcessSiloModeState
from sentry.silo.safety import match_fence_query
from sentry.testutils.cell import get_test_env_directory, override_cells
from sentry.types.cell import Cell, RegionCategory
from sentry.types.cell import Cell
from sentry.utils.snowflake import uses_snowflake_id

if typing.TYPE_CHECKING:
Expand Down Expand Up @@ -79,20 +79,14 @@ def get_cell() -> Cell | None:
SingleProcessSiloModeState.get_cell = staticmethod(get_cell) # type: ignore[method-assign]


def create_test_cells(*names: str, single_tenants: Iterable[str] = ()) -> tuple[Cell, ...]:
def create_test_cells(*names: str) -> tuple[Cell, ...]:
from sentry.api.utils import generate_locality_url

single_tenants = frozenset(single_tenants)
return tuple(
Cell(
name=name,
snowflake_id=index + 1,
address=generate_locality_url(name),
category=(
RegionCategory.SINGLE_TENANT
if name in single_tenants
else RegionCategory.MULTI_TENANT
),
)
for (index, name) in enumerate(names)
)
Expand Down
15 changes: 5 additions & 10 deletions src/sentry/types/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ class Cell:
and `system.region-api-url-template`
"""

# TODO(cells): drop once category is fully moved to Locality
category: RegionCategory

api_gateway_address: str | None = None
"""optional address for API gateway traffic."""

Comment thread
sentry[bot] marked this conversation as resolved.
Expand Down Expand Up @@ -245,7 +242,6 @@ def _parse_raw_config(cell_config: list[CellConfig]) -> Iterable[Cell]:
yield Cell(
name=config_value["name"],
snowflake_id=config_value["snowflake_id"],
category=RegionCategory(config_value["category"]),
address=config_value["address"],
api_gateway_address=config_value.get("api_gateway_address", None),
visible=config_value.get("visible", True),
Expand All @@ -264,11 +260,10 @@ def generate_monolith_cell_directory() -> CellDirectory:
name=settings.SENTRY_MONOLITH_REGION,
snowflake_id=0,
address=options.get("system.url-prefix"),
category=RegionCategory.MULTI_TENANT,
)
locality = Locality(
name=cell.name,
category=cell.category,
category=RegionCategory.MULTI_TENANT,
cells=frozenset([cell.name]),
new_org_cell=cell.name,
visible=cell.visible,
Expand All @@ -290,18 +285,18 @@ def _parse_locality_config(


def load_from_config(
region_config: list[CellConfig],
cell_config: list[CellConfig],
locality_config: list[LocalityConfig],
) -> CellDirectory:
try:
if not region_config and not locality_config:
if not cell_config and not locality_config:
return generate_monolith_cell_directory()
cells = set(_parse_raw_config(region_config))
cells = set(_parse_raw_config(cell_config))
localities = set(_parse_locality_config(locality_config))
return CellDirectory(cells, localities)
except Exception as e:
sentry_sdk.capture_exception(e)
raise CellConfigurationError("Unable to parse region_config.") from e
raise CellConfigurationError("Unable to parse cell config.") from e


_global_directory: CellDirectory | None = None
Expand Down
1 change: 0 additions & 1 deletion src/sentry/web/client_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ def cells(self) -> list[Mapping[str, Any]]:
def cell_display_order(cell: Cell) -> tuple[bool, bool, bool, str]:
return (
cell.name != settings.SENTRY_MONOLITH_REGION, # default historical cell comes first
cell.category != RegionCategory.MULTI_TENANT, # multi-tenant before single
Comment thread
cursor[bot] marked this conversation as resolved.
not cell.visible, # visible cells first
cell.name, # then sort alphabetically
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from sentry.testutils.hybrid_cloud import HybridCloudTestMixin
from sentry.testutils.outbox import outbox_runner
from sentry.testutils.silo import assume_test_silo_mode_of, control_silo_test
from sentry.types.cell import Cell, RegionCategory
from sentry.types.cell import Cell


@control_silo_test
Expand Down Expand Up @@ -144,8 +144,8 @@ def test_multi_region_organizationmember_id(self) -> None:
organization_id=self.organization.id
).cell_name
regions = [
Cell("some-region", 10, "http://blah", RegionCategory.MULTI_TENANT),
Cell(org_region_name, 2, "http://moo", RegionCategory.MULTI_TENANT),
Cell("some-region", 10, "http://blah"),
Cell(org_region_name, 2, "http://moo"),
]
with override_cells(regions), override_settings(SENTRY_MONOLITH_REGION=org_region_name):
with unguarded_write(using=router.db_for_write(OrganizationMapping)):
Expand Down
5 changes: 0 additions & 5 deletions tests/sentry/core/endpoints/test_organization_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,18 @@ def test_locality_to_cell_resolution(self) -> None:
Cell(
name="us",
snowflake_id=1,
category=RegionCategory.MULTI_TENANT,
address="10.0.0.1",
visible=True,
),
Cell(
name="us2",
snowflake_id=3,
category=RegionCategory.MULTI_TENANT,
address="10.0.0.2",
visible=True,
),
Cell(
name="de",
snowflake_id=4,
category=RegionCategory.MULTI_TENANT,
address="10.0.0.4",
visible=True,
),
Expand Down Expand Up @@ -318,14 +315,12 @@ def test_staff_user_override_cell_visiblity(self) -> None:
Cell(
name="ja",
snowflake_id=3,
category=RegionCategory.MULTI_TENANT,
address="10.0.0.2",
visible=False,
),
Cell(
name="acme",
snowflake_id=4,
category=RegionCategory.SINGLE_TENANT,
address="10.0.0.4",
visible=True,
),
Expand Down
3 changes: 1 addition & 2 deletions tests/sentry/feedback/endpoints/test_error_page_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from sentry.testutils.helpers.response import close_streaming_response
from sentry.testutils.outbox import outbox_runner
from sentry.testutils.silo import control_silo_test
from sentry.types.cell import Cell, RegionCategory, get_cell_by_name, get_local_locality
from sentry.types.cell import Cell, get_cell_by_name, get_local_locality
from sentry.utils import json


Expand Down Expand Up @@ -367,7 +367,6 @@ def _check_response(resp: Response, expected_name: str) -> None:
name="eu",
snowflake_id=2,
address="http://eu.internal.sentry.io",
category=RegionCategory.MULTI_TENANT,
)


Expand Down
3 changes: 1 addition & 2 deletions tests/sentry/hybridcloud/apigateway/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from sentry.testutils.helpers.options import override_options
from sentry.testutils.helpers.response import close_streaming_response
from sentry.testutils.silo import control_silo_test
from sentry.types.cell import Cell, RegionCategory
from sentry.types.cell import Cell
from sentry.utils import json

proxy_request = async_to_sync(_proxy_request)
Expand Down Expand Up @@ -401,7 +401,6 @@ def raise_connect_error(request: httpx.Request) -> NoReturn:
snowflake_id=1,
address="http://sentry-rpc:8999",
api_gateway_address="http://sentry-api-gateway-rpc:8999",
category=RegionCategory.MULTI_TENANT,
)


Expand Down
4 changes: 2 additions & 2 deletions tests/sentry/hybridcloud/models/test_outbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from sentry.testutils.helpers.datetime import freeze_time
from sentry.testutils.outbox import outbox_runner
from sentry.testutils.silo import assume_test_silo_mode, assume_test_silo_mode_of, control_silo_test
from sentry.types.cell import Cell, RegionCategory, get_local_cell
from sentry.types.cell import Cell, get_local_cell
from sentry.users.models.user import User


Expand All @@ -52,7 +52,7 @@ def setup_clear_fixture_outbox_messages() -> None:

@control_silo_test
class ControlOutboxTest(TestCase):
region = Cell("eu", 1, "http://eu.testserver", RegionCategory.MULTI_TENANT)
region = Cell("eu", 1, "http://eu.testserver")
region_config = (region,)

def test_skip_shards(self) -> None:
Expand Down
5 changes: 2 additions & 3 deletions tests/sentry/hybridcloud/tasks/test_deliver_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@
from sentry.testutils.factories import Factories
from sentry.testutils.helpers.options import override_options
from sentry.testutils.silo import control_silo_test
from sentry.types.cell import Cell, CellResolutionError, RegionCategory
from sentry.types.cell import Cell, CellResolutionError

cell_config = [Cell("us", 1, "http://us.testserver", RegionCategory.MULTI_TENANT)]
cell_config = [Cell("us", 1, "http://us.testserver")]
cell_config_with_gateway = [
Cell(
name="us",
snowflake_id=1,
address="http://us.testserver",
api_gateway_address="http://sentry-rpc-gateway",
category=RegionCategory.MULTI_TENANT,
)
]

Expand Down
6 changes: 3 additions & 3 deletions tests/sentry/hybridcloud/test_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
from sentry.testutils.cases import TestCase
from sentry.testutils.cell import override_cells
from sentry.testutils.silo import assume_test_silo_mode, control_silo_test
from sentry.types.cell import Cell, CellResolutionError, RegionCategory
from sentry.types.cell import Cell, CellResolutionError

_TEST_CELLS = (
Cell("north_america", 1, "na.sentry.io", RegionCategory.MULTI_TENANT),
Cell("europe", 2, "eu.sentry.io", RegionCategory.MULTI_TENANT),
Cell("north_america", 1, "na.sentry.io"),
Cell("europe", 2, "eu.sentry.io"),
)


Expand Down
7 changes: 2 additions & 5 deletions tests/sentry/hybridcloud/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@
from sentry.testutils.cell import override_cells
from sentry.testutils.helpers import override_options
from sentry.testutils.silo import assume_test_silo_mode, no_silo_test
from sentry.types.cell import Cell, RegionCategory
from sentry.types.cell import Cell
from sentry.users.services.user import RpcUser
from sentry.users.services.user.serial import serialize_rpc_user
from sentry.utils import json

_CELLS = [
Cell("north_america", 1, "http://na.sentry.io", RegionCategory.MULTI_TENANT),
Cell("europe", 2, "http://eu.sentry.io", RegionCategory.MULTI_TENANT),
]
_CELLS = [Cell("north_america", 1, "http://na.sentry.io"), Cell("europe", 2, "http://eu.sentry.io")]


@no_silo_test
Expand Down
6 changes: 3 additions & 3 deletions tests/sentry/integrations/jira/test_sentry_issue_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from sentry.testutils.cases import APITestCase
from sentry.testutils.silo import assume_test_silo_mode, assume_test_silo_mode_of, control_silo_test
from sentry.testutils.skips import requires_snuba
from sentry.types.cell import Cell, RegionCategory
from sentry.types.cell import Cell
from sentry.utils.http import absolute_uri

pytestmark = [requires_snuba]
Expand All @@ -25,8 +25,8 @@
REFRESH_REQUIRED = b"This page has expired, please refresh to view the Sentry issue"
CLICK_TO_FINISH = b"Click to Finish Installation"

us = Cell("us", 1, "https://us.testserver", RegionCategory.MULTI_TENANT)
de = Cell("de", 2, "https://de.testserver", RegionCategory.MULTI_TENANT)
us = Cell("us", 1, "https://us.testserver")
de = Cell("de", 2, "https://de.testserver")
region_config = (us, de)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sentry.silo.base import SiloLimit, SiloMode
from sentry.testutils.asserts import assert_failure_metric, assert_halt_metric
from sentry.testutils.cases import TestCase
from sentry.types.cell import Cell, RegionCategory
from sentry.types.cell import Cell


def error_regions(region: Cell, invalid_region_names: Iterable[str]) -> HttpResponse:
Expand All @@ -34,8 +34,8 @@ class ExampleRequestParser(BaseRequestParser):
class BaseRequestParserTest(TestCase):
response_handler = MagicMock()
region_config = [
Cell("us", 1, "https://us.testserver", RegionCategory.MULTI_TENANT),
Cell("eu", 2, "https://eu.testserver", RegionCategory.MULTI_TENANT),
Cell("us", 1, "https://us.testserver"),
Cell("eu", 2, "https://eu.testserver"),
]
factory = RequestFactory()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from sentry.testutils.cell import override_cells
from sentry.testutils.outbox import assert_no_webhook_payloads, assert_webhook_payloads_for_mailbox
from sentry.testutils.silo import control_silo_test
from sentry.types.cell import Cell, RegionCategory
from sentry.types.cell import Cell

cell = Cell("us", 1, "http://us.testserver", RegionCategory.MULTI_TENANT)
cell = Cell("us", 1, "http://us.testserver")
cell_config = (cell,)


Expand All @@ -22,7 +22,7 @@ def get_response(self, req: HttpRequest) -> HttpResponse:
return HttpResponse(status=200, content="passthrough")

factory = RequestFactory()
cell = Cell("us", 1, "https://us.testserver", RegionCategory.MULTI_TENANT)
cell = Cell("us", 1, "https://us.testserver")
cell_config = (cell,)

def get_integration(self) -> Integration:
Expand Down
4 changes: 2 additions & 2 deletions tests/sentry/middleware/integrations/parsers/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from sentry.testutils.helpers.options import override_options
from sentry.testutils.outbox import assert_no_webhook_payloads, assert_webhook_payloads_for_mailbox
from sentry.testutils.silo import control_silo_test
from sentry.types.cell import Cell, RegionCategory
from sentry.types.cell import Cell

cell = Cell("us", 1, "https://us.testserver", RegionCategory.MULTI_TENANT)
cell = Cell("us", 1, "https://us.testserver")
cell_config = (cell,)


Expand Down
Loading
Loading