-
Notifications
You must be signed in to change notification settings - Fork 29
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
Migrate path of logrotate.d configration #505
Conversation
kenhys
commented
Jun 26, 2023
•
edited
Loading
edited
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.
Thanks for this fix!
Indeed, we have to update the file /etc/logrotate.d
for the new package.
Do we also need to update the USER and GROUP name to _fluentd
for the deb package?
For migration, I have the following concerns.
- Shouldn't the old rotate config
/etc/logrotate.d/td-agent
work as is after the update?- Because we have the alias to access the old path:
/var/log/td-agent/td-agent.log
- Because we have the alias to access the old path:
- So, I think we should not make the new rotate config, and continue to use the old one as is.
- Possibly, we need to migrate USER and GROUP settings, but the other migration process seems to be not needed.
I confirmed the alias /var/log/td-agent
work as expected for rotation:
/etc/logrotate.d/td-agent
/var/log/td-agent/td-agent.log {
#daily
size 1
rotate 30
compress
delaycompress
notifempty
create 640 _fluentd _fluentd
sharedscripts
postrotate
pid=/var/run/fluent/fluentd.pid
if [ -s "$pid" ]
then
kill -USR1 "$(cat $pid)"
fi
endscript
}
log files:
/var/log/fluent/td-agent.log
Run rotate: $ sudo logrotate -s state /etc/logrotate.d/td-agent
rotated log files:
/var/log/fluent/td-agent.log
/var/log/fluent/td-agent.log.1
It may be a simple solution to do: 1st approach PR:
2nd approach PR:
3rd approach:
|
Try 3rd approach whether it will work as expected. |
fc60961
to
450f959
Compare
3rd approach is not bad, but tend to be broken on some deb platform. 🤔 |
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.
I confirmed this basically works as expected on Ubuntu Focal.
There was one problem about SIGUSR1
signal on rotation.
I commented on it below.
Before: /etc/logrotate.d/td-agent If td-agent user/group exists, renaming td-agent to fluent user/group then rewrite logrotate.d configuration. But, it may fail if user modify that configuration unexpected way. After: /etc/logrotate.d/fluentd If td-agent user/group exists (e.g upgrading from v4), create _fluent user/group as same uid/gid. If not, just create new _fluent user/group (no td-agent user/group). This approach make easy to migrate /etc/logrotate.d/td-agent configuration file without modification. Additionally, rewrite /etc/logrotate.d/td-agent path of pid because the pid file will be dynamically created/destroyed. Signed-off-by: Kentaro Hayashi <[email protected]>
Signed-off-by: Kentaro Hayashi <[email protected]>
Signed-off-by: Kentaro Hayashi <[email protected]>
Added fix for logrotate.d/td-agent |
I will confirm it! |
Is it intentional that 43e9343 was added into this PR? |
It should be seperate PR. |
Signed-off-by: Kentaro Hayashi <[email protected]>
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.
I confirmed that the SIGUSR1 worked correctly on rotation!
LGTM.
Thanks! |