[node-patches] Change in ovirt-node[ovirt-3.5]: Move hooks to their own service

dougsland at redhat.com dougsland at redhat.com
Fri Oct 23 20:01:19 UTC 2015


Douglas Schilling Landgraf has uploaded a new change for review.

Change subject: Move hooks to their own service
......................................................................

Move hooks to their own service

Don't run hooks as part of post anymore. Run them as their own
service after vdsm, so we can avoid any potential races with
with libvirt starting

See also: https://gerrit.ovirt.org/#/c/47566/

Change-Id: I8a6e4533628fc217c8e6b0d9028b51f38895f4d2
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1270203
Signed-off-by: Ryan Barry <rbarry at redhat.com>
Signed-off-by: Douglas Schilling Landgraf <dougsland at redhat.com>
---
M ovirt-node.spec.in
M recipe/centos6-install.ks
M recipe/rhevh6-install.ks
M scripts/Makefile.am
M scripts/ovirt-init-functions.sh.in
A scripts/ovirt-node-hooks.sh
A services/init.d/ovirt-node-hooks
7 files changed, 99 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/86/47686/1

diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
index 11b6d45..30aae11 100644
--- a/ovirt-node.spec.in
+++ b/ovirt-node.spec.in
@@ -541,6 +541,7 @@
 /sbin/chkconfig --add ovirt-early
 /sbin/chkconfig --add ovirt-firstboot
 /sbin/chkconfig --add ovirt
+/sbin/chkconfig --add ovirt-node-hooks
 /sbin/chkconfig --add ovirt-post
 /sbin/chkconfig --add ovirt-kdump
 %else
@@ -767,6 +768,7 @@
 %{_libexecdir}/ovirt-admin-shell
 %{_libexecdir}/ovirt-config-password
 %{_libexecdir}/ovirt-init-functions.sh
+%{_libexecdir}/ovirt-node-hooks
 %{_sbindir}/persist
 %{_sbindir}/unpersist
 %{_sbindir}/ovirt-node-upgrade
diff --git a/recipe/centos6-install.ks b/recipe/centos6-install.ks
index bfcb9d5..37b1423 100644
--- a/recipe/centos6-install.ks
+++ b/recipe/centos6-install.ks
@@ -1 +1 @@
-services --enabled=auditd,ntpd,ntpdate,iptables,network,rsyslog,multipathd,snmpd,ovirt-early,ovirt-post,cgconfig,tuned,libvirtd --disabled=netfs,ovirt-awake,libvirt-guests
+services --enabled=auditd,ntpd,ntpdate,iptables,network,rsyslog,multipathd,snmpd,ovirt-early,ovirt-post,ovirt-node-hooks,cgconfig,tuned,libvirtd --disabled=netfs,ovirt-awake,libvirt-guests
diff --git a/recipe/rhevh6-install.ks b/recipe/rhevh6-install.ks
index 5edde2e..f2f52f4 100644
--- a/recipe/rhevh6-install.ks
+++ b/recipe/rhevh6-install.ks
@@ -1,3 +1,3 @@
-services --enabled=auditd,ntpd,ntpdate,iptables,network,rsyslog,multipathd,snmpd,ovirt-early,ovirt-post,ovirt-cim,ovirt-kdump,cgconfig,mcelog,tuned,libvirtd --disabled=netfs,ovirt-awake,libvirt-guests,kdump
+services --enabled=auditd,ntpd,ntpdate,iptables,network,rsyslog,multipathd,snmpd,ovirt-early,ovirt-post,ovirt-cim,ovirt-kdump,ovirt-node-hooks,cgconfig,mcelog,tuned,libvirtd --disabled=netfs,ovirt-awake,libvirt-guests,kdump
 
 
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 9facb20..4327819 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -35,6 +35,7 @@
   ovirt-config-uninstall \
   ovirt-functions \
   ovirt-init-functions.sh \
+  ovirt-node-hooks.sh \
   ovirt-auto-install.py \
   ovirt-admin-shell \
   ovirt-node-igor-slave
@@ -49,6 +50,7 @@
 install-exec-hook:
 	mv $(DESTDIR)$(libexecdir)/ovirt-auto-install.py $(DESTDIR)$(libexecdir)/ovirt-auto-install
 	mv $(DESTDIR)$(sbindir)/ovirt-node-upgrade.py $(DESTDIR)$(sbindir)/ovirt-node-upgrade
+	mv $(DESTDIR)$(libexecdir)/ovirt-node-hooks.sh $(DESTDIR)$(libexecdir)/ovirt-node-hooks
 
 	mkdir -p --mode=0755 \
 	  $(DESTDIR)$(localboottriggerdir) \
diff --git a/scripts/ovirt-init-functions.sh.in b/scripts/ovirt-init-functions.sh.in
index 8dda25b..d6164c7 100644
--- a/scripts/ovirt-init-functions.sh.in
+++ b/scripts/ovirt-init-functions.sh.in
@@ -37,7 +37,6 @@
 AUGTOOL_CONFIG=/var/tmp/augtool-config
 EARLY_DIR=/etc/ovirt-early.d
 
-HOOK_ON_BOOT_DIR=/usr/libexec/ovirt-node/hooks/on-boot
 
 # Drop to a shell
 emergency_shell() {
@@ -1476,16 +1475,6 @@
             rm  /var/lock/subsys/network
         fi
 
-        # Run on-boot hooks
-        if [[ -d "$HOOK_ON_BOOT_DIR" ]] && [[ "$(ls -A $HOOK_ON_BOOT_DIR)" ]];
-        then
-            for handler in "$HOOK_ON_BOOT_DIR"/*;
-            do
-                log "Running handler: $handler"
-                runcon -t unconfined_t "$handler" 2>&1
-            done
-        fi
-
         ovirt_store_config $(ls /etc/ssh/ssh_host*_key*)
 
         # FIXME is this still needed?
@@ -1627,6 +1616,10 @@
     return $?
 }
 
+# Don't actually execute the case statement below if this is sourced as a
+# utility script
+[[ $BASH_SOURCE != $0 ]] && exit 0
+
 #
 # If called with a param from .service file:
 #
diff --git a/scripts/ovirt-node-hooks.sh b/scripts/ovirt-node-hooks.sh
new file mode 100755
index 0000000..4d0c0c6
--- /dev/null
+++ b/scripts/ovirt-node-hooks.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# ovirt-node-hooks.sh - Wrapps all functions needed by oVirt at boot time.
+#
+# Copyright (C) 2015 Red Hat, Inc.
+# Written by Ryan Barry <rbarry at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA  02110-1301, USA.  A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+#
+VAR_SUBSYS_OVIRT_HOOKS=/var/lock/subsys/ovirt-node-hooks
+HOOK_DIR=/usr/libexec/ovirt-node/hooks
+OVIRT_HOOKLOG=/var/log/ovirt-hooks.log
+
+trigger () {
+    echo "Called with $1"
+    {
+        echo "Starting ovirt-node-hooks service for $1"
+
+        # Run on-boot hooks
+        echo "Looking at $HOOK_DIR/$1"
+        if [[ -d "$HOOK_DIR/$1" ]] && [[ "$(ls -A $HOOK_DIR/$1)" ]];
+        then
+            for handler in "$HOOK_DIR/$1"/*;
+            do
+                echo "Running handler: $handler"
+                "$handler" >> $OVIRT_HOOKLOG 2>&1
+            done
+        fi
+
+        echo "Completed ovirt-node-hooks"
+    } >> $OVIRT_HOOKLOG 2>&1
+}
+
+case "$1" in
+    "trigger")
+        trigger "$2"
+        ;;
+    *)
+        echo "Please call with trigger [hook]"
+        ;;
+
+esac
diff --git a/services/init.d/ovirt-node-hooks b/services/init.d/ovirt-node-hooks
new file mode 100755
index 0000000..db75ea6
--- /dev/null
+++ b/services/init.d/ovirt-node-hooks
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# ovirt-node-hooks Start ovirt-node-hooks services
+#
+### BEGIN INIT INFO
+# Provides: ovirt-node-hooks
+# Required-Start: ovirt-early, libvirtd, ovirt-firstboot
+# Default-Start: 2 3 4 5
+# Description: Performs managed node configuration functions.
+### END INIT INFO
+
+prog=ovirt-node-hooks
+
+case "$1" in
+    start)
+        echo -n "Starting ovirt-node-hooks: "
+        /usr/libexec/ovirt-node-hooks trigger on-boot
+        test $? == 0 && success || failure
+        echo
+        ;;
+    status)
+        status -l $prog
+        test $? == 0 && success || failure
+        ;;
+    stop)
+        echo -n "Stopping ovirt-node-hooks: "
+        kill -TERM `pidof ovirt-node-hooks`
+        success
+        echo
+        ;;
+    *)
+        echo "Usage: ovirt-node-hooks {start}"
+        exit 2
+esac


-- 
To view, visit https://gerrit.ovirt.org/47686
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8a6e4533628fc217c8e6b0d9028b51f38895f4d2
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Douglas Schilling Landgraf <dougsland at redhat.com>



More information about the node-patches mailing list