Skip to content

Commit 33d8e92

Browse files
committed
add timeout for cloud-agent build
1 parent 8bdea8b commit 33d8e92

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/lk/agent.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040

4141
const (
4242
maxSecretFileSize = 1024 * 1024 // 1MB
43+
buildTimeout = 10 * time.Minute
4344
)
4445

4546
var (
@@ -580,9 +581,11 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
580581
}
581582
}
582583

584+
buildContext, cancel := context.WithTimeout(ctx, buildTimeout)
585+
defer cancel()
583586
regions := []string{region}
584587
excludeFiles := []string{fmt.Sprintf("**/%s", config.LiveKitTOMLFile)}
585-
resp, err := agentsClient.CreateAgent(ctx, os.DirFS(workingDir), secrets, regions, excludeFiles, os.Stderr)
588+
resp, err := agentsClient.CreateAgent(buildContext, os.DirFS(workingDir), secrets, regions, excludeFiles, os.Stderr)
586589
if err != nil {
587590
if twerr, ok := err.(twirp.Error); ok {
588591
return fmt.Errorf("unable to create agent: %s", twerr.Msg())
@@ -726,8 +729,10 @@ func deployAgent(ctx context.Context, cmd *cli.Command) error {
726729
}
727730
}
728731

732+
buildContext, cancel := context.WithTimeout(ctx, buildTimeout)
733+
defer cancel()
729734
excludeFiles := []string{fmt.Sprintf("**/%s", config.LiveKitTOMLFile)}
730-
if err := agentsClient.DeployAgent(ctx, agentId, os.DirFS(workingDir), secrets, excludeFiles, os.Stderr); err != nil {
735+
if err := agentsClient.DeployAgent(buildContext, agentId, os.DirFS(workingDir), secrets, excludeFiles, os.Stderr); err != nil {
731736
if twerr, ok := err.(twirp.Error); ok {
732737
return fmt.Errorf("unable to deploy agent: %s", twerr.Msg())
733738
}

0 commit comments

Comments
 (0)