Geo: Add rake task to connect psql to separate tracking DB

In an HA setup, you can't connect to the tracking DB and run FDW queries without jumping through a bunch of hoops.

Typical frustrating experience:

  • SSH into tracking DB machine
  • sudo gitlab-geo-psql
  • Run some query that includes references to gitlab_secondary (which is the foreign server)
  • ERROR: user mapping not found for "gitlab-psql"
  • Oh, I need to be gitlab_geo user since it created the foreign server
  • \q
  • sudo gitlab-geo-psql -U gitlab_geo
  • psql: FATAL: Peer authentication failed for user "gitlab_geo"
  • Oh, we configured PG to not allow peer authentication, I'll connect from an app node
  • SSH into app node
  • sudo gitlab-geo-psql
  • psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/opt/gitlab/geo-postgresql/.s.PGSQL.5431"?
  • Oh, the command doesn't do what you'd hope
  • gitlab-geo-psql -U gitlab_geo -h 10.138.0.38
  • Password for user gitlab_geo:
  • Oh I need to get the password (if you're very familiar with GitLab you know it's in plaintext somewhere in /etc/gitlab/gitlab.rb but you get the point)

Let's make this easier.

Proposal

Add a rake task that you can run from an app node e.g. gitlab-rake geo:dbconsole that starts psql for you and handles everything (since it must have all the information).

Edited Mar 12, 2019 by Michael Kozono
Assignee Loading
Time tracking Loading