Skip to content

Commit

Permalink
surface client errors
Browse files Browse the repository at this point in the history
Errors from the gatherer tomb are not being surfaced to the user, as there is
nothing checking tomb.Err().
Additionally, a write/flush failure should not bring down the gatherer - it
could be e.g. a temporary outage.
Better to log the failures rather than exiting the main loop.
  • Loading branch information
barrettj12 committed Aug 2, 2023
1 parent 760e7a4 commit 6e03c0c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internals/overlord/logstate/gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"time"

"github.com/canonical/pebble/internals/logger"

Check failure on line 22 in internals/overlord/logstate/gatherer.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s Prefix(github.com/canonical/pebble) (gci)
"gopkg.in/tomb.v2"

Check failure on line 24 in internals/overlord/logstate/gatherer.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s Prefix(github.com/canonical/pebble) (gci)
"github.com/canonical/pebble/internals/plan"
Expand Down Expand Up @@ -167,13 +168,13 @@ mainLoop:
// Timeout - flush
err := g.client.Flush(g.clientCtx)
if err != nil {
return fmt.Errorf("sending logs to target %q: %v", g.targetName, err)
logger.Noticef("sending logs to target %q: %v", g.targetName, err)
}

case entry := <-g.entryCh:
err := g.client.Write(g.clientCtx, entry)
if err != nil {
return fmt.Errorf("writing logs to target %q: %v", g.targetName, err)
logger.Noticef("writing logs to target %q: %v", g.targetName, err)
}
}
}
Expand All @@ -183,7 +184,7 @@ mainLoop:
defer cancel()
err := g.client.Flush(ctx)
if err != nil {
return fmt.Errorf("sending logs to target %q: %v", g.targetName, err)
logger.Noticef("sending logs to target %q: %v", g.targetName, err)
}
return nil
}
Expand Down

0 comments on commit 6e03c0c

Please sign in to comment.