[SPIKE] Can't add Postgres instances without postgres DB to PMM

Description

Spike goal:

  • check is there a way to remove hardcoded DB name and don't have it specified at all

  • make sure all other features of PMM working well

 

Note:

  • we can use DigitalOcean PG (dbaas) as test  

Original report

The API and PMM Add Instance dashboard both assume that the Postgres instance to be added has a database called postgres. This is not alway true. For example, DigitalOcean DBaaS instances are created with a defaultdb database instead. The AddPostgreSQLService endpoint and the PMM Add Instance dashboard should both allow the user to specify the database name when adding a Postgres instance.

 

How to test

None

How to document

None

Attachments

1
  • 29 Mar 2021, 11:36 AM

Smart Checklist

Activity

Show:

Carlos Salguero April 15, 2021 at 8:28 PM

There is no way to connect without specify a default database to connect to. 

If no DB is specified, Postgre will try to use the username as the database name. 
I've tested it with psql and postgre_exporter again a DO instance. 
If I use a database name, the exporter works as expected

DATA_SOURCE_NAME="postgresql://doadmin:xxxxxxxxxxx@db-postgresql-nyc3-70633-do-user-4022614-0.b.db.ondigitalocean.com:25060/defaultdb" ./cmd/postgres_exporter/postgres_exporter INFO[0000] Starting postgres_exporter (version=, branch=, revision=) source="postgres_exporter.go:1679" INFO[0000] Build context (go=go1.16.3, user=, date=) source="postgres_exporter.go:1680" INFO[0000] Established new database connection to "db-postgresql-nyc3-70633-do-user-4022614-0.b.db.ondigitalocean.com:25060". source="postgres_exporter.go:894" INFO[0002] Semantic Version Changed on "db-postgresql-nyc3-70633-do-user-4022614-0.b.db.ondigitalocean.com:25060": 0.0.0 -> 12.6.0 source="postgres_exporter.go:1429" INFO[0007] Starting HTTP server for http://:9187/metrics ... source="server.go:144"

If not, I am getting this error:

Error opening connection to database (postgresql://doadmin:PASSWORD_REMOVED@db-postgresql-nyc3-70633-do-user-4022614-0.b.db.ondigitalocean.com:25060/): pq: database "doadmin" does not exist source="postgres_exporter.go:1529"

Proposed solution:

Update the UI and API to let the user specify a default dabatabase.

NOTE:
template0 and template1 cannot be used eaither due to permissions.

Done

Details

Assignee

Reporter

Priority

Needs Doc

No

Story Points

Sprint

Affects versions

Smart Checklist

Created March 29, 2021 at 11:36 AM
Updated March 6, 2024 at 2:58 AM
Resolved April 16, 2021 at 2:51 PM

Flag notifications