From 73dd5ba22a2da9912515716bf37e9b81add42824 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 14 Nov 2018 17:44:18 +0800 Subject: [PATCH] gluster-block: add logrotate support Signed-off-by: Xiubo Li Reviewed-by: Prasanna Kumar Kalever Tested-by: Prasanna Kumar Kalever --- configure.ac | 3 +++ extras/Makefile.am | 12 ++++++++---- extras/gluster-block.logrotate | 18 ++++++++++++++++++ gluster-block.spec.in | 4 ++++ utils/dyn-config.c | 9 +++------ 5 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 extras/gluster-block.logrotate diff --git a/configure.ac b/configure.ac index 6f2a6ae..7d3b833 100644 --- a/configure.ac +++ b/configure.ac @@ -129,6 +129,9 @@ fi GLUSTER_BLOCKD_LIBEXECDIR="$(eval echo ${libexecdir}/gluster-block)" AC_SUBST(GLUSTER_BLOCKD_LIBEXECDIR) +GLUSTER_BLOCKD_LOGROTATEDIR="$(eval echo /etc/logrotate.d)" +AC_SUBST(GLUSTER_BLOCKD_LOGROTATEDIR) + # Checks for typedefs, structures, and compiler characteristics. AC_CHECK_HEADER_STDBOOL AC_TYPE_SIZE_T diff --git a/extras/Makefile.am b/extras/Makefile.am index 07372e1..e853f5f 100644 --- a/extras/Makefile.am +++ b/extras/Makefile.am @@ -7,11 +7,15 @@ CLEANFILES = *~ install-data-local: $(MKDIR_P) $(DESTDIR)$(GLUSTER_BLOCKD_LIBEXECDIR); \ $(INSTALL_DATA) -m 755 $(top_srcdir)/extras/wait-for-bricks.sh \ - $(DESTDIR)$(GLUSTER_BLOCKD_LIBEXECDIR)/wait-for-bricks.sh; \ + $(DESTDIR)$(GLUSTER_BLOCKD_LIBEXECDIR)/wait-for-bricks.sh; \ $(INSTALL_DATA) -m 755 $(top_srcdir)/extras/upgrade_activities.sh \ - $(DESTDIR)$(GLUSTER_BLOCKD_LIBEXECDIR)/upgrade_activities.sh + $(DESTDIR)$(GLUSTER_BLOCKD_LIBEXECDIR)/upgrade_activities.sh; \ + $(MKDIR_P) $(DESTDIR)$(GLUSTER_BLOCKD_LOGROTATEDIR); \ + $(INSTALL_DATA) -m 644 gluster-block.logrotate \ + $(DESTDIR)$(GLUSTER_BLOCKD_LOGROTATEDIR)/gluster-block; uninstall-local: rm -f $(DESTDIR)$(GLUSTER_BLOCKD_LIBEXECDIR)/wait-for-bricks.sh \ - $(DESTDIR)$(GLUSTER_BLOCKD_LIBEXECDIR)/upgrade_activities.sh \ - $(DESTDIR)$(GLUSTER_BLOCKD_WORKDIR)/gb_upgrade.status; + $(DESTDIR)$(GLUSTER_BLOCKD_LIBEXECDIR)/upgrade_activities.sh \ + $(DESTDIR)$(GLUSTER_BLOCKD_WORKDIR)/gb_upgrade.status \ + $(DESTDIR)$(GLUSTER_BLOCKD_LOGROTATEDIR)/gluster-block; diff --git a/extras/gluster-block.logrotate b/extras/gluster-block.logrotate new file mode 100644 index 0000000..2b03a14 --- /dev/null +++ b/extras/gluster-block.logrotate @@ -0,0 +1,18 @@ +# Rotate all the gluster-block logs +/var/log/gluster-block/*.log { + sharedscripts + weekly + maxsize 10M + minsize 100k + +# 6 months of logs are good enough + rotate 26 + + missingok + compress + delaycompress + notifempty + postrotate + killall -q -s 1 gluster-blockd > /dev/null 2>&1 || true + endscript +} diff --git a/gluster-block.spec.in b/gluster-block.spec.in index 2b1ddc8..18c282c 100644 --- a/gluster-block.spec.in +++ b/gluster-block.spec.in @@ -82,6 +82,7 @@ rm -rf ${RPM_BUILD_ROOT} %attr(0755,-,-) %{_initddir}/gluster-blockd %endif %config(noreplace) %{_sysconfdir}/sysconfig/gluster-blockd +%config(noreplace) %{_sysconfdir}/logrotate.d/gluster-block %dir %attr(0755,-,-) %{_libexecdir}/gluster-block %attr(0755,-,-) %{_libexecdir}/gluster-block/wait-for-bricks.sh %attr(0755,-,-) %{_libexecdir}/gluster-block/upgrade_activities.sh @@ -89,6 +90,9 @@ rm -rf ${RPM_BUILD_ROOT} %attr(0644,-,-) %{_sharedstatedir}/gluster-block/gluster-block-caps.info %changelog +* Sun Apr 3 2019 Xiubo Li +- Add logrotate support + * Sun Oct 14 2018 Prasanna Kumar Kalever - add install details for upgrade_activities.sh diff --git a/utils/dyn-config.c b/utils/dyn-config.c index b645f4f..fc4cb08 100644 --- a/utils/dyn-config.c +++ b/utils/dyn-config.c @@ -475,7 +475,6 @@ glusterBlockDynConfigStart(void *arg) gbConfig *cfg = arg; int monitor, wd, len; char buf[GB_BUF_LEN]; - char cfgDir[PATH_MAX]; struct inotify_event *event; struct timespec mtim = {0, }; /* Time of last modification. */ struct stat statbuf; @@ -489,8 +488,6 @@ glusterBlockDynConfigStart(void *arg) return NULL; } - snprintf(cfgDir, PATH_MAX, GB_DEF_CONFIGDIR); - /* Editors (vim, nano ..) follow different approaches to save conf file. * The two commonly followed techniques are to overwrite the existing * file, or to write to a new file (.swp, .tmp ..) and move it to actual @@ -500,15 +497,15 @@ glusterBlockDynConfigStart(void *arg) * To handle both the file save approaches mentioned above, it is better * we watch the directory and filter for MODIFY events. */ - wd = inotify_add_watch(monitor, cfgDir, IN_MODIFY); + wd = inotify_add_watch(monitor, GB_DEF_CONFIGDIR, IN_MODIFY); if (wd == -1) { LOG("mgmt", GB_LOG_ERROR, - "Failed to add \"%s\" to inotify (%d)\n", cfgDir, monitor); + "Failed to add \"%s\" to inotify (%d)\n", GB_DEF_CONFIGDIR, monitor); return NULL; } LOG("mgmt", GB_LOG_INFO, - "Inotify is watching \"%s\", wd: %d, mask: IN_MODIFY\n", cfgDir, wd); + "Inotify is watching \"%s\", wd: %d, mask: IN_MODIFY\n", GB_DEF_CONFIGDIR, wd); while (1) { len = read(monitor, buf, GB_BUF_LEN);