Skip to content

Commit

Permalink
feat: Leverage health checks for depends_on (#1057)
Browse files Browse the repository at this point in the history
Expands the work on #1053 to all applicable services.
  • Loading branch information
BYK authored Aug 6, 2021
1 parent d11fb14 commit 9aa34dd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
78 changes: 56 additions & 22 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9aa34dd

Please sign in to comment.