-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Cloud SQL MySQL support #7302
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but please beware that I lack experience with most of the stuff here and the Go MySQL stuff so some things may go over my head without me noticing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bot.
Adds support for connecting to MySQL Cloud SQL databases with database access.
MySQL in Cloud SQL does not support IAM authentication, so instead we're using GCP Cloud SQL Admin API to emulate one-time passwords: before each connect we reset the requested database user's password to a generated token and then connect with it. See linked ticket for more details on the used APIs, if interested.
This approach means that we have to serialize all connections to the same database/user to avoid races with clients updating the password - esp. keeping in mind HA scenario where there may be multiple database services proxying the same database instance.
The nice property about this approach though is that it can be used with regular database users as opposed to Postgres IAM auth where you have to connect with service accounts.
I've also refactored the way database service handles creating cloud clients a bit along the way, to make it a bit cleaner, ensure better separation of concerns and also to make it easier in future to introduce dynamically added/removed databases - previously it would only initialize all clients upon startup, now it initializes required clients on demand and caches them.
Closes #7146.