Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.8](backport #35426) Remove unnecessary logging #35431

Merged
merged 1 commit into from
May 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions filebeat/input/filestream/internal/input-logfile/harvester.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,19 @@ func startHarvester(

harvesterCtx, cancelHarvester, err := hg.readers.newContext(srcID, canceler)
if err != nil {
// The returned may or not be collected by the caller, thus logging
// it here is important.
ctx.Logger.Errorf("error while adding new reader to the bookkeeper %v", err)
// The only possible returned error is ErrHarvesterAlreadyRunning, which is a normal
// behaviour of the Filestream input, it's not really an error, it's just an situation.
// If the harvester is already running we don't need to start a new one.
// At the moment of writing even the returned error is ignored. So the
// only real effect of this branch is to not start a second harvester.
//
// Currently the only places this error is checked is on task.Group and the
// only thing it does is to log the error. So to avoid unnecessary errors,
// we just return nil.
if errors.Is(err, ErrHarvesterAlreadyRunning) {
return nil
}

return fmt.Errorf("error while adding new reader to the bookkeeper %w", err)
}

Expand Down