Skip to content

Commit 3ab2d81

Browse files
authored
feat: use seaweedfs as nodestore backend (#3842)
* feat: seaweedfs as s3 nodestore backend * fix: 'server' was missing for seaweed * feat: remove minimum volume free space * feat: specify hostname on ip * fix: grpc port on seaweed should be `-{service}.port.grpc` instead of `-{service}.grpcPort` * fix: wrong access key & secret key; use localhost for internal comms * fix: create index directory * test: add sentry-seaweedfs volume into expected volumes * debug: aaaaaaaaaaaaaaaaaaaaaaarrrrggggggghhhhhhhhhhhhhhh * test: correct ordering for expected volumes * chore: seaweedfs healthcheck to multiple urls See https://stackoverflow.com/a/14578575/3153224
1 parent 0318e84 commit 3ab2d81

File tree

9 files changed

+85
-82
lines changed

9 files changed

+85
-82
lines changed

.env

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,3 @@ HEALTHCHECK_RETRIES=10
2424
POSTGRES_MAX_CONNECTIONS=100
2525
# Set SETUP_JS_SDK_ASSETS to 1 to enable the setup of JS SDK assets
2626
# SETUP_JS_SDK_ASSETS=1
27-
# Storage size for node store in Garage
28-
# If you need to change this after first install, you'd need to change the Garage layout
29-
# See https://garagehq.deuxfleurs.fr/documentation/quick-start/#creating-a-cluster-layout
30-
GARAGE_STORAGE_SIZE=100G

_unit-test/create-docker-volumes-test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ sentry-data
1414
sentry-kafka
1515
sentry-postgres
1616
sentry-redis
17+
sentry-seaweedfs
1718
sentry-symbolicator"
1819

1920
before=$(get_volumes)

docker-compose.yml

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ x-sentry-defaults: &sentry_defaults
3636
<<: *depends_on-default
3737
smtp:
3838
<<: *depends_on-default
39-
garage:
39+
seaweedfs:
4040
<<: *depends_on-default
4141
snuba-api:
4242
<<: *depends_on-default
@@ -212,19 +212,44 @@ services:
212212
interval: 10s
213213
timeout: 10s
214214
retries: 30
215-
garage:
216-
image: dxflrs/garage:v1.0.1
215+
seaweedfs:
216+
image: "chrislusf/seaweedfs:3.96_large_disk"
217+
entrypoint: "weed"
218+
command: >-
219+
server
220+
-filer=true
221+
-filer.port=8888
222+
-filer.port.grpc=18888
223+
-filer.defaultReplicaPlacement=000
224+
-master=true
225+
-master.port=9333
226+
-master.port.grpc=19333
227+
-metricsPort=9091
228+
-s3=true
229+
-s3.port=8333
230+
-s3.port.grpc=18333
231+
-volume=true
232+
-volume.dir.idx=/data/idx
233+
-volume.index=leveldbLarge
234+
-volume.max=0
235+
-volume.preStopSeconds=8
236+
-volume.readMode=redirect
237+
-volume.port=8080
238+
-volume.port.grpc=18080
239+
-ip=127.0.0.1
240+
-ip.bind=0.0.0.0
241+
-webdav=false
242+
environment:
243+
AWS_ACCESS_KEY_ID: sentry
244+
AWS_SECRET_ACCESS_KEY: sentry
217245
volumes:
218-
- type: bind
219-
read_only: true
220-
source: ./garage.toml
221-
target: /etc/garage.toml
222-
- "sentry-garage:/var/lib/garage/"
246+
- "sentry-seaweedfs:/data"
223247
healthcheck:
224-
test: ["CMD", "/garage", "status"]
225-
interval: 10s
226-
timeout: 2s
227-
retries: 2
248+
test: ["CMD", "wget", "-q", "-O-", "http://seaweedfs:8080/healthz", "http://seaweedfs:9333/cluster/healthz", "http://seaweedfs:8333/healthz"]
249+
interval: 30s
250+
timeout: 20s
251+
retries: 5
252+
start_period: 60s
228253
snuba-api:
229254
<<: *snuba_defaults
230255
# Kafka consumer responsible for feeding events into Clickhouse
@@ -621,6 +646,8 @@ volumes:
621646
external: true
622647
sentry-symbolicator:
623648
external: true
649+
sentry-seaweedfs:
650+
external: true
624651
# This volume stores JS SDK assets and the data inside this volume should
625652
# be cleaned periodically on upgrades.
626653
sentry-nginx-www:
@@ -640,4 +667,3 @@ volumes:
640667
sentry-kafka-log:
641668
sentry-smtp-log:
642669
sentry-clickhouse-log:
643-
sentry-garage:

garage.toml

Lines changed: 0 additions & 19 deletions
This file was deleted.

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ source install/ensure-relay-credentials.sh
3636
source install/generate-secret-key.sh
3737
source install/update-docker-images.sh
3838
source install/build-docker-images.sh
39-
source install/bootstrap-garage.sh
39+
source install/bootstrap-s3-nodestore.sh
4040
source install/bootstrap-snuba.sh
4141
source install/upgrade-postgres.sh
4242
source install/ensure-correct-permissions-profiles-dir.sh

install/bootstrap-garage.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

install/bootstrap-s3-nodestore.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
echo "${_group}Bootstrapping seaweedfs (node store)..."
2+
3+
$dc up --wait seaweedfs postgres
4+
$dc exec seaweedfs apk add --no-cache s3cmd
5+
$dc exec seaweedfs mkdir -p /data/idx/
6+
s3cmd="$dc exec seaweedfs s3cmd"
7+
8+
bucket_list=$($s3cmd --access_key=sentry --secret_key=sentry --no-ssl --region=us-east-1 --host=localhost:8333 --host-bucket='localhost:8333/%(bucket)' ls)
9+
10+
if [[ $($bucket_list | tail -1 | awk '{print $3}') != 's3://nodestore' ]]; then
11+
# Only touch if no existing nodestore config is found
12+
if ! grep -q "SENTRY_NODESTORE" $SENTRY_CONFIG_PY; then
13+
nodestore_config=$(sed -n '/SENTRY_NODESTORE/,/[}]/{p}' sentry/sentry.conf.example.py)
14+
if [[ $($dc exec postgres psql -qAt -U postgres -c "select exists (select * from nodestore_node limit 1)") = "f" ]]; then
15+
nodestore_config=$(echo -e "$nodestore_config" | sed '$s/\}/ "read_through": True,\n "delete_through": True,\n\}/')
16+
fi
17+
echo "$nodestore_config" >>$SENTRY_CONFIG_PY
18+
fi
19+
$dc exec seaweedfs mkdir -p /data/idx/
20+
$s3cmd --access_key=sentry --secret_key=sentry --no-ssl --region=us-east-1 --host=localhost:8333 --host-bucket='localhost:8333/%(bucket)' mb s3://nodestore
21+
else
22+
echo "Node store already exists, skipping..."
23+
fi
24+
25+
echo "${_endgroup}"

install/create-docker-volumes.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ echo "Created $(create_volume sentry-kafka)."
1717
echo "Created $(create_volume sentry-postgres)."
1818
echo "Created $(create_volume sentry-redis)."
1919
echo "Created $(create_volume sentry-symbolicator)."
20+
echo "Created $(create_volume sentry-seaweedfs)."
2021

2122
echo "${_endgroup}"

sentry/sentry.conf.example.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,29 @@ def get_internal_network():
9595
# See https://develop.sentry.dev/self-hosted/experimental/errors-only/
9696
SENTRY_SELF_HOSTED_ERRORS_ONLY = env("COMPOSE_PROFILES") != "feature-complete"
9797

98-
##############
99-
# Node Store #
100-
##############
98+
################
99+
# Node Storage #
100+
################
101+
102+
# Sentry uses an abstraction layer called "node storage" to store raw events.
103+
# Previously, it used PostgreSQL as the backend, but this didn't scale for
104+
# high-throughput environments. Read more about this in the documentation:
105+
# https://develop.sentry.dev/backend/application-domains/nodestore/
106+
#
107+
# Through this setting, you can use the provided blob storage or
108+
# your own S3-compatible API from your infrastructure.
109+
# Other backend implementations for node storage developed by the community
110+
# are available in public GitHub repositories.
101111

102112
SENTRY_NODESTORE = "sentry_nodestore_s3.S3PassthroughDjangoNodeStorage"
103113
SENTRY_NODESTORE_OPTIONS = {
104-
"compression": False, # we have compression enabled in Garage itself
105-
"endpoint_url": "http://garage:3900",
114+
"compression": True,
115+
"endpoint_url": "http://seaweedfs:8333",
106116
"bucket_path": "nodestore",
107117
"bucket_name": "nodestore",
108-
"region_name": "garage",
109-
"aws_access_key_id": "<GARAGE_KEY_ID>",
110-
"aws_secret_access_key": "<GARAGE_SECRET_KEY>",
118+
"region_name": "us-east-1",
119+
"aws_access_key_id": "sentry",
120+
"aws_secret_access_key": "sentry",
111121
}
112122

113123
#########

0 commit comments

Comments
 (0)