Skip to content

Commit

Permalink
add migration support
Browse files Browse the repository at this point in the history
  • Loading branch information
BYK committed Jan 1, 2025
1 parent 20e608b commit 8d7c1ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 15 additions & 5 deletions install/bootstrap-garage.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
echo "${_group}Bootstrapping garage (node store)..."

$dc up --wait garage
$dc up --wait garage postgres
garage="$dc exec garage /garage"

if [[ $($garage bucket list | tail -1 | awk '{print $1}') != 'nodestore' ]]; then
node_id=$($garage status | tail -1 | awk '{print $1}')
$garage layout assign -z local -c $GARAGE_STORAGE_SIZE "$node_id"
$garage layout apply --version 1

# Only touch if no existing nodestore config is found
if ! grep -q "SENTRY_NODESTORE" $SENTRY_CONFIG_PY; then
nodestore_config=$(sed -n '/SENTRY_NODESTORE/,/[}]/{p}' sentry/sentry.conf.example.py)
if [[ $($dc exec postgres psql -qAt -U postgres -c "select exists (select * from nodestore_node limit 1)") = "f" ]]; then
nodestore_config=$(echo -e "$nodestore_config" | sed '$s/\}/ "read_through": True,\n "delete_through": True,\n\}/')
fi
echo "$nodestore_config" >>$SENTRY_CONFIG_PY
fi

$garage bucket create nodestore
key_info=$($garage key create nodestore-key | head -3 | tail -2)
echo "$key_info"
Expand All @@ -16,10 +25,11 @@ if [[ $($garage bucket list | tail -1 | awk '{print $1}') != 'nodestore' ]]; the

$garage bucket allow --read --write --owner nodestore --key nodestore-key

sed -i -e "s/<GARAGE_KEY_ID>/$key_id/" $SENTRY_CONFIG_PY
sed -i -e "s/<GARAGE_SECRET_KEY>/$key_secret/" $SENTRY_CONFIG_PY

echo "Set Garage keys for SENTRY_NODESTORE_OPTIONS in $SENTRY_CONFIG_PY"
if grep -q "<GARAGE_KEY_ID>" $SENTRY_CONFIG_PY; then
sed -i -e "s/<GARAGE_KEY_ID>/$key_id/" $SENTRY_CONFIG_PY
sed -i -e "s/<GARAGE_SECRET_KEY>/$key_secret/" $SENTRY_CONFIG_PY
echo "Set Garage keys for SENTRY_NODESTORE_OPTIONS in $SENTRY_CONFIG_PY"
fi
else
echo "Node store already exists, skipping..."
fi
Expand Down
4 changes: 0 additions & 4 deletions sentry/sentry.conf.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,10 @@ def get_internal_network():

SENTRY_NODESTORE = "sentry_nodestore_s3.S3PassthroughDjangoNodeStorage"
SENTRY_NODESTORE_OPTIONS = {
"delete_through": True,
"write_through": False,
"read_through": True,
"compression": False, # we have compression enabled in Garage itself
"endpoint_url": "http://garage:3900",
"bucket_path": "nodestore",
"bucket_name": "nodestore",
"retry_attempts": 3,
"region_name": "garage",
"aws_access_key_id": "<GARAGE_KEY_ID>",
"aws_secret_access_key": "<GARAGE_SECRET_KEY>",
Expand Down

0 comments on commit 8d7c1ff

Please sign in to comment.