Skip to content
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

feat: Resolve DSN from runtime in PG Proxy #3458

Merged
merged 1 commit into from
Nov 25, 2024
Merged

Conversation

jvmakine
Copy link
Contributor

@jvmakine jvmakine commented Nov 22, 2024

High level changes:

  • Stop sending PostgreSQL DSNs with the ModuleContext to the runners.
  • Instead, when GetDatabase in the runner is called, and there is no DSN for the DB, it gets translated to pgproxy DSN.
  • We start the pgproxy before the deployment in the runner, and pass the local address in an environment variable to the runner.
  • pgproxy gets the active schema, and redirects connections to the DSN defined in the runtime of that schema.

Follow-ups

  • Integrate MySQL proxy
  • Remove DSNs from ModuleContext completely

@github-actions github-actions bot changed the title Juho/module in proxy feat(Juho/module): in proxy Nov 22, 2024
@jvmakine jvmakine changed the title feat(Juho/module): in proxy Resolve DSN from runtime in PG Proxy Nov 22, 2024
@ftl-robot ftl-robot mentioned this pull request Nov 22, 2024
@github-actions github-actions bot changed the title Resolve DSN from runtime in PG Proxy feat: Resolve DSN from runtime in PG Proxy Nov 22, 2024
@jvmakine jvmakine force-pushed the juho/module-in-proxy branch 3 times, most recently from 6457549 to 0a5f94f Compare November 22, 2024 05:00
if !ok {
return "", fmt.Errorf("database %s not found", params["database"])
}
logger.Debugf("Resolved DSN (%s): %s", params["database"], db.Runtime.DSN)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is where the logic to use a dsn resolver based on provisioned runtime (like type: aws-iam-auth) will be added

@jvmakine jvmakine force-pushed the juho/module-in-proxy branch 2 times, most recently from b635b09 to b6ca3cb Compare November 25, 2024 00:15
@jvmakine jvmakine marked this pull request as ready for review November 25, 2024 00:35
@jvmakine jvmakine requested review from a team and alecthomas as code owners November 25, 2024 00:35
@jvmakine jvmakine force-pushed the juho/module-in-proxy branch 2 times, most recently from 262c532 to 1aa21bb Compare November 25, 2024 02:18
@jvmakine jvmakine force-pushed the juho/module-in-proxy branch 3 times, most recently from 6ea7f5b to 7d19c0b Compare November 25, 2024 02:36
Instead, when GetDatabase in the runner is called, and there is no DSN for the DB, it gets translated to pgproxy DSN.

We start the pgproxy before the deployment in the runner, and pass the local address in an environment variable to the runner.
pgproxy gets the active schema, and redirects connections to the DSN defined in the runtime of that schema.

Follow-ups
- Integrate MySQL proxy
- Remove DSNs from ModuleContext completely
@jvmakine jvmakine merged commit 665ccab into main Nov 25, 2024
93 checks passed
@jvmakine jvmakine deleted the juho/module-in-proxy branch November 25, 2024 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants