From 5845b2ccacf65532b920406f5acae539dbfa8e00 Mon Sep 17 00:00:00 2001 From: Piotr <17101802+thampiotr@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:52:06 +0000 Subject: [PATCH] Update journaltarget from loki/promtail (#1995) --- CHANGELOG.md | 2 ++ .../source/journal/internal/target/journaltarget.go | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff26cd53ea..3f05479234 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,8 @@ Main (unreleased) - Fixed a bug in `import.git` which caused a `"non-fast-forward update"` error message. (@ptodev) +- Do not log error on clean shutdown of `loki.source.journal`. (@thampiotr) + ### Other changes - Small fix in UI stylesheet to fit more content into visible table area. (@defanator) diff --git a/internal/component/loki/source/journal/internal/target/journaltarget.go b/internal/component/loki/source/journal/internal/target/journaltarget.go index 7cd6904ff8..cffc3c9d06 100644 --- a/internal/component/loki/source/journal/internal/target/journaltarget.go +++ b/internal/component/loki/source/journal/internal/target/journaltarget.go @@ -2,8 +2,8 @@ package target -// This code is copied from Promtail (https://github.com/grafana/loki/commit/954df433e98f659d006ced52b23151cb5eb2fdfa) with minor edits. The target package is used to -// configure and run the targets that can read journal entries and forward them +// This code is copied from Promtail (https://github.com/grafana/loki/blob/baaaa83c78c03c6b9257afddc0854daec928a755/clients/pkg/promtail/targets/journal/journaltarget.go#L4) +// with minor edits. The target package is used to configure and run the targets that can read journal entries and forward them // to other loki components. import ( @@ -214,7 +214,11 @@ func journalTargetWithReader( for { err := t.r.Follow(until, io.Discard) if err != nil { - if err == sdjournal.ErrExpired || err == syscall.EBADMSG || err == io.EOF || strings.HasPrefix(err.Error(), "failed to iterate journal:") { + if err == sdjournal.ErrExpired { + return + } + + if err == syscall.EBADMSG || err == io.EOF || strings.HasPrefix(err.Error(), "failed to iterate journal:") { level.Error(t.logger).Log("msg", "unable to follow journal", "err", err.Error()) return }