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.
  • Loading branch information
darxriggs authored Apr 3, 2023
1 parent e2c4454 commit 46af2cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
#### Promtail

##### Enhancements

* [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
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 46af2cd

Please sign in to comment.