Skip to content

Commit

Permalink
gluster-block: add logrotate support
Browse files Browse the repository at this point in the history
Signed-off-by: Xiubo Li <[email protected]>
Reviewed-by: Prasanna Kumar Kalever <[email protected]>
Tested-by: Prasanna Kumar Kalever <[email protected]>
  • Loading branch information
lxbsz authored and Prasanna Kumar Kalever committed Apr 3, 2019
1 parent ac702ac commit 73dd5ba
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions extras/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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;
18 changes: 18 additions & 0 deletions extras/gluster-block.logrotate
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 4 additions & 0 deletions gluster-block.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,17 @@ 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
%dir %attr(0755,-,-) %{_sharedstatedir}/gluster-block
%attr(0644,-,-) %{_sharedstatedir}/gluster-block/gluster-block-caps.info

%changelog
* Sun Apr 3 2019 Xiubo Li <[email protected]>
- Add logrotate support

* Sun Oct 14 2018 Prasanna Kumar Kalever <[email protected]>
- add install details for upgrade_activities.sh

Expand Down
9 changes: 3 additions & 6 deletions utils/dyn-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit 73dd5ba

Please sign in to comment.