[node-patches] Change in ovirt-node[ovirt-3.5]: Mount kdump nfs targets before trying to use them

fabiand at redhat.com fabiand at redhat.com
Wed Nov 26 11:29:35 UTC 2014


Hello Ryan Barry,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/35591

to review the following change.

Change subject: Mount kdump nfs targets before trying to use them
......................................................................

Mount kdump nfs targets before trying to use them

Kdump over NFS won't even try anymore if it's not mounted. See
the discussion in rhbz#808298

Mount it before we try to set it as a target so kdump can deal
with it, then ummount it if it's unset. Mount it in ovirt-kdump

Change-Id: I7b64094fe1c42638eac00ad81c79c043b884a528
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1095140
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M scripts/ovirt-init-functions.sh.in
M src/ovirt/node/config/defaults.py
2 files changed, 44 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/91/35591/1

diff --git a/scripts/ovirt-init-functions.sh.in b/scripts/ovirt-init-functions.sh.in
index ce8f570..c0be57c 100644
--- a/scripts/ovirt-init-functions.sh.in
+++ b/scripts/ovirt-init-functions.sh.in
@@ -1573,6 +1573,11 @@
     return $?
 }
 
+major_release() {
+    REL=`cat /etc/redhat-release | sed -r 's/.*release ([0-9]+).*/\1/'`
+    echo $REL
+}
+
 start_ovirt_kdump () {
     [ -f "$VAR_SUBSYS_OVIRT_cim" ] && exit 0
     {
@@ -1581,6 +1586,10 @@
         touch $VAR_SUBSYS_OVIRT_KDUMP
 
         if is_persisted /etc/kdump.conf; then
+            if [[ ! -z $OVIRT_KDUMP_NFS && $(major_release) -ge 7 ]]; then
+                [[ ! -d //var/run/kdump-nfs ]] && mkdir /var/run/kdump-nfs
+                mount /var/run/kdump-nfs
+            fi
             service kdump start
         fi
 
diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
old mode 100644
new mode 100755
index 64d7e6b..81f899c
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -1085,6 +1085,7 @@
 
         aug = AugeasWrapper()
         prefix = "/files/etc/kdump.conf/"
+        nfs_path = "/var/run/kdump-nfs"
 
         def _set_values(vals):
             for k, v in vals.iteritems():
@@ -1120,6 +1121,35 @@
                         "path": "/core"}
 
                 _set_values(vals)
+
+        class MountNFS(utils.Transaction.Element):
+            title = "Mounting NFS volume for kdump configuration"
+
+            def commit(self):
+                try:
+                    if not os.path.isdir(nfs_path):
+                        os.makedirs(nfs_path)
+                    system.Mount(nfs_path, nfs, "nfs").mount()
+
+                    File("/etc/fstab").write(
+                        "\n%s\t%s\tnfs\tdefaults\t0 0" % (nfs, nfs_path),
+                        "a")
+                except utils.process.CalledProcessError:
+                    self.logger.warning("Failed to mount %s at " +
+                                        "%s" % (nfs, nfs_path),
+                                        exc_info=True)
+
+        class UmountNFS(utils.Transaction.Element):
+            title = "Umounting Kdump NFS volume"
+
+            def commit(self):
+                try:
+                    system.Mount(nfs_path).umount()
+                    File("/etc/fstab").sed(r'\#.*{dir}#d'.format(
+                        dir=nfs_path))
+                except utils.process.CalledProcessError:
+                    self.logger.warning("Failed to umount %s" % nfs,
+                                        exc_info=True)
 
         class CreateNfsKdumpConfig(utils.Transaction.Element):
             title = "Creating kdump NFS config"
@@ -1245,6 +1275,8 @@
 
         final_txe = RestartKdumpService(backup_txe.backups)
         if nfs:
+            if not system.is_max_el(6):
+                tx.append(MountNFS())
             tx.append(CreateNfsKdumpConfig())
         elif ssh:
             if ssh_key:
@@ -1255,6 +1287,9 @@
         else:
             final_txe = RemoveKdumpConfig(backup_txe.backups)
 
+        if not nfs and os.path.ismount(nfs_path):
+            tx.insert(0, UmountNFS())
+
         tx.append(final_txe)
 
         return tx


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b64094fe1c42638eac00ad81c79c043b884a528
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Fabian Deutsch <fabiand at redhat.com>
Gerrit-Reviewer: Fabian Deutsch <fabiand at redhat.com>
Gerrit-Reviewer: Ryan Barry <rbarry at redhat.com>



More information about the node-patches mailing list