Skip to content

Commit

Permalink
ref(devservices): Turning sentry devservices into a no-op (#83389)
Browse files Browse the repository at this point in the history
Cutting over to the revamped devservices, making sentry devservices a
no-op for up (as we still want users to be able to bring it down).
https://getsentry.atlassian.net/browse/DEVINFRA-577
https://getsentry.atlassian.net/browse/DEVINFRA-578

---------

Co-authored-by: Hubert Deng <[email protected]>
Co-authored-by: Hubert Deng <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2025
1 parent b502325 commit 0304769
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 61 deletions.
6 changes: 3 additions & 3 deletions bin/split-silo-database
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def split_database(tables: list[str], source: str, destination: str, reset: bool

with get_docker_client() as client:
postgres_container = (
"sentry_postgres"
if os.environ.get("USE_NEW_DEVSERVICES") != "1"
else "sentry-postgres-1"
"sentry-postgres-1"
if os.environ.get("USE_OLD_DEVSERVICES") != "1"
else "sentry_postgres"
)
postgres = client.containers.get(postgres_container)

Expand Down
34 changes: 20 additions & 14 deletions devenv/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def main(context: dict[str, str]) -> int:

FRONTEND_ONLY = os.environ.get("SENTRY_DEVENV_FRONTEND_ONLY") is not None

USE_NEW_DEVSERVICES = os.environ.get("USE_NEW_DEVSERVICES") == "1"
USE_OLD_DEVSERVICES = os.environ.get("USE_OLD_DEVSERVICES") == "1"

if constants.DARWIN and check_minimum_version("1.14.2"):
# `devenv update`ing to >=1.14.0 will install global colima
Expand Down Expand Up @@ -266,35 +266,41 @@ def main(context: dict[str, str]) -> int:
print("Skipping python migrations since SENTRY_DEVENV_FRONTEND_ONLY is set.")
return 0

if USE_NEW_DEVSERVICES:
# Ensure old sentry devservices is not being used, otherwise ports will conflict
if USE_OLD_DEVSERVICES:
# Ensure new devservices is not being used, otherwise ports will conflict
proc.run(
(
f"{venv_dir}/bin/{repo}",
"devservices",
"down",
),
(f"{venv_dir}/bin/devservices", "down"),
pathprepend=f"{reporoot}/.devenv/bin",
exit=True,
)
# TODO: check healthchecks for redis and postgres to short circuit this
proc.run(
(f"{venv_dir}/bin/devservices", "up", "--mode", "migrations"),
(
f"{venv_dir}/bin/{repo}",
"devservices",
"up",
"redis",
"postgres",
),
pathprepend=f"{reporoot}/.devenv/bin",
exit=True,
)
else:
# TODO: check healthchecks for redis and postgres to short circuit this
# Ensure old sentry devservices is not being used, otherwise ports will conflict
proc.run(
(
f"{venv_dir}/bin/{repo}",
"devservices",
"up",
"redis",
"postgres",
"down",
),
pathprepend=f"{reporoot}/.devenv/bin",
exit=True,
)
proc.run(
(f"{venv_dir}/bin/devservices", "up", "--mode", "migrations"),
pathprepend=f"{reporoot}/.devenv/bin",
exit=True,
)

if not run_procs(
repo,
Expand All @@ -312,7 +318,7 @@ def main(context: dict[str, str]) -> int:
return 1

postgres_container = (
"sentry_postgres" if os.environ.get("USE_NEW_DEVSERVICES") != "1" else "sentry-postgres-1"
"sentry_postgres" if os.environ.get("USE_OLD_DEVSERVICES") == "1" else "sentry-postgres-1"
)

# faster prerequisite check than starting up sentry and running createuser idempotently
Expand Down
8 changes: 4 additions & 4 deletions scripts/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
# shellcheck disable=SC2034 # Unused variables
# shellcheck disable=SC2001 # https://github.com/koalaman/shellcheck/wiki/SC2001

POSTGRES_CONTAINER="sentry_postgres"
USE_NEW_DEVSERVICES=${USE_NEW_DEVSERVICES:-"0"}
if [ "$USE_NEW_DEVSERVICES" == "1" ]; then
POSTGRES_CONTAINER="sentry-postgres-1"
POSTGRES_CONTAINER="sentry-postgres-1"
USE_OLD_DEVSERVICES=${USE_OLD_DEVSERVICES:-"0"}
if [ "$USE_OLD_DEVSERVICES" == "1" ]; then
POSTGRES_CONTAINER="sentry_postgres"
fi

venv_name=".venv"
Expand Down
8 changes: 4 additions & 4 deletions scripts/upgrade-postgres.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

POSTGRES_CONTAINER="sentry_postgres"
USE_NEW_DEVSERVICES=${USE_NEW_DEVSERVICES:-"0"}
if [ "$USE_NEW_DEVSERVICES" == "1" ]; then
POSTGRES_CONTAINER="sentry-postgres-1"
POSTGRES_CONTAINER="sentry-postgres-1"
USE_OLD_DEVSERVICES=${USE_OLD_DEVSERVICES:-"0"}
if [ "$USE_OLD_DEVSERVICES" == "1" ]; then
POSTGRES_CONTAINER="sentry_postgres"
fi

OLD_VERSION="9.6"
Expand Down
6 changes: 3 additions & 3 deletions src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2455,9 +2455,9 @@ def custom_parameter_sort(parameter: dict) -> tuple[str, int]:
"ports": {"50051/tcp": 50051},
"environment": {
"TASKBROKER_KAFKA_CLUSTER": (
"kafka-kafka-1"
if os.environ.get("USE_NEW_DEVSERVICES") == "1"
else "sentry_kafka"
"sentry_kafka"
if os.environ.get("USE_OLD_DEVSERVICES") == "1"
else "kafka-kafka-1"
),
},
"only_if": settings.SENTRY_USE_TASKBROKER,
Expand Down
14 changes: 7 additions & 7 deletions src/sentry/runner/commands/devserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,17 @@ def devserver(

# Create all topics if the Kafka eventstream is selected
if kafka_consumers:
use_new_devservices = os.environ.get("USE_NEW_DEVSERVICES") == "1"
use_old_devservices = os.environ.get("USE_OLD_DEVSERVICES") == "1"
valid_kafka_container_names = ["kafka-kafka-1", "sentry_kafka"]
kafka_container_name = "kafka-kafka-1" if use_new_devservices else "sentry_kafka"
kafka_container_name = "sentry_kafka" if use_old_devservices else "kafka-kafka-1"
kafka_container_warning_message = (
f"""
Devserver is configured to work with the revamped devservices. Looks like the `{kafka_container_name}` container is not running.
Please run `devservices up` to start it. If you would like to use devserver with `sentry devservices`, set `USE_NEW_DEVSERVICES=0` in your environment."""
if use_new_devservices
else f"""
Devserver is configured to work with `sentry devservices`. Looks like the `{kafka_container_name}` container is not running.
Please run `sentry devservices up kafka` to start it. If you would like to use devserver with the revamped devservices, set `USE_NEW_DEVSERVICES=1` in your environment."""
Please run `sentry devservices up kafka` to start it. If you would like to use devserver with the revamped devservices, set `USE_OLD_DEVSERVICES=1` in your environment."""
if use_old_devservices
else f"""
Devserver is configured to work with the revamped devservices. Looks like the `{kafka_container_name}` container is not running.
Please run `devservices up` to start it. If you would like to use devserver with `sentry devservices`, set `USE_OLD_DEVSERVICES=0` in your environment."""
)
if not any(name in containers for name in valid_kafka_container_names):
raise click.ClickException(
Expand Down
33 changes: 7 additions & 26 deletions src/sentry/runner/commands/devservices.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import docker

CI = os.environ.get("CI") is not None
USE_OLD_DEVSERVICES = os.environ.get("USE_OLD_DEVSERVICES") == "1"

# assigned as a constant so mypy's "unreachable" detection doesn't fail on linux
# https://github.com/python/mypy/issues/12286
Expand Down Expand Up @@ -214,6 +215,9 @@ def devservices() -> None:
click.echo("Assuming docker (CI).")
return

if not USE_OLD_DEVSERVICES:
return

if DARWIN:
if USE_DOCKER_DESKTOP:
click.echo("Using docker desktop.")
Expand Down Expand Up @@ -303,20 +307,12 @@ def up(
"""
from sentry.runner import configure

if os.environ.get("USE_NEW_DEVSERVICES", "0") != "1":
if not USE_OLD_DEVSERVICES:
click.secho(
"""
WARNING: We're transitioning from `sentry devservices` to the new and improved `devservices` in January 2025.
To give the new devservices a try, set the `USE_NEW_DEVSERVICES` environment variable to `1`. For a full list of commands, see
https://github.com/getsentry/devservices?tab=readme-ov-file#commands
Instead of running `sentry devservices up`, consider using `devservices up`.
For Sentry employees - if you hit any bumps or have feedback, we'd love to hear from you in #discuss-dev-infra.
Thanks for helping the Dev Infra team improve this experience!
""",
"WARNING: `sentry devservices up` is deprecated. Please use `devservices up` instead. For more info about the revamped devservices, see https://github.com/getsentry/devservices.",
fg="yellow",
)
return

configure()

Expand Down Expand Up @@ -535,21 +531,6 @@ def down(project: str, service: list[str]) -> None:
an explicit list of services to bring down.
"""

if os.environ.get("USE_NEW_DEVSERVICES", "0") != "1":
click.secho(
"""
WARNING: We're transitioning from `sentry devservices` to the new and improved `devservices` in January 2025.
To give the new devservices a try, set the `USE_NEW_DEVSERVICES` environment variable to `1`. For a full list of commands, see
https://github.com/getsentry/devservices?tab=readme-ov-file#commands
Instead of running `sentry devservices down`, consider using `devservices down`.
For Sentry employees - if you hit any bumps or have feedback, we'd love to hear from you in #discuss-dev-infra.
Thanks for helping the Dev Infra team improve this experience!
""",
fg="yellow",
)

def _down(container: docker.models.containers.Container) -> None:
click.secho(f"> Stopping '{container.name}' container", fg="red")
container.stop()
Expand Down

0 comments on commit 0304769

Please sign in to comment.