Skip to content

Commit

Permalink
fix: when running with --provisioners=1, use provisioner to do deploy…
Browse files Browse the repository at this point in the history
…ments with ftl dev (#3011)
  • Loading branch information
jvmakine authored Oct 7, 2024
1 parent 3f355e4 commit cfbce05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions backend/provisioner/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -79,13 +80,15 @@ 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 {
// TODO: Deal with failed deployments
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)
Expand Down
10 changes: 8 additions & 2 deletions frontend/cli/cmd_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit cfbce05

Please sign in to comment.