From cfbce05d8b3a6e015a5ae6f8e4b4b5ea1b02be14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20M=C3=A4kinen?= Date: Tue, 8 Oct 2024 09:01:59 +1100 Subject: [PATCH] fix: when running with --provisioners=1, use provisioner to do deployments with ftl dev (#3011) --- backend/provisioner/service.go | 3 +++ frontend/cli/cmd_dev.go | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/provisioner/service.go b/backend/provisioner/service.go index 999003c08..936adc416 100644 --- a/backend/provisioner/service.go +++ b/backend/provisioner/service.go @@ -61,6 +61,7 @@ func (s *Service) Ping(context.Context, *connect.Request[ftlv1.PingRequest]) (*c } func (s *Service) CreateDeployment(ctx context.Context, req *connect.Request[ftlv1.CreateDeploymentRequest]) (*connect.Response[ftlv1.CreateDeploymentResponse], error) { + logger := log.FromContext(ctx) // TODO: Block deployments to make sure only one module is modified at a time moduleName := req.Msg.Schema.Name module, err := schema.ModuleFromProto(req.Msg.Schema) @@ -79,6 +80,7 @@ func (s *Service) CreateDeployment(ctx context.Context, req *connect.Request[ftl deployment := s.registry.CreateDeployment(moduleName, desiredResources, existingResources) running := true + logger.Debugf("Running deployment for module %s", moduleName) for running { running, err = deployment.Progress(ctx) if err != nil { @@ -86,6 +88,7 @@ func (s *Service) CreateDeployment(ctx context.Context, req *connect.Request[ftl return nil, fmt.Errorf("error running a provisioner: %w", err) } } + logger.Debugf("Finished deployment for module %s", moduleName) // TODO: manage multiple deployments properly. Extract as a provisioner plugin response, err := s.controllerClient.CreateDeployment(ctx, req) diff --git a/frontend/cli/cmd_dev.go b/frontend/cli/cmd_dev.go index 2dc314937..c1f44378b 100644 --- a/frontend/cli/cmd_dev.go +++ b/frontend/cli/cmd_dev.go @@ -11,6 +11,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect" + "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1beta1/provisioner/provisionerconnect" "github.com/TBD54566975/ftl/internal/buildengine" "github.com/TBD54566975/ftl/internal/dev" "github.com/TBD54566975/ftl/internal/log" @@ -39,8 +40,13 @@ func (d *devCmd) Run(ctx context.Context, k *kong.Kong, projConfig projectconfig return errors.New("no directories specified") } - client := rpc.ClientFromContext[ftlv1connect.ControllerServiceClient](ctx) - terminal.LaunchEmbeddedConsole(ctx, k, bindContext, client) + controllerClient := rpc.ClientFromContext[ftlv1connect.ControllerServiceClient](ctx) + terminal.LaunchEmbeddedConsole(ctx, k, bindContext, controllerClient) + + var client buildengine.DeployClient = controllerClient + if d.ServeCmd.Provisioners > 0 { + client = rpc.ClientFromContext[provisionerconnect.ProvisionerServiceClient](ctx) + } g, ctx := errgroup.WithContext(ctx)