Add AlloyDB support to DB usage ping
What does this MR do and why?
It adds the ability for Service Ping to detect that Gitlab is connecting to an AlloyDB database, resolving issue #367426 (closed). This allows us to collect aggregate statistics about how commonly GitLab is used with AlloyDB.
Screenshots or screen recordings
How to set up and validate locally
- Create an AlloyDB cluster in Google Cloud.
- Create a VM instance within the same VPC (you can't connect to the DB's instance directly from the internet) and add an SSH public key directly to the VM instance.
- Establish an SSH tunnel that connects your local port 5433 to the DB instance's port 5432 via your VM instance:
ssh -L 5433:10.126.48.5:5432 user@34.71.197.99
where10.126.48.5
is the internal IP address of your DB instance and34.71.197.99
is the external IP address of your VM instance. -
cd
to your gitlab source folder and switch to a 14.x version of Postgres using asdf. - Log into your AlloyDB using psql and create dev databases for gitlab and gitlab_geo. Then create a user and GRANT ALL to both databases to that user.
- Set up config/database.yml to reflect the above, taking care to use port 5433.
- Run
bundle exec rake db:migrate
to initialize your AlloyDB. - Start the rails console (
rails c
). - Create a Service Ping Report:
Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)
- Find the database flavor under 'database' key.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Jon Jenkins