chef-client
chef-client copied to clipboard
Add a graceful-restart option in service restart script
Cookbook version
8.1.7
Chef-client version
12.14.89
Platform Details
Redhat and CentOS 6 & 7
Scenario:
After log rotation with logrotated, the postrotate option in this cookbook does a reload
of the service daemon. However, we've found that this leaves stale filehandles on the system, and it appears as if the daemon is no longer working, as there is no longer logging happening during chef runs.
Steps to Reproduce:
Setup logrotated to rotate the chef-client's log file every night (see sample).
$ cat /etc/logrotate.d/chef-client
"/var/log/chef/client.log" {
daily
rotate 14
compress
missingok
notifempty
postrotate
/etc/init.d/chef-client reload >/dev/null || :
endscript
}
Expected Result:
chef-client daemon rotates its log file and service resumes normally.
Actual Result:
We're seeing stale filehandles. It also appears as if the chef client stop checking in.
I've identified a solution that works, but this requires us to drop our own chef-client restart script. I think this should go into the template used in this cookbook instead.
Add to /etc/init.d/chef-client the following, which sends the -TERM
option to the daemon restart:
graceful_restart() {
echo -n $"Gracefully restarting $prog: "
killproc -p $pidfile $exec -TERM
retval=$?
echo
return $retval
}
Then change the postrotate option to /etc/init.d/chef-client graceful-restart >/dev/null || :
I’m adding the Type: Jump In GitHub label to this issue. This is a great issue for someone to get their feet wet with and we’d love a PR to resolves the issue.