sentry-kubernetes
sentry-kubernetes copied to clipboard
Can the clickhouse-init job be executed during the helm upgrade phase?
as below, it will drop all tables with _dist suffix and recreate them. Will this permanently delete the existing data in the Clickhouse?
command:
- /bin/bash
- -ec
- |-
check_readiness() {
local host="$1"
local port="$2"
local count="$3"
until [ $count -le 0 ] || clickhouse-client --database=default --host=$host --port=$port --query="SELECT 1;" > /dev/null;
do
echo "Waiting for clickhouse to be ready..."
count="$((count-1))"
sleep 1
done
};
echo "clickhouse-init started";
check_readiness "sentry-clickhouse.infra" "9000" "5";
for tbl in discover errors groupassignee groupedmessage outcomes_hourly migrations outcomes_mv_hourly outcomes_raw sentry sessions_hourly sessions_hourly_mv sessions_raw transactions; do
clickhouse-client --user default --password "" --database=default --host=sentry-clickhouse.infra --port=9000 --query="DROP TABLE IF EXISTS ${tbl}_dist";
clickhouse-client --user default --password "" --database=default --host=sentry-clickhouse.infra --port=9000 --query="CREATE TABLE ${tbl}_dist AS ${tbl}_local ENGINE = Distributed('test_shard_localhost', 'default', ${tbl}_local, rand())";
done
echo "clickhouse-init finished"