Skip to content

Commit

Permalink
wip: Add flag to run devserver's region node in monolith mode
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanSkonnord committed Oct 6, 2023
1 parent 922e96a commit be1d3a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ def SOCIAL_AUTH_DEFAULT_USERNAME() -> str:

# Enable siloed development environment.
USE_SILOS = os.environ.get("SENTRY_USE_SILOS", None)
USE_MONOLITH_AS_REGION_SILO = os.environ.get("SENTRY_USE_MONOLITH_AS_REGION_SILO", None)

# List of the available regions, or a JSON string
# that is parsed.
Expand Down
13 changes: 10 additions & 3 deletions src/sentry/runner/commands/devserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from sentry.runner.commands.devservices import get_docker_client
from sentry.runner.decorators import configuration, log_options
from sentry.silo import SiloMode

_DEV_METRICS_INDEXER_ARGS = [
# We don't really need more than 1 process.
Expand Down Expand Up @@ -388,9 +389,15 @@ def devserver(

server_port = os.environ["SENTRY_BACKEND_PORT"]
if settings.USE_SILOS:
os.environ["SENTRY_SILO_MODE"] = "REGION"
os.environ["SENTRY_REGION"] = "us"
os.environ["SENTRY_REGION_API_URL_TEMPLATE"] = f"http://{{region}}.localhost:{server_port}"
if not settings.USE_MONOLITH_AS_REGION_SILO:
os.environ["SENTRY_SILO_MODE"] = SiloMode.REGION.name
os.environ[
"SENTRY_REGION_API_URL_TEMPLATE"
] = f"http://{{region}}.localhost:{server_port}"
else:
os.environ["SENTRY_SILO_MODE"] = SiloMode.MONOLITH.name
os.environ["SENTRY_REGION_API_URL_TEMPLATE"] = f"http://localhost:{server_port}"

# Override variable set by SentryHTTPServer.prepare_environment()
os.environ["SENTRY_DEVSERVER_BIND"] = f"localhost:{server_port}"
Expand Down Expand Up @@ -446,7 +453,7 @@ def devserver(
if settings.USE_SILOS:
control_port = ports["control.server"]
control_environ = {
"SENTRY_SILO_MODE": "CONTROL",
"SENTRY_SILO_MODE": SiloMode.CONTROL.name,
"SENTRY_REGION": "",
"SENTRY_DEVSERVER_BIND": f"localhost:{control_port}",
# Override variable set by SentryHTTPServer.prepare_environment()
Expand Down

0 comments on commit be1d3a4

Please sign in to comment.