[node-patches] Change in ovirt-node[master]: RFC: synchronize log dir with iso on boot

mburns at redhat.com mburns at redhat.com
Thu May 23 10:43:53 UTC 2013


Michael Burns has uploaded a new change for review.

Change subject: RFC:  synchronize log dir with iso on boot
......................................................................

RFC:  synchronize log dir with iso on boot

During an upgrade, a service could be added that logs in a new
location under /var/log/<service>.  The directory will not exist
and start/stop of that service may fail.

This patch adds logic that will examing the contents of /var/log
on the base iso and create any directories found there but
not found in the HostVG-Logging partition.

Change-Id: Ife2399c9cb1fb7eb9fd572f9214ee74f8a61a8ce
Signed-off-by: Mike Burns <mburns at redhat.com>
---
M scripts/ovirt-init-functions.sh.in
M src/ovirtnode/ovirtfunctions.py
2 files changed, 27 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/18/15018/1

diff --git a/scripts/ovirt-init-functions.sh.in b/scripts/ovirt-init-functions.sh.in
index d78a5c1..a805a52 100644
--- a/scripts/ovirt-init-functions.sh.in
+++ b/scripts/ovirt-init-functions.sh.in
@@ -816,6 +816,19 @@
             mount -a
             swapon -a
         fi
+        log "Synchronizing log files"
+        logsync_TMPDIR=$(mktemp -d)
+        mkdir -p ${logsync_TMPDIR}/{squash,ext3}
+        mount /dev/.initramfs/live/LiveOS/sqaushfs.img ${logsync_TMPDIR}/squash
+        mount ${logsync_TMPDIR}/squash/LiveOS/ext3fs.img ${logsync_TMPDIR}/ext3
+        python << EOP
+from ovirtnode.ovirtfunctions import copy_dir_if_not_exist
+copy_dir_if_not_exist("${logsync_TMPDIR}/ext3/var/log", "/var/log")
+EOP
+        umount ${logsync_TMPDIR}/ext3
+        umount ${logsync_TMPDIR}/squash
+        rm -rf ${logsync_TMPDIR}
+
 
     fi
     log "Updating $OVIRT_DEFAULTS"
diff --git a/src/ovirtnode/ovirtfunctions.py b/src/ovirtnode/ovirtfunctions.py
index ee47286..a091c1d 100644
--- a/src/ovirtnode/ovirtfunctions.py
+++ b/src/ovirtnode/ovirtfunctions.py
@@ -1806,6 +1806,20 @@
     else:
         return False
 
+#function to copy missing directories from one location to another
+# should only be used when syncing a directory structure from iso
+# to disk like /var/log
+# use case -- upgrade adds some service which logs to /var/log/<service>
+# need to have the directory created, but it's not on iso upgrade
+def copy_dir_if_not_exist(orig, target):
+  for f in os.listdir(orig):
+    if os.path.isdir("%s/%s" % (orig, f)):
+        if not os.path.exists("%s/%s" % (target, f)):
+            system_closefds("cp -av %s/%s %s &>/dev/null" % (orig, f, target))
+        else:
+            copy_dir_if_not_exist("%s/%s" % (orig, f),"%s/%s" % (target,f))
+
+
 class PluginBase(object):
     """Base class for pluggable Hypervisor configuration options.
 


--
To view, visit http://gerrit.ovirt.org/15018
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ife2399c9cb1fb7eb9fd572f9214ee74f8a61a8ce
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Michael Burns <mburns at redhat.com>



More information about the node-patches mailing list