Silently ignore empty files in filestream#49196
Conversation
Empty files are excluded from processing in filestream as early as possible.
🤖 GitHub commentsJust comment with:
|
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughDetects and silently exclude zero-byte files from filestream processing. Adds a new package error 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates the filestream scanner/watcher logic to treat 0-byte files as a special case: they are excluded from ingestion decisions early and do not contribute to fingerprint “too small” warnings/log noise, aligning behavior with the empty-file expectations described in #48891.
Changes:
- Add an
errFileEmptysentinel and exclude empty regular files (and symlinks to empty targets) during ingest-target resolution. - Suppress per-scan debug logging for the empty-file case in
fileScanner.GetFiles(). - Update/add tests to cover silent exclusion of empty files and symlinks; add changelog fragment.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| filebeat/input/filestream/fswatch.go | Introduces errFileEmpty and skips empty files early; avoids debug logging for empty-file ingest-target failures. |
| filebeat/input/filestream/fswatch_test.go | Updates watcher test expectation (no debug for empty files) and adds scanner/getIngestTarget tests for empty file exclusion. |
| filebeat/input/filestream/fswatch_integration_test.go | Minor test cleanup (unused param) and relocates mustFingerprintIdentifier helper. |
| changelog/fragments/1772466645-ignore-empty-files.yaml | Adds changelog entry for the enhancement. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
|
So, that's because now truncating a file to zero is handled the same way as delete/re-create. Which I cannot see any problem with (am I missing something?). Truncating to anything but zero is still handled with the special behavior as before. I adjusted the existing tests to reflect that. |
I don't think so, the truncated file would get a new fingerprint anyway. |
|
@Mergifyio backport 8.19 9.2 9.3 |
✅ Backports have been createdDetails
Cherry-pick of 404fb99 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally
Cherry-pick of 404fb99 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally
Cherry-pick of 404fb99 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
Empty files are excluded from processing in filestream as early as possible. Now the truncate to zero behavior equals to delete/recreate. (cherry picked from commit 404fb99) # Conflicts: # filebeat/input/filestream/fswatch_integration_test.go # filebeat/input/filestream/fswatch_test.go
Empty files are excluded from processing in filestream as early as possible. Now the truncate to zero behavior equals to delete/recreate. (cherry picked from commit 404fb99) # Conflicts: # filebeat/input/filestream/fswatch_test.go
Empty files are excluded from processing in filestream as early as possible. Now the truncate to zero behavior equals to delete/recreate. (cherry picked from commit 404fb99) # Conflicts: # filebeat/input/filestream/fswatch_test.go
) * Silently ignore empty files in filestream (#49196) Empty files are excluded from processing in filestream as early as possible. Now the truncate to zero behavior equals to delete/recreate. (cherry picked from commit 404fb99) # Conflicts: # filebeat/input/filestream/fswatch_test.go * Resolve conflicts --------- Co-authored-by: Denis <denis.rechkunov@elastic.co>
…9230) * Silently ignore empty files in filestream (#49196) Empty files are excluded from processing in filestream as early as possible. Now the truncate to zero behavior equals to delete/recreate. (cherry picked from commit 404fb99) # Conflicts: # filebeat/input/filestream/fswatch_integration_test.go # filebeat/input/filestream/fswatch_test.go * Resolve conflicts --------- Co-authored-by: Denis <denis.rechkunov@elastic.co>
) * Silently ignore empty files in filestream (#49196) Empty files are excluded from processing in filestream as early as possible. Now the truncate to zero behavior equals to delete/recreate. (cherry picked from commit 404fb99) # Conflicts: # filebeat/input/filestream/fswatch_test.go * Resolve conflicts --------- Co-authored-by: Denis <denis.rechkunov@elastic.co>
Proposed commit message
Checklist
- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration filesstresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.Benchmarks
Environment: darwin/arm64, Apple M4 Pro, 12 threads
So, no impact.
Related issues