Projects cannot re-setup Product Analytics at the project-level if they've already onboarded with an instance-level cluster
Summary
If a project already sets up Product Analytics when a cluster is connected at the instance-level, they cannot re-setup Product Analytics after connecting a cluster at the project-level.
Steps to reproduce
- Configure a project with a PA cluster at the instance-level
- Start the onboarding process, where you're given an application ID and instructions to collect events
- Configure a project with a different PA cluster at the project-level
- Go back to Analytics Dashboards, and note that it still states that it's waiting for events.
- This is wrong, it should know whether or not a project has been set up on the cluster, and report the state accordingly. This state is erroneously shown because we check for the presence of any application ID within the GitLab application.
Proposal
This needs proper solution validation from an engineer, but here's @dennis' rough idea:
- Clear the application ID whenever a PA cluster is configured or removed at the project-level.
- At this point, you should be able to:
- Start a new
ProductAnalytics::InitializeSnowplowProductAnalyticsWorker
background job, however:- If a project has already been configured on a cluster, instead of a
200
, a500
error will be returned with the error:clickhouse [execute]:: 500 code: Code: 82. DB::Exception: Database <DATABASE_NAME> already exists. (DATABASE_ALREADY_EXISTS) (version 23.7.4.5 (official build))
- If a project has already been configured on a cluster, instead of a
- Start a new
So we will likely need a change in analytics-configurator
to either:
- Return a different status or code to indicate that the database already exists, and return the application ID instead to set a new one, or...
- Create a new endpoint that simply checks for the existence of a database for the namespace ID, and then return the existing application ID.
For any changes to the analytics-configurator
, please file an issue and coordinate with the groupanalytics instrumentation team!
Changes applied should also work in reverse, i.e., when a project is removed from a project-level cluster configuration, and then needs to onboard (or not), depending on whether the project has been set up on the instance-level cluster.
Relates to Product Analytics onboarding instructions and s... (#421601 - closed)