-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Open log files with O_APPEND so log rotation can work properly #9468
Conversation
If logging to a file is used, and external log rotation is setup e.g. with logrotate, teleport would end up creating a sparse file because `write`s to the log file opened without O_APPEND would resume writing to the last write location even though the log file might have been truncated by logrotate. Fix this by opening the log file with O_APPEND. This will cause all subsequent `write`s to write to the end of the file, thus starting from the beginning of the empty file after a truncate has been performed by logrotate.
/gcbrun |
Hey @vrivanov-rb, thanks for the change, we'd like to merge this. Can you rebase it or do you want us to take it over? |
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.
|
If logging to a file is used, and external log rotation is setup e.g. with logrotate, teleport would end up creating a sparse file because
write
s to the log file opened without O_APPEND would resume writing to the last write location even though the log file might have been truncated by logrotate.Fix this by opening the log file with O_APPEND. This will cause all subsequent
write
s to write to the end of the file, thus starting from the beginning of the empty file after a truncate has been performed by logrotate.