Browse Source

feat(devservices): Support new devservices for devenv sync (#81022)

bumps devservices to 1.0.3 and supports new devservices for devenv sync
as long as `USE_NEW_DEVSERVICES` is set to `1`
Hubert Deng 3 months ago
parent
commit
1922b875ff
4 changed files with 40 additions and 14 deletions
  1. 31 12
      devenv/sync.py
  2. 7 0
      devservices/config.yml
  3. 1 1
      requirements-dev-frozen.txt
  4. 1 1
      requirements-dev.txt

+ 31 - 12
devenv/sync.py

@@ -107,6 +107,8 @@ 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"
+
     from devenv.lib import node
 
     node.install(
@@ -253,18 +255,35 @@ def main(context: dict[str, str]) -> int:
         print("Skipping python migrations since SENTRY_DEVENV_FRONTEND_ONLY is set.")
         return 0
 
-    # TODO: check healthchecks for redis and postgres to short circuit this
-    proc.run(
-        (
-            f"{venv_dir}/bin/{repo}",
-            "devservices",
-            "up",
-            "redis",
-            "postgres",
-        ),
-        pathprepend=f"{reporoot}/.devenv/bin",
-        exit=True,
-    )
+    if USE_NEW_DEVSERVICES:
+        # Ensure old sentry devservices is not being used, otherwise ports will conflict
+        proc.run(
+            (
+                f"{venv_dir}/bin/{repo}",
+                "devservices",
+                "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,
+        )
+    else:
+        # TODO: check healthchecks for redis and postgres to short circuit this
+        proc.run(
+            (
+                f"{venv_dir}/bin/{repo}",
+                "devservices",
+                "up",
+                "redis",
+                "postgres",
+            ),
+            pathprepend=f"{reporoot}/.devenv/bin",
+            exit=True,
+        )
 
     if not run_procs(
         repo,

+ 7 - 0
devservices/config.yml

@@ -19,8 +19,15 @@ x-sentry-service-config:
         mode: containerized
     postgres:
       description: Database used to store Sentry data
+    redis:
+      description: Shared instance of redis used by sentry services
+      remote:
+        repo_name: sentry-shared-redis
+        branch: main
+        repo_link: git@github.com:getsentry/sentry-shared-redis.git
   modes:
     default: [snuba, postgres, relay]
+    migrations: [postgres, redis]
 
 services:
   postgres:

+ 1 - 1
requirements-dev-frozen.txt

@@ -36,7 +36,7 @@ cryptography==43.0.1
 cssselect==1.0.3
 cssutils==2.9.0
 datadog==0.49.1
-devservices==1.0.2
+devservices==1.0.3
 distlib==0.3.8
 distro==1.8.0
 django==5.1.1

+ 1 - 1
requirements-dev.txt

@@ -1,7 +1,7 @@
 --index-url https://pypi.devinfra.sentry.io/simple
 
 sentry-devenv>=1.13.0
-devservices>=1.0.2
+devservices>=1.0.3
 
 covdefaults>=2.3.0
 docker>=7