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

Add a graceful-restart option in service restart script #508

Open
haidangwa opened this issue Jul 20, 2017 · 1 comment
Open

Add a graceful-restart option in service restart script #508

haidangwa opened this issue Jul 20, 2017 · 1 comment
Labels
Status: Good First Issue An issue ready for a new contributor.

Comments

@haidangwa
Copy link

haidangwa commented Jul 20, 2017

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 || :

@haidangwa haidangwa changed the title graceful-restart option in service restart script Add a graceful-restart option in service restart script Jul 20, 2017
@tas50
Copy link
Contributor

tas50 commented Sep 9, 2017

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.

@tas50 tas50 added Status: Good First Issue An issue ready for a new contributor. and removed Help: Good First Issue labels Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Good First Issue An issue ready for a new contributor.
Development

No branches or pull requests

2 participants