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

[v16] Re-open the log file by filesystem notify #44426

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

vapopov
Copy link
Contributor

@vapopov vapopov commented Jul 18, 2024

Backport #43359 to branch/v16

changelog: Re-open log file by filesystem notify rename/remove (useful for logrotate).

* Re-open the log file on OS Signal trigger

This PR implements an handler for the CONT signal.
The handler will close and re-open the log file.
If the log destination is not a file, this is a no-op.

Useful for logrotate postrotate hook.

* signal replaced with the fsnotify

* code review changes:
- refactored to launch watcher with process context
- make file shared writer as singleton
- add test for logrotate case

* add locking for write, reopen

* - configuration for log section update
- test simplification

* code review changes:
- add closing for file shared writer
- make runWatcherFunc not exported

* linter fixes

* change default file mode for log file
simplify setting global watcher

* terminate watcher after override global one
added test for validating global override

* make log file name static for shared writer

* replace logic to use finalizer instead

* fix possible locking write while reopen is triggered

* wrap internal error, fix incorrect unlock

* drop configuration flag, make watcher always enabled

* tune context passing

---------

Co-authored-by: Vadym Popov <vadym.popov@goteleport.com>
@vapopov vapopov added backport no-changelog Indicates that a PR does not require a changelog entry labels Jul 18, 2024
@r0mant
Copy link
Collaborator

r0mant commented Jul 19, 2024

@vapopov Let's hold this backport until 16.2.

@marcoandredinis marcoandredinis removed their request for review July 31, 2024 10:31
@r0mant r0mant added the release-16.2 To be released in v16.2 label Aug 14, 2024
@vapopov vapopov removed the no-changelog Indicates that a PR does not require a changelog entry label Aug 15, 2024
@vapopov vapopov added this pull request to the merge queue Aug 26, 2024
Merged via the queue into branch/v16 with commit 67a7ef7 Aug 26, 2024
39 of 40 checks passed
@vapopov vapopov deleted the vapopov/logrotate-v16 branch August 26, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release-16.2 To be released in v16.2 size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants