-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix handling of truncated files for Filestream input #38416
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
f1a1d69
to
30814ec
Compare
This pull request is now in conflicts. Could you fix it? 🙏
|
43e82b4
to
0ef8349
Compare
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
7c2a1f0
to
0978bba
Compare
💔 Build Failed
Failed CI StepsHistory
cc @belimawr |
💚 Build Succeeded
History
cc @belimawr |
💚 Build Succeeded
History
cc @belimawr |
💚 Build Succeeded
History
cc @belimawr |
💔 Build Failed
Failed CI StepsHistory
cc @belimawr |
💚 Build Succeeded
History
cc @belimawr |
💚 Build Succeeded
History
cc @belimawr |
💚 Build Succeeded
History
cc @belimawr |
💚 Build Succeeded
History
cc @belimawr |
@@ -0,0 +1,225 @@ | |||
// Licensed to Elasticsearch B.V. under one or more contributor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@belimawr Did you make sure all these tests are failing without the fix applied?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wrote them before start working on the fix. But it has been a while since I ran them, so I'll re-run them without the fix before merging just to be on the safe side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--- FAIL: TestFilestreamLiveFileTruncation (8.91s)
filestream_truncation_test.go:110: expecting offset 500 got 10500 instead
--- FAIL: TestFilestreamOfflineFileTruncation (4.28s)
filestream_truncation_test.go:150: expecting offset 250 got 750 instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given yes
is the answer to my question above, everything looks good.
0978bba
to
b77063d
Compare
I rebased onto |
b77063d
to
b6f96d8
Compare
c5774dc
to
41d1e18
Compare
/test |
41d1e18
to
1744c7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a small question, otherwise LGTM from the ingest-eng-prod PoV
9794cd3
to
c893107
Compare
This pull request is now in conflicts. Could you fix it? 🙏
|
Test that fails if Filestream does not correctly update the registry when the file is truncated while Filebeat is not running.
Refactor tests and set `logging.files.rotateonstartup=false` when starting the Beat so we only generate a single log file even when the Beat is started multiple times.
This commit fixes file truncation handling for the case when the file is truncated when Filebeat is not running.
The generated log file did not have its size predictable because the RFC3339 may not include the timezone offset. This is fixed by looking at the time string size and adding padding if necessary.
f18a0ad
to
bbc3532
Compare
Proposed commit message
This commit fixes the handling of file truncation in the Filestream input. In some file truncation cases Filebeat would detect the truncation but it would not set the offset to zero, leading to the registry offset always increasing and causing the file to be re-ingested every time Filebeat was restarted.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.## Author's ChecklistHow to test this PR locally
All scripts and configuration files are at the end of this section.
1. File is truncated while Filebeat is running
loop-add-data.sh
truncate -s 50
/tmp/logs/log.log`. This will truncate the file but leave a whole line to be ingested later on.50
once it finishes reading the file2. File is truncated while Filebeat is stopped
gen-file.sh
truncate -s 50
/tmp/logs/log.log`. This will truncate the file but leave a whole line to be ingested later on.50
once it finishes reading the fileConfiguration file and scripts
loop-add-data.sh
gen-file.sh
filebeat.yml
Related issues
## Use cases## Screenshots## Logs