Skip to content

Commit

Permalink
Promtail: Prevent logging errors on normal shutdown (#8988)
Browse files Browse the repository at this point in the history
**What this PR does / why we need it**:
Since PR #4066 two messages are logged for the errors `ErrExpired` and
`EOF`, whereas nothing has been logged beforehand.

As `ErrExpired` is returned by the `JournalReader` after sending a
message to the `until` channel to signal a normal stop, this should not
be logged as an error.

(cherry picked from commit 46af2cd)
  • Loading branch information
darxriggs authored and grafanabot committed May 5, 2023
1 parent 4f55ef9 commit 07c4014
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@

## 2.8.0 (2023-04-04)

* [8474](https://github.com/grafana/loki/pull/8787) **andriikushch**: Promtail: Add a new target for the Azure Event Hubs

##### Fixes

* [8988](https://github.com/grafana/loki/pull/8988) **darxriggs**: Promtail: Prevent logging errors on normal shutdown.

## 2.8.0 (2023-03-??)

#### Loki

##### Enhancements
Expand Down
8 changes: 6 additions & 2 deletions clients/pkg/promtail/targets/journal/journaltarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,16 @@ func journalTargetWithReader(
for {
err := t.r.Follow(until, io.Discard)
if err != nil {
level.Error(t.logger).Log("msg", "received error during sdjournal follow", "err", err.Error())
if err == sdjournal.ErrExpired {
return
}

if err == sdjournal.ErrExpired || err == syscall.EBADMSG || err == io.EOF {
if err == syscall.EBADMSG || err == io.EOF {
level.Error(t.logger).Log("msg", "unable to follow journal", "err", err.Error())
return
}

level.Error(t.logger).Log("msg", "received unexpected error while following the journal", "err", err.Error())
}

// prevent tight loop
Expand Down

0 comments on commit 07c4014

Please sign in to comment.