From f5554a14687d27f525cc733f9fd2606ca82c4e1a Mon Sep 17 00:00:00 2001 From: Juho Makinen Date: Fri, 22 Nov 2024 13:03:02 +1100 Subject: [PATCH 1/4] fix: pass module schema to the pgproxy --- backend/runner/runner.go | 95 +++++++++++++++++++++++++++------------- cmd/ftl-runner/main.go | 22 +--------- 2 files changed, 66 insertions(+), 51 deletions(-) diff --git a/backend/runner/runner.go b/backend/runner/runner.go index 981127723..663f1253f 100644 --- a/backend/runner/runner.go +++ b/backend/runner/runner.go @@ -24,6 +24,7 @@ import ( "github.com/alecthomas/types/optional" "github.com/jpillora/backoff" "github.com/otiai10/copy" + "golang.org/x/sync/errgroup" "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/timestamppb" @@ -39,6 +40,7 @@ import ( "github.com/TBD54566975/ftl/internal/log" "github.com/TBD54566975/ftl/internal/model" ftlobservability "github.com/TBD54566975/ftl/internal/observability" + "github.com/TBD54566975/ftl/internal/pgproxy" "github.com/TBD54566975/ftl/internal/rpc" "github.com/TBD54566975/ftl/internal/schema" "github.com/TBD54566975/ftl/internal/slices" @@ -61,6 +63,8 @@ type Config struct { Registry artefacts.RegistryConfig `embed:"" prefix:"oci-"` ObservabilityConfig ftlobservability.Config `embed:"" prefix:"o11y-"` DevEndpoint optional.Option[url.URL] `help:"An existing endpoint to connect to in development mode" env:"FTL_DEV_ENDPOINT"` + + PgProxyConfig pgproxy.Config `embed:"" prefix:"pgproxy-"` } func Start(ctx context.Context, config Config) error { @@ -129,7 +133,20 @@ func Start(ctx context.Context, config Config) error { cancelFunc: doneFunc, devEndpoint: config.DevEndpoint, } - err = svc.deploy(ctx) + + deploymentKey, err := model.ParseDeploymentKey(config.Deployment) + if err != nil { + observability.Deployment.Failure(ctx, optional.None[string]()) + svc.cancelFunc() + return connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("invalid deployment key: %w", err)) + } + + module, err := svc.GetModule(ctx, deploymentKey) + if err != nil { + return fmt.Errorf("failed to get module: %w", err) + } + + err = svc.deploy(ctx, deploymentKey, module) if err != nil { // If we fail to deploy we just exit // Kube or local scaling will start a new instance to continue @@ -143,11 +160,19 @@ func Start(ctx context.Context, config Config) error { go rpc.RetryStreamingClientStream(ctx, backoff.Backoff{}, controllerClient.StreamDeploymentLogs, svc.streamLogsLoop) }() - return rpc.Serve(ctx, config.Bind, - rpc.GRPC(ftlv1connect.NewVerbServiceHandler, svc), - rpc.HTTP("/", svc), - rpc.HealthCheck(svc.healthCheck), - ) + g, ctx := errgroup.WithContext(ctx) + g.Go(func() error { + return svc.StartPgProxy(ctx, module) + }) + g.Go(func() error { + // TODO: Make sure pgproxy is ready before starting the runner + return rpc.Serve(ctx, config.Bind, + rpc.GRPC(ftlv1connect.NewVerbServiceHandler, svc), + rpc.HTTP("/", svc), + rpc.HealthCheck(svc.healthCheck), + ) + }) + return fmt.Errorf("failure in runner: %w", g.Wait()) } func newIdentityStore(ctx context.Context, config Config, key model.RunnerKey, controllerClient ftlv1connect.ControllerServiceClient) (*identity.Store, error) { @@ -294,26 +319,32 @@ func (s *Service) Ping(ctx context.Context, req *connect.Request[ftlv1.PingReque return connect.NewResponse(&ftlv1.PingResponse{}), nil } -func (s *Service) deploy(ctx context.Context) error { - logger := log.FromContext(ctx) - if err, ok := s.registrationFailure.Load().Get(); ok { - observability.Deployment.Failure(ctx, optional.None[string]()) - return connect.NewError(connect.CodeUnavailable, fmt.Errorf("failed to register runner: %w", err)) +func (s *Service) GetModule(ctx context.Context, key model.DeploymentKey) (*schema.Module, error) { + gdResp, err := s.controllerClient.GetDeployment(ctx, connect.NewRequest(&ftlv1.GetDeploymentRequest{DeploymentKey: s.config.Deployment})) + if err != nil { + observability.Deployment.Failure(ctx, optional.Some(key.String())) + return nil, fmt.Errorf("failed to get deployment: %w", err) } - key, err := model.ParseDeploymentKey(s.config.Deployment) + module, err := schema.ModuleFromProto(gdResp.Msg.Schema) if err != nil { + observability.Deployment.Failure(ctx, optional.Some(key.String())) + return nil, fmt.Errorf("invalid module: %w", err) + } + return module, nil +} + +func (s *Service) deploy(ctx context.Context, key model.DeploymentKey, module *schema.Module) error { + logger := log.FromContext(ctx) + + if err, ok := s.registrationFailure.Load().Get(); ok { observability.Deployment.Failure(ctx, optional.None[string]()) - s.cancelFunc() - return connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("invalid deployment key: %w", err)) + return connect.NewError(connect.CodeUnavailable, fmt.Errorf("failed to register runner: %w", err)) } observability.Deployment.Started(ctx, key.String()) defer observability.Deployment.Completed(ctx, key.String()) - deploymentLogger := s.getDeploymentLogger(ctx, key) - ctx = log.ContextWithLogger(ctx, deploymentLogger) - s.lock.Lock() defer s.lock.Unlock() if s.deployment.Load().Ok() { @@ -321,25 +352,18 @@ func (s *Service) deploy(ctx context.Context) error { return errors.New("already deployed") } - gdResp, err := s.controllerClient.GetDeployment(ctx, connect.NewRequest(&ftlv1.GetDeploymentRequest{DeploymentKey: s.config.Deployment})) - if err != nil { - observability.Deployment.Failure(ctx, optional.Some(key.String())) - return fmt.Errorf("failed to get deployment: %w", err) - } - module, err := schema.ModuleFromProto(gdResp.Msg.Schema) - if err != nil { - observability.Deployment.Failure(ctx, optional.Some(key.String())) - return fmt.Errorf("invalid module: %w", err) - } + deploymentLogger := s.getDeploymentLogger(ctx, key) + ctx = log.ContextWithLogger(ctx, deploymentLogger) + deploymentDir := filepath.Join(s.config.DeploymentDir, module.Name, key.String()) if s.config.TemplateDir != "" { - err = copy.Copy(s.config.TemplateDir, deploymentDir) + err := copy.Copy(s.config.TemplateDir, deploymentDir) if err != nil { observability.Deployment.Failure(ctx, optional.Some(key.String())) return fmt.Errorf("failed to copy template directory: %w", err) } } else { - err = os.MkdirAll(deploymentDir, 0700) + err := os.MkdirAll(deploymentDir, 0700) if err != nil { observability.Deployment.Failure(ctx, optional.Some(key.String())) return fmt.Errorf("failed to create deployment directory: %w", err) @@ -377,7 +401,7 @@ func (s *Service) deploy(ctx context.Context) error { deployment, cmdCtx, err := plugin.Spawn( unstoppable.Context(verbCtx), log.FromContext(ctx).GetLevel(), - gdResp.Msg.Schema.Name, + module.Name, deploymentDir, "./launch", ftlv1connect.NewVerbServiceClient, @@ -568,3 +592,14 @@ func (s *Service) healthCheck(writer http.ResponseWriter, request *http.Request) } writer.WriteHeader(http.StatusServiceUnavailable) } + +func (s *Service) StartPgProxy(ctx context.Context, module *schema.Module) error { + if err := pgproxy.New(s.config.PgProxyConfig, func(ctx context.Context, params map[string]string) (string, error) { + db := params["database"] + + return "postgres://127.0.0.1:5432/" + db + "?user=" + params["user"], nil + }).Start(ctx); err != nil { + return fmt.Errorf("failed to start pgproxy: %w", err) + } + return nil +} diff --git a/cmd/ftl-runner/main.go b/cmd/ftl-runner/main.go index b1126290f..df951a680 100644 --- a/cmd/ftl-runner/main.go +++ b/cmd/ftl-runner/main.go @@ -2,25 +2,21 @@ package main import ( "context" - "fmt" "os" "path/filepath" "github.com/alecthomas/kong" - "golang.org/x/sync/errgroup" "github.com/TBD54566975/ftl" "github.com/TBD54566975/ftl/backend/runner" _ "github.com/TBD54566975/ftl/internal/automaxprocs" // Set GOMAXPROCS to match Linux container CPU quota. "github.com/TBD54566975/ftl/internal/log" - "github.com/TBD54566975/ftl/internal/pgproxy" ) var cli struct { Version kong.VersionFlag `help:"Show version."` LogConfig log.Config `prefix:"log-" embed:""` RunnerConfig runner.Config `embed:""` - ProxyConfig pgproxy.Config `embed:"" prefix:"pgproxy-"` } func main() { @@ -47,21 +43,5 @@ and route to user code. logger := log.Configure(os.Stderr, cli.LogConfig) ctx := log.ContextWithLogger(context.Background(), logger) - g, ctx := errgroup.WithContext(ctx) - g.Go(func() error { - return runPGProxy(ctx, cli.ProxyConfig) - }) - g.Go(func() error { - return runner.Start(ctx, cli.RunnerConfig) - }) - kctx.FatalIfErrorf(g.Wait()) -} - -func runPGProxy(ctx context.Context, config pgproxy.Config) error { - if err := pgproxy.New(config, func(ctx context.Context, params map[string]string) (string, error) { - return "postgres://127.0.0.1:5432/postgres?user=" + params["user"], nil - }).Start(ctx); err != nil { - return fmt.Errorf("failed to start pgproxy: %w", err) - } - return nil + kctx.FatalIfErrorf(runner.Start(ctx, cli.RunnerConfig)) } From f2a91ef896c01145ddd4bd4978b5b3844b8fed75 Mon Sep 17 00:00:00 2001 From: Juho Makinen Date: Fri, 22 Nov 2024 14:00:21 +1100 Subject: [PATCH 2/4] fix: resolve the pg DSN from runtime in the proxy --- backend/controller/controller.go | 14 +++++++++++++- backend/runner/runner.go | 19 ++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/backend/controller/controller.go b/backend/controller/controller.go index 7365bca34..95d9898cb 100644 --- a/backend/controller/controller.go +++ b/backend/controller/controller.go @@ -769,9 +769,21 @@ func (s *Service) GetModuleContext(ctx context.Context, req *connect.Request[ftl continue } dbTypes[db.Name] = dbType + // TODO: Move the DSN resolution to the runtime if db.Runtime != nil { + var dsn string + switch dbType { + case modulecontext.DBTypePostgres: + // TODO: Get the port from config + dsn = "postgres://127.0.0.1:5678/" + db.Name + case modulecontext.DBTypeMySQL: + // TODO: Route MySQL through a proxy as well + dsn = db.Runtime.DSN + default: + return connect.NewError(connect.CodeInternal, fmt.Errorf("unknown DB type: %s", db.Type)) + } databases[db.Name] = modulecontext.Database{ - DSN: db.Runtime.DSN, + DSN: dsn, DBType: dbType, } } diff --git a/backend/runner/runner.go b/backend/runner/runner.go index 663f1253f..eb4026d8e 100644 --- a/backend/runner/runner.go +++ b/backend/runner/runner.go @@ -162,7 +162,7 @@ func Start(ctx context.Context, config Config) error { g, ctx := errgroup.WithContext(ctx) g.Go(func() error { - return svc.StartPgProxy(ctx, module) + return svc.startPgProxy(ctx, module) }) g.Go(func() error { // TODO: Make sure pgproxy is ready before starting the runner @@ -593,11 +593,20 @@ func (s *Service) healthCheck(writer http.ResponseWriter, request *http.Request) writer.WriteHeader(http.StatusServiceUnavailable) } -func (s *Service) StartPgProxy(ctx context.Context, module *schema.Module) error { - if err := pgproxy.New(s.config.PgProxyConfig, func(ctx context.Context, params map[string]string) (string, error) { - db := params["database"] +func (s *Service) startPgProxy(ctx context.Context, module *schema.Module) error { + databases := map[string]*schema.Database{} + for _, decl := range module.Decls { + if db, ok := decl.(*schema.Database); ok { + databases[db.Name] = db + } + } - return "postgres://127.0.0.1:5432/" + db + "?user=" + params["user"], nil + if err := pgproxy.New(s.config.PgProxyConfig, func(ctx context.Context, params map[string]string) (string, error) { + db, ok := databases[params["database"]] + if !ok { + return "", fmt.Errorf("database %s not found", params["database"]) + } + return db.Runtime.DSN, nil }).Start(ctx); err != nil { return fmt.Errorf("failed to start pgproxy: %w", err) } From 0a5f94f6d121f541cbd1cc1f759e20f042e4f50e Mon Sep 17 00:00:00 2001 From: Juho Makinen Date: Fri, 22 Nov 2024 14:55:39 +1100 Subject: [PATCH 3/4] fix: resolve pg DSN in the runner --- backend/controller/controller.go | 17 +++------------- backend/runner/runner.go | 25 +++++++++++++++--------- cmd/ftl-proxy-pg/main.go | 4 ++-- internal/modulecontext/module_context.go | 5 +++++ internal/pgproxy/pgproxy.go | 20 +++++++++++++++---- 5 files changed, 42 insertions(+), 29 deletions(-) diff --git a/backend/controller/controller.go b/backend/controller/controller.go index 95d9898cb..5470ba26b 100644 --- a/backend/controller/controller.go +++ b/backend/controller/controller.go @@ -769,21 +769,10 @@ func (s *Service) GetModuleContext(ctx context.Context, req *connect.Request[ftl continue } dbTypes[db.Name] = dbType - // TODO: Move the DSN resolution to the runtime - if db.Runtime != nil { - var dsn string - switch dbType { - case modulecontext.DBTypePostgres: - // TODO: Get the port from config - dsn = "postgres://127.0.0.1:5678/" + db.Name - case modulecontext.DBTypeMySQL: - // TODO: Route MySQL through a proxy as well - dsn = db.Runtime.DSN - default: - return connect.NewError(connect.CodeInternal, fmt.Errorf("unknown DB type: %s", db.Type)) - } + // TODO: Move the DSN resolution to the runtime once MySQL proxy is working + if db.Runtime != nil && dbType == modulecontext.DBTypeMySQL { databases[db.Name] = modulecontext.Database{ - DSN: dsn, + DSN: db.Runtime.DSN, DBType: dbType, } } diff --git a/backend/runner/runner.go b/backend/runner/runner.go index eb4026d8e..576cef682 100644 --- a/backend/runner/runner.go +++ b/backend/runner/runner.go @@ -63,8 +63,6 @@ type Config struct { Registry artefacts.RegistryConfig `embed:"" prefix:"oci-"` ObservabilityConfig ftlobservability.Config `embed:"" prefix:"o11y-"` DevEndpoint optional.Option[url.URL] `help:"An existing endpoint to connect to in development mode" env:"FTL_DEV_ENDPOINT"` - - PgProxyConfig pgproxy.Config `embed:"" prefix:"pgproxy-"` } func Start(ctx context.Context, config Config) error { @@ -141,7 +139,7 @@ func Start(ctx context.Context, config Config) error { return connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("invalid deployment key: %w", err)) } - module, err := svc.GetModule(ctx, deploymentKey) + module, err := svc.getModule(ctx, deploymentKey) if err != nil { return fmt.Errorf("failed to get module: %w", err) } @@ -160,12 +158,17 @@ func Start(ctx context.Context, config Config) error { go rpc.RetryStreamingClientStream(ctx, backoff.Backoff{}, controllerClient.StreamDeploymentLogs, svc.streamLogsLoop) }() + pgProxyStarted := make(chan pgproxy.Started) + g, ctx := errgroup.WithContext(ctx) g.Go(func() error { - return svc.startPgProxy(ctx, module) + return svc.startPgProxy(ctx, module, pgProxyStarted) }) g.Go(func() error { - // TODO: Make sure pgproxy is ready before starting the runner + pgProxy := <-pgProxyStarted + os.Setenv("PG_PROXY_ADDRESS", fmt.Sprintf("127.0.0.1:%d", pgProxy.Address.Port)) + logger.Debugf("PG_PROXY_ADDRESS: %s", os.Getenv("PG_PROXY_ADDRESS")) + return rpc.Serve(ctx, config.Bind, rpc.GRPC(ftlv1connect.NewVerbServiceHandler, svc), rpc.HTTP("/", svc), @@ -319,7 +322,7 @@ func (s *Service) Ping(ctx context.Context, req *connect.Request[ftlv1.PingReque return connect.NewResponse(&ftlv1.PingResponse{}), nil } -func (s *Service) GetModule(ctx context.Context, key model.DeploymentKey) (*schema.Module, error) { +func (s *Service) getModule(ctx context.Context, key model.DeploymentKey) (*schema.Module, error) { gdResp, err := s.controllerClient.GetDeployment(ctx, connect.NewRequest(&ftlv1.GetDeploymentRequest{DeploymentKey: s.config.Deployment})) if err != nil { observability.Deployment.Failure(ctx, optional.Some(key.String())) @@ -593,7 +596,9 @@ func (s *Service) healthCheck(writer http.ResponseWriter, request *http.Request) writer.WriteHeader(http.StatusServiceUnavailable) } -func (s *Service) startPgProxy(ctx context.Context, module *schema.Module) error { +func (s *Service) startPgProxy(ctx context.Context, module *schema.Module, started chan<- pgproxy.Started) error { + logger := log.FromContext(ctx) + databases := map[string]*schema.Database{} for _, decl := range module.Decls { if db, ok := decl.(*schema.Database); ok { @@ -601,13 +606,15 @@ func (s *Service) startPgProxy(ctx context.Context, module *schema.Module) error } } - if err := pgproxy.New(s.config.PgProxyConfig, func(ctx context.Context, params map[string]string) (string, error) { + if err := pgproxy.New(":0", func(ctx context.Context, params map[string]string) (string, error) { db, ok := databases[params["database"]] if !ok { return "", fmt.Errorf("database %s not found", params["database"]) } + logger.Debugf("Resolved DSN (%s): %s", params["database"], db.Runtime.DSN) + return db.Runtime.DSN, nil - }).Start(ctx); err != nil { + }).Start(ctx, started); err != nil { return fmt.Errorf("failed to start pgproxy: %w", err) } return nil diff --git a/cmd/ftl-proxy-pg/main.go b/cmd/ftl-proxy-pg/main.go index 781fda75d..1bf84fbd5 100644 --- a/cmd/ftl-proxy-pg/main.go +++ b/cmd/ftl-proxy-pg/main.go @@ -38,10 +38,10 @@ func main() { err = observability.Init(ctx, false, "", "ftl-provisioner", ftl.Version, cli.ObservabilityConfig) kctx.FatalIfErrorf(err, "failed to initialize observability") - proxy := pgproxy.New(cli.Config, func(ctx context.Context, params map[string]string) (string, error) { + proxy := pgproxy.New(cli.Config.Listen, func(ctx context.Context, params map[string]string) (string, error) { return "postgres://localhost:5432/postgres?user=" + params["user"], nil }) - if err := proxy.Start(ctx); err != nil { + if err := proxy.Start(ctx, nil); err != nil { kctx.FatalIfErrorf(err, "failed to start proxy") } } diff --git a/internal/modulecontext/module_context.go b/internal/modulecontext/module_context.go index 05d063185..ef1e91144 100644 --- a/internal/modulecontext/module_context.go +++ b/internal/modulecontext/module_context.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "os" "strings" "sync" "time" @@ -159,6 +160,10 @@ func (m ModuleContext) GetSecret(name string, value any) error { func (m ModuleContext) GetDatabase(name string, dbType DBType) (string, bool, error) { db, ok := m.databases[name] if !ok { + if dbType == DBTypePostgres { + proxyAddress := os.Getenv("PG_PROXY_ADDRESS") + return "postgres://" + proxyAddress + "/" + name, false, nil + } return "", false, fmt.Errorf("missing DSN for database %s", name) } if db.DBType != dbType { diff --git a/internal/pgproxy/pgproxy.go b/internal/pgproxy/pgproxy.go index 916bdcaec..d16bdc529 100644 --- a/internal/pgproxy/pgproxy.go +++ b/internal/pgproxy/pgproxy.go @@ -30,15 +30,19 @@ type DSNConstructor func(ctx context.Context, params map[string]string) (string, // // address is the address to listen on for incoming connections. // connectionFn is a function that constructs a new connection string from parameters of the incoming connection. -func New(config Config, connectionFn DSNConstructor) *PgProxy { +func New(listenAddress string, connectionFn DSNConstructor) *PgProxy { return &PgProxy{ - listenAddress: config.Listen, + listenAddress: listenAddress, connectionStringFn: connectionFn, } } -// Start the proxy. -func (p *PgProxy) Start(ctx context.Context) error { +type Started struct { + Address *net.TCPAddr +} + +// Start the proxy +func (p *PgProxy) Start(ctx context.Context, started chan<- Started) error { logger := log.FromContext(ctx) listener, err := net.Listen("tcp", p.listenAddress) @@ -47,6 +51,14 @@ func (p *PgProxy) Start(ctx context.Context) error { } defer listener.Close() + if started != nil { + addr, ok := listener.Addr().(*net.TCPAddr) + if !ok { + panic("failed to get TCP address") + } + started <- Started{Address: addr} + } + for { conn, err := listener.Accept() if err != nil { From 240c16acbc01857b3cd63849fd3b1face17d2ff6 Mon Sep 17 00:00:00 2001 From: Juho Makinen Date: Fri, 22 Nov 2024 16:26:09 +1100 Subject: [PATCH 4/4] fix: construct db dsn in Go runtime --- go-runtime/server/database.go | 19 +++++++++++++------ internal/integration/harness.go | 1 + internal/modulecontext/module_context.go | 5 ----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/go-runtime/server/database.go b/go-runtime/server/database.go index 9ea1b9da7..ee046a141 100644 --- a/go-runtime/server/database.go +++ b/go-runtime/server/database.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "fmt" + "os" "reflect" "time" @@ -47,11 +48,17 @@ func InitDatabase(ref reflection.Ref, dbtype string, protoDBtype modulecontext.D DBType: dbtype, DB: once.Once(func(ctx context.Context) (*sql.DB, error) { logger := log.FromContext(ctx) - - provider := modulecontext.FromContext(ctx).CurrentContext() - dsn, testDB, err := provider.GetDatabase(ref.Name, protoDBtype) - if err != nil { - return nil, fmt.Errorf("failed to get database %q: %w", ref.Name, err) + var dsn string + if protoDBtype == modulecontext.DBTypePostgres { + proxyAddress := os.Getenv("PG_PROXY_ADDRESS") + dsn = "postgres://" + proxyAddress + "/" + ref.Name + } else { + provider := modulecontext.FromContext(ctx).CurrentContext() + d, _, err := provider.GetDatabase(ref.Name, protoDBtype) + if err != nil { + return nil, fmt.Errorf("failed to get database %q: %w", ref.Name, err) + } + dsn = d } logger.Debugf("Opening database: %s", ref.Name) @@ -71,7 +78,7 @@ func InitDatabase(ref reflection.Ref, dbtype string, protoDBtype modulecontext.D return nil, fmt.Errorf("failed to register database metrics: %w", err) } db.SetConnMaxIdleTime(time.Minute) - if testDB { + if os.Getenv("FTL_INTEGRATION_TEST") == "true" { // In tests we always close the connections, as the DB being clean might invalidate pooled connections db.SetMaxIdleConns(0) } else { diff --git a/internal/integration/harness.go b/internal/integration/harness.go index 2dde020f5..5c97ae0f2 100644 --- a/internal/integration/harness.go +++ b/internal/integration/harness.go @@ -218,6 +218,7 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) { for key, value := range opts.envars { t.Setenv(key, value) } + t.Setenv("FTL_INTEGRATION_TEST", "true") cwd, err := os.Getwd() assert.NoError(t, err) diff --git a/internal/modulecontext/module_context.go b/internal/modulecontext/module_context.go index ef1e91144..05d063185 100644 --- a/internal/modulecontext/module_context.go +++ b/internal/modulecontext/module_context.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "os" "strings" "sync" "time" @@ -160,10 +159,6 @@ func (m ModuleContext) GetSecret(name string, value any) error { func (m ModuleContext) GetDatabase(name string, dbType DBType) (string, bool, error) { db, ok := m.databases[name] if !ok { - if dbType == DBTypePostgres { - proxyAddress := os.Getenv("PG_PROXY_ADDRESS") - return "postgres://" + proxyAddress + "/" + name, false, nil - } return "", false, fmt.Errorf("missing DSN for database %s", name) } if db.DBType != dbType {