[OpenAFS-devel] rethinking log rotation

Michael Meffie mmeffie@sinenomine.net
Thu, 28 Apr 2016 09:55:01 -0400


> > > You could actually make bosserver forward the 'reopen the logs' signal to
> > > the various processes.  logrotate certainly supports this for httpd -- it
> > > has at least two log files that need rotated on the same signal.
> > 
> > This. Logrotate already has the tools to make this happen in a safe manner
> > (no data loss). But it requires a command-line interface so logrotate can
> > tell the application to simply close and re-open the log file. It works for
> > [r]syslogd, httpd, etc, etc. A bos command that tells the running *server
> > utils to close/reopen the logs is all that's needed.
> > 
> > I am *strongly* opposed to building our own log rotation stuff inside
> > bos/etc; ultimately you wind up replicating what logrotate already does for
> > you. And usually in a less flexible manner. 
> 
> Thank you. To be clear; No one has proposed putting log rotation logic in the
> servers, only to add the signal handling to close re-open the log file
> handles (as is done for the mrafs-style logs), and to remove the renaming of
> <log> to <log>.old on process restarts.
> 
> This last part (the removal of renaming to <log>.old) is a change that
> probably makes sense since bosserver weekly restarts have not be the default
> for quite a long while.

Hello,

After quite a lot of yak shaving, the externalize log rotation patches have
been merged on the master branch.  Thanks in particular to Ben and Chas
for their reviews, help, and suggestions.

Much of this work was cleaning up old bugs to make way for making even simple
changes to the server logging.  A number of obsolete things were retired and
all the servers (with the exception of the bosserver) now use the same logging
routines.

Some highlights:

* Ben's work in retiring Linux 2.4 support (and thus the support for the
  ancient and obsolete LinuxThreads) made way for retiring the old and
  complicated soft signal handling and freed up signal SIGUSR1.

* All of the servers have been converted to the simplified softsig
  routines for pthreads (written some time ago by Simon).

* Ben converted the backup servers to use the same logging routines
  as the other servers. The salvager and DAFS salvage server logging
  routines were also converted to use the common server logging routines.

* Many small fixes and code cleanups were done in the server logging routines,
  including about a half a dozen fixes to "mrafs-style" logging, thread safety
  fixes, and others.

* The server logging global variables to initialize server logging have been
  replaced with arguments to OpenLog().

An option has been added to all the server processes to fallback to the old
style, where log messages are truncated on processes startup (e.g. FileLog.old
is deleted and FileLog is renamed to FileLog.old).  By default, the servers now
just open the existing log files and append messages instead of clobbering
log entries.  

Signal SIGUSR1 can be sent to processes to close and re-open log files after
they are renamed by log rotate.  We do not have a new bos command, however the
bosserver -pidfiles option (already in 1.6.x) gives the pids of the running
server processes.

Thanks,
Mike

-- 
Michael Meffie <mmeffie@sinenomine.net>