diff --git a/CHANGELOG.md b/CHANGELOG.md index 31d829c830b..edf49c7de4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - feat: Support custom CA roots ([#27062](https://github.com/getsentry/sentry/pull/27062)), see the [docs](https://develop.sentry.dev/self-hosted/custom-ca-roots/) for more details. - fix: Fix `curl` image to version 7.77.0 - upgrade: docker-compose version to 1.29.2 +- feat: Leverage health checks for depends_on ## 21.7.0 diff --git a/docker-compose.yml b/docker-compose.yml index 78c7547e138..63b76619e6f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,10 @@ version: "3.4" x-restart-policy: &restart_policy restart: unless-stopped +x-depends_on-healthy: &depends_on-healthy + condition: service_healthy +x-depends_on-default: &depends_on-default + condition: service_started x-healthcheck-defaults: &healthcheck_defaults # Avoid setting the interval too small, as docker uses much more CPU than one would expect. # Related issues: @@ -15,20 +19,34 @@ x-sentry-defaults: &sentry_defaults <<: *restart_policy image: "$SENTRY_IMAGE" depends_on: - - redis - - postgres - - memcached - - smtp - - snuba-api - - snuba-consumer - - snuba-outcomes-consumer - - snuba-sessions-consumer - - snuba-transactions-consumer - - snuba-subscription-consumer-events - - snuba-subscription-consumer-transactions - - snuba-replacer - - symbolicator - - kafka + redis: + <<: *depends_on-healthy + kafka: + <<: *depends_on-healthy + postgres: + <<: *depends_on-healthy + memcached: + <<: *depends_on-default + smtp: + <<: *depends_on-default + snuba-api: + <<: *depends_on-default + snuba-consumer: + <<: *depends_on-default + snuba-outcomes-consumer: + <<: *depends_on-default + snuba-sessions-consumer: + <<: *depends_on-default + snuba-transactions-consumer: + <<: *depends_on-default + snuba-subscription-consumer-events: + <<: *depends_on-default + snuba-subscription-consumer-transactions: + <<: *depends_on-default + snuba-replacer: + <<: *depends_on-default + symbolicator: + <<: *depends_on-default entrypoint: "/etc/sentry/entrypoint.sh" command: ["run", "web"] environment: @@ -55,11 +73,11 @@ x-snuba-defaults: &snuba_defaults <<: *restart_policy depends_on: clickhouse: - condition: service_healthy + <<: *depends_on-healthy kafka: - condition: service_healthy + <<: *depends_on-healthy redis: - condition: service_healthy + <<: *depends_on-healthy image: "$SNUBA_IMAGE" environment: SNUBA_SETTINGS: docker @@ -143,7 +161,8 @@ services: kafka: <<: *restart_policy depends_on: - - zookeeper + zookeeper: + <<: *depends_on-healthy image: "confluentinc/cp-kafka:5.5.0" environment: KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181" @@ -184,7 +203,11 @@ services: # You might want to change this to a higher value (and ensure your host has enough memory) MAX_MEMORY_USAGE_RATIO: 0.3 healthcheck: - test: ["CMD-SHELL", "wget -nv -t1 --spider 'http://localhost:9000/' || exit 1"] + test: + [ + "CMD-SHELL", + "wget -nv -t1 --spider 'http://localhost:9000/' || exit 1", + ] interval: 3s timeout: 600s retries: 200 @@ -264,6 +287,14 @@ services: - "sentry-symbolicator:/data" web: <<: *sentry_defaults + healthcheck: + <<: *healthcheck_defaults + test: + - "CMD" + - "/bin/bash" + - '-c' + # Courtesy of https://unix.stackexchange.com/a/234089/108960 + - 'exec 3<>/dev/tcp/127.0.0.1/9000 && echo -e "GET /_health/ HTTP/1.1\r\nhost: 127.0.0.1\r\n\r\n" >&3 && grep ok -s -m 1 <&3' cron: <<: *sentry_defaults command: run cron @@ -318,9 +349,12 @@ services: source: ./geoip target: /geoip depends_on: - - kafka - - redis - - web + kafka: + <<: *depends_on-healthy + redis: + <<: *depends_on-healthy + web: + <<: *depends_on-healthy volumes: sentry-data: external: true