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

Remove erroneous status reporting #42435

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Fix Netflow Template Sharing configuration handling. {pull}42080[42080]
- Updated websocket retry error code list to allow more scenarios to be retried which could have been missed previously. {pull}42218[42218]
- In the `streaming` input, prevent panics on shutdown with a null check and apply a consistent namespace to contextual data in debug logs. {pull}42315[42315]
- Remove erroneous status reporting to Elastic-Agent from the Filestream input {pull}42435[42435]
- Fix truncation of bodies in request tracing by limiting bodies to 10% of the maximum file size. {pull}42327[42327]

*Heartbeat*
Expand Down
9 changes: 3 additions & 6 deletions filebeat/input/filestream/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/elastic/beats/v7/libbeat/common/file"
"github.com/elastic/beats/v7/libbeat/common/match"
"github.com/elastic/beats/v7/libbeat/feature"
"github.com/elastic/beats/v7/libbeat/management/status"
"github.com/elastic/beats/v7/libbeat/reader"
"github.com/elastic/beats/v7/libbeat/reader/debug"
"github.com/elastic/beats/v7/libbeat/reader/parser"
Expand Down Expand Up @@ -166,11 +165,9 @@ func (inp *filestream) Run(
})
defer streamCancel()

if err := inp.readFromSource(ctx, log, r, fs.newPath, state, publisher, metrics); err != nil {
ctx.UpdateStatus(status.Degraded, fmt.Sprintf("error while reading from source: %v", err))
return err
}
return nil
// The caller of Run already reports the error and filters out errors that
// must not be reported, like 'context cancelled'.
return inp.readFromSource(ctx, log, r, fs.newPath, state, publisher, metrics)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the case today, but what if someone changes the logic inside readFromSource to return another kind of error? This promise would then become invalid and could cause silent failures. If you mean that Run up the chain has logic to report the errors then it is fine, then disregard my comment.

Copy link
Contributor Author

@belimawr belimawr Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean that Run up the chain has logic to report the errors then it is fine, then disregard my comment.

Yes, that's what I meant.

However if it wasn't clear when you read the comment, this means it can be improved ;)

Do you have any suggestions on how I can make it clear? So future changes won't fall into the trap of trying to report it?

Should I go with something simpler like:

The caller of Run already reports the error and filter out errors that must not be reported, like 'context cancelled'.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I like your suggestion, it is both clearer and shorter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UpdateStatus could probably just unconditionally filter out context.Cancelled and the Beats context equivalent.

context.Cancelled is not an actionable user error, it's something that would only ever arise because of a bug. We could log it but not change the agent state perhaps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree if the error is context.Cancelled it's coming from a bug, however it could also break/stop something essential (like an input) and if that affects the data ingestion or the overall behaviour of the Elastic-Agent it should be reported to the user so they know something is wrong.

Ideally there would be no bug, but if I have to choose between a silent bug and a verbose/noisy one, I'll take the noisy one, it's gonna be much easier to catch and less likely to make it into a final release.

}

func initState(log *logp.Logger, c loginp.Cursor, s fileSource) state {
Expand Down
Loading