Skip to content

Commit 240eb92

Browse files
committed
feat: move profiling data to seaweedfs
1 parent dd76ac6 commit 240eb92

File tree

5 files changed

+127
-5
lines changed

5 files changed

+127
-5
lines changed

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ x-sentry-defaults: &sentry_defaults
7272
SENTRY_STATSD_ADDR: "${STATSD_ADDR:-}"
7373
volumes:
7474
- "sentry-data:/data"
75-
- sentry-vroom:/var/vroom/sentry-profiles
75+
- "sentry-vroom:/var/vroom/sentry-profiles"
7676
- "./sentry:/etc/sentry"
7777
- "./geoip:/geoip:ro"
7878
- "./certificates:/usr/local/share/ca-certificates:ro"
@@ -753,7 +753,7 @@ services:
753753
environment:
754754
SENTRY_KAFKA_BROKERS_PROFILING: "kafka:9092"
755755
SENTRY_KAFKA_BROKERS_OCCURRENCES: "kafka:9092"
756-
SENTRY_BUCKET_PROFILES: file:///var/vroom/sentry-profiles
756+
SENTRY_BUCKET_PROFILES: "s3://profiles?region=us-east-1&endpoint=seaweedfs:8333&s3ForcePathStyle=true&disableSSL=true"
757757
SENTRY_SNUBA_HOST: "http://snuba-api:1218"
758758
volumes:
759759
- sentry-vroom:/var/vroom/sentry-profiles

install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ source install/generate-secret-key.sh
3737
source install/update-docker-images.sh
3838
source install/build-docker-images.sh
3939
source install/bootstrap-s3-nodestore.sh
40+
source install/bootstrap-s3-profiles.sh
4041
source install/bootstrap-snuba.sh
4142
source install/upgrade-postgres.sh
4243
source install/ensure-correct-permissions-profiles-dir.sh

install/bootstrap-s3-nodestore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
echo "${_group}Bootstrapping seaweedfs (node store)..."
22

3-
$dc up --wait seaweedfs postgres
3+
start_service_and_wait_ready seaweedfs postgres
44
$dc exec -e "HTTP_PROXY=${HTTP_PROXY:-}" -e "HTTPS_PROXY=${HTTPS_PROXY:-}" -e "NO_PROXY=${NO_PROXY:-}" -e "http_proxy=${http_proxy:-}" -e "https_proxy=${https_proxy:-}" -e "no_proxy=${no_proxy:-}" seaweedfs apk add --no-cache s3cmd
55
$dc exec seaweedfs mkdir -p /data/idx/
66
s3cmd="$dc exec seaweedfs s3cmd"

install/bootstrap-s3-profiles.sh

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
echo "${_group}Bootstrapping seaweedfs (profiles)..."
2+
3+
# The purpose of this file is to have both `sentry`-based containers and `vroom` use the same bucket for profiling.
4+
# Currently, we have a `sentry-vroom` volume which stores the profiling data. However, since version 25.10.0,
5+
# the behavior changed, and `vroomrs` now ingests profiles directly. Both services must share the same bucket,
6+
# but at the time of this writing, it's not possible because the `sentry-vroom` volume has ownership set to `vroom:vroom`.
7+
# This prevents the `sentry`-based containers from performing read/write operations on that volume.
8+
#
9+
# Therefore, this script should do the following:
10+
# 1. Check if there are any files inside the `sentry-vroom` volume.
11+
# 2. If (1) finds files, copy those files into a "profiles" bucket on SeaweedFS.
12+
# 3. Point `filestore-profiles` and vroom to the SeaweedFS "profiles" bucket.
13+
14+
start_service_and_wait_ready seaweedfs
15+
$dc exec -e "HTTP_PROXY=${HTTP_PROXY:-}" -e "HTTPS_PROXY=${HTTPS_PROXY:-}" -e "NO_PROXY=${NO_PROXY:-}" -e "http_proxy=${http_proxy:-}" -e "https_proxy=${https_proxy:-}" -e "no_proxy=${no_proxy:-}" seaweedfs apk add --no-cache s3cmd
16+
17+
bucket_list=$($s3cmd --access_key=sentry --secret_key=sentry --no-ssl --region=us-east-1 --host=localhost:8333 --host-bucket='localhost:8333/%(bucket)' ls)
18+
19+
if [[ $(echo "$bucket_list" | tail -1 | awk '{print $3}') != 's3://profiles' ]]; then
20+
apply_config_changes_profiles=0
21+
# Only touch if no existing profiles config is found
22+
if ! grep -q "filestore.profiles-backend" $SENTRY_CONFIG_YML; then
23+
if [[ -z "${APPLY_AUTOMATIC_CONFIG_UPDATES:-}" ]]; then
24+
echo
25+
echo "We are migrating the Profiles data directory from the 'sentry-vroom' volume to S3."
26+
echo "This migration will ensure profiles ingestion works correctly with the new 'vroomrs'"
27+
echo "and allows both 'sentry' and 'vroom' to transition smoothly."
28+
echo "To complete this, your sentry/config.yml file needs to be modified."
29+
echo "Would you like us to perform this modification automatically?"
30+
echo
31+
32+
yn=""
33+
until [ ! -z "$yn" ]; do
34+
read -p "y or n? " yn
35+
case $yn in
36+
y | yes | 1)
37+
export apply_config_changes_profiles=1
38+
echo
39+
echo -n "Thank you."
40+
;;
41+
n | no | 0)
42+
export apply_config_changes_profiles=0
43+
echo
44+
echo -n "Alright, you will need to update your sentry/config.yml file manually before running 'docker compose up'."
45+
;;
46+
*) yn="" ;;
47+
esac
48+
done
49+
50+
echo
51+
echo "To avoid this prompt in the future, use one of these flags:"
52+
echo
53+
echo " --apply-automatic-config-updates"
54+
echo " --no-apply-automatic-config-updates"
55+
echo
56+
echo "or set the APPLY_AUTOMATIC_CONFIG_UPDATES environment variable:"
57+
echo
58+
echo " APPLY_AUTOMATIC_CONFIG_UPDATES=1 to apply automatic updates"
59+
echo " APPLY_AUTOMATIC_CONFIG_UPDATES=0 to not apply automatic updates"
60+
echo
61+
sleep 5
62+
fi
63+
64+
if [[ "$APPLY_AUTOMATIC_CONFIG_UPDATES" == 1 || "$apply_config_changes_profiles" == 1 ]]; then
65+
profiles_config=$(sed -n '/filestore.profiles-backend/,/s3v4"/{p}' sentry/config.example.yml)
66+
echo "$profiles_config" >>$SENTRY_CONFIG_YML
67+
fi
68+
fi
69+
70+
$s3cmd --access_key=sentry --secret_key=sentry --no-ssl --region=us-east-1 --host=localhost:8333 --host-bucket='localhost:8333/%(bucket)' mb s3://profiles
71+
72+
# Check if there are files in the sentry-vroom volume
73+
vroom_files_count=$($dc exec vroom sh -c "find /var/vroom/sentry-profiles -type f | wc -l")
74+
if [[ "$vroom_files_count" -gt 0 ]]; then
75+
echo "Migrating $vroom_files_count files from 'sentry-vroom' volume to 'profiles' bucket on SeaweedFS..."
76+
77+
# Use a temporary container to copy files from the volume to SeaweedFS
78+
$dc run --rm --no-deps -v sentry-vroom:/source -e "HTTP_PROXY=${HTTP_PROXY:-}" -e "HTTPS_PROXY=${HTTPS_PROXY:-}" -e "NO_PROXY=${NO_PROXY:-}" -e "http_proxy=${http_proxy:-}" -e "https_proxy=${https_proxy:-}" -e "no_proxy=${no_proxy:-}" seaweedfs sh -c '
79+
apk add --no-cache s3cmd &&
80+
s3cmd --access_key=sentry --secret_key=sentry --no-ssl --region=us-east-1 --host=localhost:8333 --host-bucket="localhost:8333/%(bucket)" sync /source/ s3://profiles/
81+
'
82+
83+
echo "Migration completed."
84+
else
85+
echo "No files found in 'sentry-vroom' volume. Skipping files migration."
86+
fi
87+
else
88+
echo "'profiles' bucket already exists on SeaweedFS. Skipping creation."
89+
fi
90+
91+
if [[ -z "${APPLY_AUTOMATIC_CONFIG_UPDATES:-}" || "$APPLY_AUTOMATIC_CONFIG_UPDATES" == 1 ]]; then
92+
lifecycle_policy=$(
93+
cat <<EOF
94+
<?xml version="1.0" encoding="UTF-8"?>
95+
<LifecycleConfiguration>
96+
<Rule>
97+
<ID>Sentry-Profiles-Rule</ID>
98+
<Status>Enabled</Status>
99+
<Filter></Filter>
100+
<Expiration>
101+
<Days>$SENTRY_EVENT_RETENTION_DAYS</Days>
102+
</Expiration>
103+
</Rule>
104+
</LifecycleConfiguration>
105+
EOF
106+
)
107+
108+
$dc exec seaweedfs sh -c "printf '%s' '$lifecycle_policy' > /tmp/profiles-lifecycle-policy.xml"
109+
$s3cmd --access_key=sentry --secret_key=sentry --no-ssl --region=us-east-1 --host=localhost:8333 --host-bucket='localhost:8333/%(bucket)' setlifecycle /tmp/profiles-lifecycle-policy.xml s3://profiles
110+
111+
echo "Making sure the bucket lifecycle policy is all set up correctly..."
112+
$s3cmd --access_key=sentry --secret_key=sentry --no-ssl --region=us-east-1 --host=localhost:8333 --host-bucket='localhost:8333/%(bucket)' getlifecycle s3://profiles
113+
fi

sentry/config.example.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,17 @@ releasefile.cache-path: '/data/releasefile-cache'
9696
# secret_key: 'XXXXXXX'
9797
# bucket_name: 's3-bucket-name'
9898

99-
filestore.profiles-backend: 'filesystem'
99+
filestore.profiles-backend: 's3'
100100
filestore.profiles-options:
101-
location: '/var/vroom/sentry-profiles'
101+
bucket_acl: "private"
102+
default_acl: "private"
103+
access_key: "sentry"
104+
secret_key: "sentry"
105+
bucket_name: "profiles"
106+
region_name: "us-east-1"
107+
endpoint_url: "http://seaweedfs:8333"
108+
addressing_style: "path"
109+
signature_version: "s3v4"
102110

103111
symbolicator.enabled: true
104112
symbolicator.options:

0 commit comments

Comments
 (0)