From a0b4609fbed156177c2b8d21b4a1ea836e2d1bcc Mon Sep 17 00:00:00 2001 From: Hubert Deng Date: Fri, 1 Nov 2024 15:48:28 -0700 Subject: [PATCH] feat(devservices): Add sentry config (#80030) This adds devservices configs for usage with sentry. Instead of running relay as a part of devserver, we are opting to do it in a container which allows us to automatically import relay configs from the relay repo. This will help in reducing the duplication of configs across repos. --- devservices/config.yml | 55 +++++++++++++++++++++++++ src/sentry/runner/commands/devserver.py | 13 +++--- 2 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 devservices/config.yml diff --git a/devservices/config.yml b/devservices/config.yml new file mode 100644 index 00000000000000..f83a7c9c29e83e --- /dev/null +++ b/devservices/config.yml @@ -0,0 +1,55 @@ +# Ignored by docker compose, used by devservices +x-sentry-service-config: + version: 0.1 + service_name: sentry + dependencies: + snuba: + description: Service that provides fast aggregation and query capabilities on top of Clickhouse + remote: + repo_name: snuba + branch: master + repo_link: git@github.com:getsentry/snuba.git + mode: containerized + relay: + description: Service event forwarding and ingestion service + remote: + repo_name: relay + branch: master + repo_link: git@github.com:getsentry/relay.git + mode: containerized + postgres: + description: Database used to store Sentry data + modes: + default: [snuba, postgres, relay] + +services: + postgres: + image: ghcr.io/getsentry/image-mirror-library-postgres:14-alpine + environment: + POSTGRES_HOST_AUTH_METHOD: trust + POSTGRES_DB: sentry + command: + [ + postgres, + -c, + wal_level=logical, + -c, + max_replication_slots=1, + -c, + max_wal_senders=1, + ] + networks: + - devservices + volumes: + - postgres-data:/var/lib/postgresql/data + ports: + - 5432:5432 + extra_hosts: + - host.docker.internal:host-gateway + +networks: + devservices: + name: devservices + +volumes: + postgres-data: diff --git a/src/sentry/runner/commands/devserver.py b/src/sentry/runner/commands/devserver.py index 98969e07cb470c..2425dcded08c9b 100644 --- a/src/sentry/runner/commands/devserver.py +++ b/src/sentry/runner/commands/devserver.py @@ -231,6 +231,9 @@ def devserver( daemons: MutableSequence[tuple[str, Sequence[str]]] = [] kafka_consumers: set[str] = set() + containers: set[str] = set() + with get_docker_client() as docker: + containers = {c.name for c in docker.containers.list(filters={"status": "running"})} if experimental_spa: os.environ["SENTRY_UI_DEV_ONLY"] = "1" @@ -323,7 +326,9 @@ def devserver( kafka_consumers.add("uptime-configs") if settings.SENTRY_USE_RELAY: - daemons += [("relay", ["sentry", "devservices", "attach", "relay"])] + # TODO: Remove this once we have a better way to check if relay is running for new devservices + if "relay-relay-1" not in containers: + daemons += [("relay", ["sentry", "devservices", "attach", "relay"])] kafka_consumers.add("ingest-events") kafka_consumers.add("ingest-attachments") @@ -347,9 +352,7 @@ def devserver( # Create all topics if the Kafka eventstream is selected if kafka_consumers: - with get_docker_client() as docker: - containers = {c.name for c in docker.containers.list(filters={"status": "running"})} - if "sentry_kafka" not in containers: + if "sentry_kafka" not in containers and "shared-kafka-kafka-1" not in containers: raise click.ClickException( f""" Devserver is configured to start some kafka consumers, but Kafka @@ -368,7 +371,7 @@ def devserver( and run `sentry devservices up kafka`. Alternatively, run without --workers. -""" + """ ) from sentry.conf.types.kafka_definition import Topic