From: Loic Dachary Date: Thu, 6 Mar 2014 23:07:26 +0000 (+0100) Subject: logrotate: copy/paste daemon list from *-all-starter.conf X-Git-Tag: v0.78~72^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1393%2Fhead;p=ceph.git logrotate: copy/paste daemon list from *-all-starter.conf Each upstart/*-all-starter.conf use the same script to find the list of daemons and their ids. Copy it over to the corresponding logrotate.conf script instead of using a less reliable script based on initctl list output. If logrotate fails to run initctl reload on a daemon, it will keep writing to the rotated log file, even after it is deleted and until it fills the disk. By using the exact same shell snippet as the upstart scripts used to start the daemon, all of them will be sent the HUP signal and reopen the log file that was just rotated. http://tracker.ceph.com/issues/7072 fixes #7072 Signed-off-by: Loic Dachary --- diff --git a/src/logrotate.conf b/src/logrotate.conf index e49285a9f508..9181b56f063c 100644 --- a/src/logrotate.conf +++ b/src/logrotate.conf @@ -11,13 +11,17 @@ fi # Possibly reload twice, but depending on ceph.conf the reload above may be a no-op if which initctl > /dev/null 2>&1 && [ -x `which initctl` ]; then - # upstart reload isn't very helpful here: - # https://bugs.launchpad.net/upstart/+bug/1012938 - initctl list \ - | sed -n 's/^\(ceph-\(mon\|osd\|mds\)\+\)[ \t]\+(\([^ \/]\+\)\/\([^ \/]\+\))[ \t]\+start\/.*$/\1 cluster=\3 id=\4/p' \ - | while read l; do - initctl reload -- $l 2>/dev/null || : - done + for daemon in osd mon mds ; do + find -L /var/lib/ceph/$daemon/ -mindepth 1 -maxdepth 1 -regextype posix-egrep -regex '.*/[A-Za-z0-9]+-[A-Za-z0-9._-]+' -printf '%P\n' \ + | while read f; do + if [ -e "/var/lib/ceph/$daemon/$f/done" ] && [ -e "/var/lib/ceph/$daemon/$f/upstart" ] && [ ! -e "/var/lib/ceph/$daemon/$f/sysvinit" ]; then + cluster="${f%%-*}" + id="${f#*-}" + + initctl reload ceph-$daemon cluster="$cluster" id="$id" 2>/dev/null || : + fi + done + done fi endscript missingok diff --git a/src/rgw/logrotate.conf b/src/rgw/logrotate.conf index 7fb3391bbec2..7c6f74e18882 100644 --- a/src/rgw/logrotate.conf +++ b/src/rgw/logrotate.conf @@ -11,13 +11,14 @@ fi # Possibly reload twice, but depending on ceph.conf the reload above may be a no-op if which initctl > /dev/null 2>&1 && [ -x `which initctl` ]; then - # upstart reload isn't very helpful here: - # https://bugs.launchpad.net/upstart/+bug/1012938 - initctl list \ - | sed -n 's/^\(radosgw\+\)[ \t]\+(\([^ \/]\+\)\/\([^ \/]\+\))[ \t]\+start\/.*$/\1 cluster=\2 id=\3/p' \ - | while read l; do - initctl reload -- $l 2>/dev/null || : - done + find -L /var/lib/ceph/radosgw/ -mindepth 1 -maxdepth 1 -regextype posix-egrep -regex '.*/[A-Za-z0-9]+-[A-Za-z0-9._-]+' -printf '%P\n' \ + | while read f; do + if [ -e "/var/lib/ceph/radosgw/$f/done" ]; then + cluster="${f%%-*}" + id="${f#*-}" + initctl reload radosgw cluster="$cluster" id="$id" 2>/dev/null || : + fi + done fi endscript missingok