Skip to content

Add AlloyDB support to DB usage ping

Jon Jenkins requested to merge alloy_db_usage_ping into master

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

Screenshot_at_2022-09-21_15-47-02

How to set up and validate locally

  1. Create an AlloyDB cluster in Google Cloud.
  2. 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.
  3. 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 where 10.126.48.5 is the internal IP address of your DB instance and 34.71.197.99 is the external IP address of your VM instance.
  4. cd to your gitlab source folder and switch to a 14.x version of Postgres using asdf.
  5. 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.
  6. Set up config/database.yml to reflect the above, taking care to use port 5433.
  7. Run bundle exec rake db:migrate to initialize your AlloyDB.
  8. Start the rails console (rails c).
  9. Create a Service Ping Report: Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)
  10. 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.

Edited by Jon Jenkins

Merge request reports