Replace ClickHouse feature flag check with CH availability check
At present, ClickHouse availablility is tested via feature flags:
clickhouse_data_collection
clickhouse_ci_analytics
(perhaps others, I did a quick grep)
Rather than using short-lived feature flags, when testing for the availability of ClickHouse we should have a method on the client:
- The
ClickHouse
configuration should have at least themain
database - All migrations should have been run (it should have tables and some data)
We could have some method like ClickHouse::Client.available?(:main)
which checks for this. Alternatively we could simply check for the existence of the given CH database (main
). Other database names can be provided as they are created.
Suggested solution
Add a method with necessary calls that returns whether a particular instance's ClickHouse configuration is ready to be used.
- Suggested:
ClickHouse::Client.configured?
- Configuration in https://gitlab.com/gitlab-org/gitlab/-/blob/5774991c8fa1b9970f80f36b95dd2aedc1c7fbb7/config/initializers/click_house.rb#L9 returns an error if it can't be configured so a state can be checked.
- All databases exist (and the migrations are all run)
Edited by charlie ablett