bentoml / Yatai

Model Deployment at Scale on Kubernetes 🦄️
https://bentoml.com
Other
789 stars 69 forks source link

PostGres connection string with special character #261

Closed mts-dyt closed 2 years ago

mts-dyt commented 2 years ago

Hello bentoml team 👋

I am trying to build a Yatai production ready platform on AZURE. The database is hosted on an external Azure Postgres Single server but I am unable to configure because the username and the password contain special characters.
For example with a password like special>#aec, I have the following error:

Error: migrate up db: cannot create migrate: parse "postgres://dbuser:special>": invalid port ":special>" after host
Usage:
  yatai-api-server serve [flags]

Flags:
  -c, --config string    (default "./yatai-config.dev.yaml")
  -h, --help            help for serve

Global Flags:
  -d, --debug   debug mode, output verbose output

error: migrate up db: cannot create migrate: parse "postgres://dbuser:special>": invalid port ":special>" after host

Is there a way to handle complex password? NB: On azure, the admin username of the database is something like admin@db-postgres-azdzazd so the @ is not handle too

yubozhao commented 2 years ago

@mts-dyt Thanks for pointing it out. We will work on this and let yo know when we release a new version with this fix

yubozhao commented 2 years ago

I am trying to build a Yatai production ready platform on AZURE.

I am a little confused on this. Do you mean you are trying to build yatai for your production system?

mts-dyt commented 2 years ago

I am trying to build a Yatai production ready platform on AZURE.

I am a little confused on this. Do you mean you are trying to build yatai for your production system?

No sorry, it is a misunderstanding. I want to use Yatai in a production environment

yetone commented 2 years ago

@mts-dyt Thanks for your report! I have fixed it in this PR: https://github.com/bentoml/Yatai/pull/263 and released a new version v0.3.9. You can install this version to fix it.

mts-dyt commented 2 years ago

@yetone Thanks for the update. Actually It still have issue because the username is something like:

    HOST     = "mydemoserver.postgres.database.azure.com"
    DATABASE = "mypgsqldb"
    USER     = "mylogin@mydemoserver"
    PASSWORD = "<server_admin_password>"

The character @is interpreted as the end of the user and the connection to the DB failed:

Error: migrate up db: cannot create migrate: pq: password authentication failed for user "mylogin"

You can find an example of Azure PostGres connection string with GO here: https://docs.microsoft.com/en-us/azure/postgresql/single-server/connect-go#connect-and-create-a-table

yetone commented 2 years ago

@mts-dyt

Thanks for your report!

github.com/golang-migrate/migrate/v4 does not support the database keyword/value connection string, it only supports the database connection uri.

I can't reproduce your problem in my environment, this is my screenshots:

image image
yetone commented 2 years ago

@mts-dyt

Even through I didn't reproduce your problem, I attempt to merge a new PR to fix it. I hope it can fix the problem in your environment.

Note the difference between the db uri string in the following screenshot and the one in the previous screenshot

image

You can install version v0.3.10 to try it out.

mts-dyt commented 2 years ago

Wonderful the solution work as expected! Thanks