getsentry / sentry-kubernetes

Kubernetes event reporter for Sentry
Apache License 2.0
458 stars 64 forks source link

Can the clickhouse-init job be executed during the helm upgrade phase? #50

Closed stanxing closed 9 months ago

stanxing commented 2 years ago

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"
tonyo commented 9 months ago

This was probably meant for the Helm chart that installs Sentry? This repository hosts the sentry-kubernetes agent (event reporter), sorry!