Skip to content
Open
Show file tree
Hide file tree
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
17 changes: 16 additions & 1 deletion cmd/lk/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,21 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
excludeFiles := []string{fmt.Sprintf("**/%s", config.LiveKitTOMLFile)}
resp, err := agentsClient.CreateAgent(buildContext, os.DirFS(workingDir), secrets, regions, attrs, excludeFiles, os.Stderr)
if err != nil {
// Under --user-auth, CreateAgent can fail after it created the agent.
// Save its ID then, as the --image path does once it registers the
// agent, so that `lk agent deploy` and `lk agent status` find it.
var created *agentCreatedError
if errors.As(err, &created) {
lkConfig.Agent.ID = created.agentID
if saveErr := lkConfig.SaveTOMLFile(workingDir, tomlFilename); saveErr != nil {
return errors.Join(fmt.Errorf("unable to create agent: %w", err), saveErr)
}
out.Statusf("Created agent with ID [%s]", util.Accented(created.agentID))
}
if errors.Is(err, context.Canceled) && created != nil {
out.Status("Disconnected. The build continues on the server; run `lk agent status` to check.")
return nil
}
if errors.Is(err, context.Canceled) {
// The client disconnected (Ctrl-C). The agent is registered and its build runs
// to completion on the server, so this is not a failure. The agent ID was not
Expand Down Expand Up @@ -857,7 +872,7 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
return fmt.Errorf("agent [%s] was created, but no region was returned to stream its logs from; view them with `lk agent logs`", resp.AgentId)
}
out.Status("Tailing runtime logs...safe to exit at any time")
return agentsClient.StreamLogs(ctx, "deploy", lkConfig.Agent.ID, "", os.Stdout, resp.ServerRegions[0])
return tailCreatedAgentLogs(ctx, agentsClient, lkConfig.Agent.ID, resp.ServerRegions[0], os.Stdout)
}
}
return nil
Expand Down
337 changes: 326 additions & 11 deletions cmd/lk/agent_user_auth.go

Large diffs are not rendered by default.

Loading
Loading