Skip to content
Open
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
9 changes: 8 additions & 1 deletion cmd/lk/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,11 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
return err
} else if viewLogs {
fmt.Println("Tailing runtime logs...safe to exit at any time")
return agentsClient.StreamLogs(ctx, "deploy", lkConfig.Agent.ID, os.Stdout, resp.ServerRegions[0])
logRegion := region
if len(resp.ServerRegions) > 0 {
logRegion = resp.ServerRegions[0]
}
return agentsClient.StreamLogs(ctx, "deploy", lkConfig.Agent.ID, os.Stdout, logRegion)
}
}
return nil
Expand Down Expand Up @@ -1014,6 +1018,9 @@ func getLogs(ctx context.Context, cmd *cli.Command) error {
if len(response.Agents) == 0 {
return fmt.Errorf("no agent deployments found")
}
if len(response.Agents[0].AgentDeployments) == 0 {
return fmt.Errorf("agent has no deployments to stream logs from")
}

return agentsClient.StreamLogs(ctx, cmd.String("log-type"), agentID, os.Stdout, response.Agents[0].AgentDeployments[0].ServerRegion)
}
Expand Down
Loading