2
0

fix(migration): Move Snuba bootstrapping before DB upgrade (#317)

Since we are [moving the eventstream into a proper db migration](https://github.com/getsentry/sentry/pull/16226), we need Snuba and its friends ready at the time of `sentry upgrade` command. This patch does exactly that.

Co-authored-by: Lyn Nagara <lyn.nagara@gmail.com>
This commit is contained in:
Burak Yigit Kaya 2020-01-03 22:52:22 +03:00 committed by GitHub
parent 4a82e9fa1d
commit 1d33ae6b04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,6 +101,16 @@ $dc build --force-rm
echo ""
echo "Docker images built."
echo "Bootstrapping Snuba..."
$dc up -d kafka redis clickhouse
until $($dcr clickhouse clickhouse-client -h clickhouse --query="SHOW TABLES;" | grep -q sentry_local); do
# `bootstrap` is for fresh installs, and `migrate` is for existing installs
# Running them both for both cases is harmless so we blindly run them
$dcr snuba-api bootstrap --force || true;
$dcr snuba-api migrate || true;
done;
echo ""
# Very naively check whether there's an existing sentry-postgres volume and the PG version in it
if [[ $(docker volume ls -q --filter name=sentry-postgres) && $(docker run --rm -v sentry-postgres:/db busybox cat /db/PG_VERSION 2>/dev/null) == "9.5" ]]; then
docker volume rm sentry-postgres-new || true
@ -145,16 +155,6 @@ if [ "$SENTRY_DATA_NEEDS_MIGRATION" ]; then
"mkdir -p /tmp/files; mv /data/* /tmp/files/; mv /tmp/files /data/files"
fi
echo "Boostrapping Snuba..."
$dc up -d kafka redis clickhouse
until $($dcr clickhouse clickhouse-client -h clickhouse --query="SHOW TABLES;" | grep -q sentry_local); do
# `bootstrap` is for fresh installs, and `migrate` is for existing installs
# Running them both for both cases is harmless so we blindly run them
$dcr snuba-api bootstrap --force || true;
$dcr snuba-api migrate || true;
done;
echo ""
set -o allexport
source .env
set +o allexport