- Notifications
You must be signed in to change notification settings - Fork 197
fix(diagnostics): handle log rotation races #8215
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(diagnostics): handle log rotation races #8215
Conversation
This pull request does not have a backport label. Could you fix it @andrewkroh? 🙏
|
Handle a race condition that can occur in Agent diagnostics if log rotation happens while logs are being zipped. There is a time window between when `filepath.WalkDir` reads the directory contents and when log files are opened for reading. During this time window, log rotation can happen, resulting in files that no longer exist and cannot be added to the diagnostic archive. To handle this, `fs.ErrNotExist` errors are ignored when attempting to add log files.
d48294a
to f1188bc
Compare Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
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.
aside a nit about non-relevant to this PR linter issue this LGTM, thanks for handling it @andrewkroh 🙂 Also since this is a bug-fix I added the backport to all active branches
|
💚 Build Succeeded
History
cc @andrewkroh |
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.
LGTM 🙂
@Mergifyio backport 8.17 8.18 8.19 9.0 |
✅ Backports have been created
|
Handle a race condition that can occur in Agent diagnostics if log rotation happens while logs are being zipped. There is a time window between when `filepath.WalkDir` reads the directory contents and when log files are opened for reading. During this time window, log rotation can happen, resulting in files that no longer exist and cannot be added to the diagnostic archive. To handle this, `fs.ErrNotExist` errors are ignored when attempting to add log files. Also, address and unrelated linter warning by using fmt.Fprintf. (cherry picked from commit 751acc1)
Handle a race condition that can occur in Agent diagnostics if log rotation happens while logs are being zipped. There is a time window between when `filepath.WalkDir` reads the directory contents and when log files are opened for reading. During this time window, log rotation can happen, resulting in files that no longer exist and cannot be added to the diagnostic archive. To handle this, `fs.ErrNotExist` errors are ignored when attempting to add log files. Also, address and unrelated linter warning by using fmt.Fprintf. (cherry picked from commit 751acc1)
Handle a race condition that can occur in Agent diagnostics if log rotation happens while logs are being zipped. There is a time window between when `filepath.WalkDir` reads the directory contents and when log files are opened for reading. During this time window, log rotation can happen, resulting in files that no longer exist and cannot be added to the diagnostic archive. To handle this, `fs.ErrNotExist` errors are ignored when attempting to add log files. Also, address and unrelated linter warning by using fmt.Fprintf. (cherry picked from commit 751acc1)
Handle a race condition that can occur in Agent diagnostics if log rotation happens while logs are being zipped. There is a time window between when `filepath.WalkDir` reads the directory contents and when log files are opened for reading. During this time window, log rotation can happen, resulting in files that no longer exist and cannot be added to the diagnostic archive. To handle this, `fs.ErrNotExist` errors are ignored when attempting to add log files. Also, address and unrelated linter warning by using fmt.Fprintf. (cherry picked from commit 751acc1)
Handle a race condition that can occur in Agent diagnostics if log rotation happens while logs are being zipped. There is a time window between when `filepath.WalkDir` reads the directory contents and when log files are opened for reading. During this time window, log rotation can happen, resulting in files that no longer exist and cannot be added to the diagnostic archive. To handle this, `fs.ErrNotExist` errors are ignored when attempting to add log files. Also, address and unrelated linter warning by using fmt.Fprintf. (cherry picked from commit 751acc1) Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co>
Handle a race condition that can occur in Agent diagnostics if log rotation happens while logs are being zipped. There is a time window between when `filepath.WalkDir` reads the directory contents and when log files are opened for reading. During this time window, log rotation can happen, resulting in files that no longer exist and cannot be added to the diagnostic archive. To handle this, `fs.ErrNotExist` errors are ignored when attempting to add log files. Also, address and unrelated linter warning by using fmt.Fprintf. (cherry picked from commit 751acc1) Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co>
Handle a race condition that can occur in Agent diagnostics if log rotation happens while logs are being zipped. There is a time window between when `filepath.WalkDir` reads the directory contents and when log files are opened for reading. During this time window, log rotation can happen, resulting in files that no longer exist and cannot be added to the diagnostic archive. To handle this, `fs.ErrNotExist` errors are ignored when attempting to add log files. Also, address and unrelated linter warning by using fmt.Fprintf. (cherry picked from commit 751acc1) Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co>
Handle a race condition that can occur in Agent diagnostics if log rotation happens while logs are being zipped. There is a time window between when `filepath.WalkDir` reads the directory contents and when log files are opened for reading. During this time window, log rotation can happen, resulting in files that no longer exist and cannot be added to the diagnostic archive. To handle this, `fs.ErrNotExist` errors are ignored when attempting to add log files. Also, address and unrelated linter warning by using fmt.Fprintf. (cherry picked from commit 751acc1) Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co>
* main: chore: Update to elastic/beats@c51fee3a852e (elastic#8246) chore: Update to elastic/beats@82f47f73acbd (elastic#8239) Fix minor typo in beats update job (elastic#8233) fix(diagnostics): handle log rotation races (elastic#8215) Fix some minor issues with the beats version update job (elastic#8224) [main][Automation] Update elastic/beats to 9382cc20546b (elastic#8222) Automatically update beats module versions (elastic#8174) chore: deps(ironbank): Bump ubi version to 9.6 (elastic#8218)
What does this PR do?
Handle a race condition that can occur in Agent diagnostics if log rotation happens while logs are being zipped. There is a time window between when
filepath.WalkDir
reads the directory contents and when log files are opened for reading. During this time window, log rotation can happen, resulting in files that no longer exist and cannot be added to the diagnostic archive.To handle this,
fs.ErrNotExist
errors are ignored when attempting to add log files.Why is it important?
This race can happen at any time, so any user could be affected. The problem is worse if debug logging is enabled and logs are being rotated quickly.
Checklist
./changelog/fragments
using the changelog toolScreenshots
This is the user reported error:
via OCR, it says:
Disruptive User Impact
How to test this PR locally
Related issues
Questions to ask yourself