Skip to content

Commit

Permalink
Exit with code 0 on logs timeout
Browse files Browse the repository at this point in the history
This is not considered as a error and can be retried
  • Loading branch information
bchatelard committed Dec 23, 2024
1 parent 7a523f6 commit 08ab437
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pkg/koyeb/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (query *WatchLogsQuery) Execute() (chan WatchLogsEntry, error) {
// Stop sending ping messages to the websocket connection
conn.Stop()

logs <- WatchLogsEntry{Err: &errors.CLIError{
newErr := &errors.CLIError{
Icon: "⏰",
What: "Disconnected from the logs API",
Why: fmt.Sprintf("forced disconnection after %s", logsTimeout),
Expand All @@ -216,7 +216,8 @@ func (query *WatchLogsQuery) Execute() (chan WatchLogsEntry, error) {
},
Orig: nil,
Solution: "Run the command again to reconnect",
}}
}
log.Errorf("%s", newErr)
close(logs)
case msg := <-readCh:
// Sometimes, for example when passing a future date in --since, the
Expand Down Expand Up @@ -326,23 +327,23 @@ func (query *WatchLogsQuery) PrintAll() error {
if err != nil {
return err
}
for log := range logs {
if log.Err != nil {
return log.Err
for logl := range logs {
if logl.Err != nil {
return logl.Err
}
layout := "2006-01-02 15:04:05"
date := log.Date.Format(layout)
zone, _ := log.Date.Zone()
date := logl.Date.Format(layout)
zone, _ := logl.Date.Zone()

switch outputFormat {
case "json", "yaml":
data, err := json.Marshal(log)
data, err := json.Marshal(logl)
if err != nil {
return err
}
fmt.Printf("%s\n", data)
default:
fmt.Printf("[%s %s] %s %6s - %s\n", date, zone, renderer.FormatID(log.Labels.InstanceID, query.full), log.Stream, log.Msg)
fmt.Printf("[%s %s] %s %6s - %s\n", date, zone, renderer.FormatID(logl.Labels.InstanceID, query.full), logl.Stream, logl.Msg)
}
}
return nil
Expand Down

0 comments on commit 08ab437

Please sign in to comment.