Просмотр исходного кода

ref(devservices): Turning sentry devservices into a no-op (#83389)

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 <hubertdeng123@gmail.com>
Co-authored-by: Hubert Deng <hubert.deng@sentry.io>
Ian Woodard 1 месяц назад
Родитель
Сommit
03047690ee

+ 3 - 3
bin/split-silo-database

@@ -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)
 

+ 20 - 14
devenv/sync.py

@@ -108,7 +108,7 @@ Then, use it to run sync this one time.
 
     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
@@ -266,35 +266,41 @@ Then, use it to run sync this one time.
         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,
@@ -312,7 +318,7 @@ Then, use it to run sync this one time.
         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

+ 4 - 4
scripts/lib.sh

@@ -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"

+ 4 - 4
scripts/upgrade-postgres.sh

@@ -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"

+ 3 - 3
src/sentry/conf/server.py

@@ -2455,9 +2455,9 @@ SENTRY_DEVSERVICES: dict[str, Callable[[Any, Any], dict[str, Any]]] = {
             "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,

+ 7 - 7
src/sentry/runner/commands/devserver.py

@@ -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(

+ 7 - 26
src/sentry/runner/commands/devservices.py

@@ -22,6 +22,7 @@ if TYPE_CHECKING:
     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
@@ -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.")
@@ -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()
 
@@ -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()