Skip to content

Commit

Permalink
feat: timeout for deploy command
Browse files Browse the repository at this point in the history
Also limit test deploy to 1m to help diagnose issues
  • Loading branch information
stuartwdouglas committed Nov 20, 2024
1 parent 51d3c55 commit 8d32f25
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 20 additions & 6 deletions frontend/cli/cmd_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"context"
"fmt"
"time"

"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect"
"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1beta1/provisioner/provisionerconnect"
Expand All @@ -10,10 +12,11 @@ import (
)

type deployCmd struct {
Replicas int32 `short:"n" help:"Number of replicas to deploy." default:"1"`
NoWait bool `help:"Do not wait for deployment to complete." default:"false"`
UseProvisioner bool `help:"Use the ftl-provisioner to deploy the application." default:"false" hidden:"true"`
Build buildCmd `embed:""`
Replicas int32 `short:"n" help:"Number of replicas to deploy." default:"1"`
NoWait bool `help:"Do not wait for deployment to complete." default:"false"`
UseProvisioner bool `help:"Use the ftl-provisioner to deploy the application." default:"false" hidden:"true"`
Build buildCmd `embed:""`
Timeout time.Duration `short:"t" help:"Timeout for the deployment."`
}

func (d *deployCmd) Run(
Expand All @@ -31,7 +34,13 @@ func (d *deployCmd) Run(
}

// Cancel build engine context to ensure all language plugins are killed.
ctx, cancel := context.WithCancel(ctx)
var cancel context.CancelFunc
if d.Timeout > 0 {
ctx, cancel = context.WithTimeout(ctx, d.Timeout)
defer cancel()
} else {
ctx, cancel = context.WithCancel(ctx)
}
defer cancel()
engine, err := buildengine.New(
ctx, client, schemaClient, projConfig, d.Build.Dirs,
Expand All @@ -41,5 +50,10 @@ func (d *deployCmd) Run(
if err != nil {
return err
}
return engine.BuildAndDeploy(ctx, d.Replicas, !d.NoWait)

err = engine.BuildAndDeploy(ctx, d.Replicas, !d.NoWait)
if err != nil {
return fmt.Errorf("failed to deploy: %w", err)
}
return nil
}
2 changes: 1 addition & 1 deletion internal/integration/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func ExpectError(action Action, expectedErrorMsg ...string) Action {
func Deploy(module string) Action {
return Chain(
func(t testing.TB, ic TestContext) {
args := []string{"deploy"}
args := []string{"deploy", "-t", "4m"}
if ic.Provisioner != nil {
args = append(args, "--use-provisioner", "--provisioner-endpoint=http://localhost:8893")
}
Expand Down

0 comments on commit 8d32f25

Please sign in to comment.