[PATCH] Move systemd journal to disk once we have usable disks (#882132)

Vratislav Podzimek vpodzime at redhat.com
Wed Mar 13 09:26:30 UTC 2013


On Tue, 2013-03-12 at 20:50 -0400, Will Woods wrote:
> Saving the journal is a good idea - it has some log info that aren't in
> our existing logs (dracut output, for example).
> 
> We could just make a copy of it at the end of the install, but we can
> also make journald move its logs to disk by creating /var/log/journal
> and sending it SIGUSR1.
> 
> Doing it this way rather than copying it at the end saves some RAM and
> gives us on-disk logs that will be there even if you yank the power cord
> before we get to kickstart %post.
> 
> So as soon as we're sure we've got somewhere persistent we can write to,
> we should move the journal.
> 
> At the moment where preInstall happens we have the target disk mounted
> but there's nothing on it yet. This seems it's probably the earliest
> point where we can safely start writing to disk, so go ahead and do
> that.
> 
> Oh - and make sure 99-copy-logs.ks doesn't chmod the journal dir 0600.
> (and make it use $ANA_INSTALL_PATH consistently, while we're at it)
> ---
>  data/post-scripts/99-copy-logs.ks | 21 +++++++++++----------
>  pyanaconda/iutil.py               | 29 +++++++++++++++++++++++++++++
>  pyanaconda/packaging/__init__.py  |  1 +
>  3 files changed, 41 insertions(+), 10 deletions(-)
> 
> diff --git a/data/post-scripts/99-copy-logs.ks b/data/post-scripts/99-copy-logs.ks
> index 1a60756..73e3c9c 100644
> --- a/data/post-scripts/99-copy-logs.ks
> +++ b/data/post-scripts/99-copy-logs.ks
> @@ -1,16 +1,17 @@
>  # Note, this script log will not be copied to the installed system.
>  %post --nochroot
>  
> +LOGDIR=$ANA_INSTALL_PATH/var/log/anaconda
>  mkdir -p /mnt/sysimage/var/log/anaconda
> -[ -e /tmp/anaconda.log ] && cp /tmp/anaconda.log $ANA_INSTALL_PATH/var/log/anaconda/anaconda.log
> -[ -e /tmp/syslog ] && cp /tmp/syslog $ANA_INSTALL_PATH/var/log/anaconda/syslog
> -[ -e /tmp/X.log ] && cp /tmp/X.log $ANA_INSTALL_PATH/var/log/anaconda/anaconda.xlog
> -[ -e /tmp/program.log ] && cp /tmp/program.log $ANA_INSTALL_PATH/var/log/anaconda/anaconda.program.log
> -[ -e /tmp/packaging.log ] && cp /tmp/packaging.log $ANA_INSTALL_PATH/var/log/anaconda/anaconda.packaging.log
> -[ -e /tmp/storage.log ] && cp /tmp/storage.log $ANA_INSTALL_PATH/var/log/anaconda/anaconda.storage.log
> -[ -e /tmp/ifcfg.log ] && cp /tmp/ifcfg.log $ANA_INSTALL_PATH/var/log/anaconda/anaconda.ifcfg.log
> -[ -e /tmp/yum.log ] && cp /tmp/yum.log $ANA_INSTALL_PATH/var/log/anaconda/anaconda.yum.log
> -cp /tmp/ks-script*.log $ANA_INSTALL_PATH/var/log/anaconda/
> -chmod 0600 /mnt/sysimage/var/log/anaconda/*
> +[ -e /tmp/anaconda.log ] && cp /tmp/anaconda.log $LOGDIR/anaconda.log
> +[ -e /tmp/syslog ] && cp /tmp/syslog $LOGDIR/syslog
> +[ -e /tmp/X.log ] && cp /tmp/X.log $LOGDIR/anaconda.xlog
> +[ -e /tmp/program.log ] && cp /tmp/program.log $LOGDIR/anaconda.program.log
> +[ -e /tmp/packaging.log ] && cp /tmp/packaging.log $LOGDIR/anaconda.packaging.log
> +[ -e /tmp/storage.log ] && cp /tmp/storage.log $LOGDIR/anaconda.storage.log
> +[ -e /tmp/ifcfg.log ] && cp /tmp/ifcfg.log $LOGDIR/anaconda.ifcfg.log
> +[ -e /tmp/yum.log ] && cp /tmp/yum.log $LOGDIR/anaconda.yum.log
> +cp /tmp/ks-script*.log $LOGDIR/
> +chmod 0600 $LOGDIR/{syslog,*.log}
>  
>  %end
> diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py
> index 05e7753..bcb1934 100644
> --- a/pyanaconda/iutil.py
> +++ b/pyanaconda/iutil.py
> @@ -480,3 +480,32 @@ class ProxyString(object):
>      def __str__(self):
>          return self.url
>  
> +def pidof(procname):
> +    def cmdmatch(pid):
> +        try:
> +            argv = open("/proc/"+pid+"/cmdline").read().split('\0')
> +        except IOError:
> +            return False
> +        return procname in (argv[0], os.path.basename(argv[0]))
> +    return [int(pid) for p in os.listdir("/proc") if cmdmatch(p)]
You could use parentheses instead of square brackets to return generator
instead of constructing a new list. As long as the returned value is
used only in for-cycles they behave the same way. However it is worth
adding a docstring with "@rtype: generator" or something like that.

Otherwise this looks good to me and I am for not renaming the log files
now that they are in a separate directory.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list