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

fix: panic when ftl-controller trying to access config and secrets #1592

Merged
merged 1 commit into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions cmd/ftl-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/TBD54566975/ftl"
"github.com/TBD54566975/ftl/backend/controller"
"github.com/TBD54566975/ftl/backend/controller/scaling"
cf "github.com/TBD54566975/ftl/common/configuration"
_ "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/observability"
Expand All @@ -22,6 +23,7 @@ var cli struct {
ObservabilityConfig observability.Config `embed:"" prefix:"o11y-"`
LogConfig log.Config `embed:"" prefix:"log-"`
ControllerConfig controller.Config `embed:""`
ConfigFlag []string `name:"config" short:"C" help:"Paths to FTL project configuration files." env:"FTL_CONFIG" placeholder:"FILE[,FILE,...]"`
}

func main() {
Expand All @@ -38,6 +40,28 @@ func main() {
err = observability.Init(ctx, "ftl-controller", ftl.Version, cli.ObservabilityConfig)
kctx.FatalIfErrorf(err, "failed to initialize observability")

// This is duplicating the logic in the `ftl/main.go` to resolve the current panic
// However, this should be updated to only allow providers that are supported on the current environment
// See https://github.com/TBD54566975/ftl/issues/1473 for more information
sr := cf.ProjectConfigResolver[cf.Secrets]{Config: cli.ConfigFlag}
cr := cf.ProjectConfigResolver[cf.Configuration]{Config: cli.ConfigFlag}
kctx.BindTo(sr, (*cf.Resolver[cf.Secrets])(nil))
kctx.BindTo(cr, (*cf.Resolver[cf.Configuration])(nil))

// Add config manager to context.
cm, err := cf.NewConfigurationManager(ctx, cr)
if err != nil {
kctx.Fatalf(err.Error())
}
ctx = cf.ContextWithConfig(ctx, cm)

// Add secrets manager to context.
sm, err := cf.NewSecretsManager(ctx, sr)
if err != nil {
kctx.Fatalf(err.Error())
}
ctx = cf.ContextWithSecrets(ctx, sm)

err = controller.Start(ctx, cli.ControllerConfig, scaling.NewK8sScaling())
kctx.FatalIfErrorf(err)
}
Loading