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 Change-Id: I8a6e4533628fc217c8e6b0d9028b51f38895f4d2 Signed-off-by: Ryan Barry <[email protected]> Signed-off-by: Douglas Schilling Landgraf <[email protected]> --- M ovirt-node.spec.in M recipe/centos7-install.ks M recipe/rhevh7-install.ks M scripts/Makefile.am M scripts/ovirt-init-functions.sh.in A scripts/ovirt-node-hooks.sh M services/Makefile.am A services/ovirt-node-hooks.service 8 files changed, 79 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/47/47547/1 diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in index 82dea18..fd3c688 100644 --- a/ovirt-node.spec.in +++ b/ovirt-node.spec.in @@ -950,6 +950,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 @@ -967,6 +968,7 @@ %{_unitdir}/ovirt-post.service %{_unitdir}/ovirt-early.service %{_unitdir}/ovirt-kdump.service +%{_unitdir}/ovirt-node-hooks.service %{_sysconfdir}/systemd/system/ntpd.service.d/ntpd-pre-start.conf %{_sysconfdir}/systemd/system/ntpd.service.d/ntpd-private-tmp.conf %else diff --git a/recipe/centos7-install.ks b/recipe/centos7-install.ks index d70632e..019b3f9 100644 --- a/recipe/centos7-install.ks +++ b/recipe/centos7-install.ks @@ -1,3 +1,3 @@ -services --enabled=auditd,ntpd,iptables,network,rsyslog,multipathd,snmpd,ovirt-early,ovirt-post,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-kdump,ovirt-node-hooks,cgconfig,mcelog,tuned,libvirtd --disabled=netfs,ovirt-awake,libvirt-guests,kdump diff --git a/recipe/rhevh7-install.ks b/recipe/rhevh7-install.ks index 16cc769..530c269 100644 --- a/recipe/rhevh7-install.ks +++ b/recipe/rhevh7-install.ks @@ -1,3 +1,3 @@ -services --enabled=fcoe,lldpad,auditd,ntpd,iptables,network,rsyslog,multipathd,snmpd,ovirt-early,ovirt-post,ovirt-cim,ovirt-kdump,cgconfig,mcelog,tuned --disabled=netfs,ovirt-awake,libvirt-guests,libvirtd,kdump +services --enabled=fcoe,lldpad,auditd,ntpd,iptables,network,rsyslog,multipathd,snmpd,ovirt-early,ovirt-post,ovirt-cim,ovirt-kdump,ovirt-node-hooks,cgconfig,mcelog,tuned --disabled=netfs,ovirt-awake,libvirt-guests,libvirtd,kdump diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 222a743..adfed02 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 @@ -46,6 +47,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 ece5ed1..7d052ab 100644 --- a/scripts/ovirt-init-functions.sh.in +++ b/scripts/ovirt-init-functions.sh.in @@ -37,8 +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() { plymouth --hide-splash @@ -1504,16 +1502,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? @@ -1655,6 +1643,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 100644 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 <[email protected]> +# +# 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/Makefile.am b/services/Makefile.am index 69f2ff8..fb39a74 100644 --- a/services/Makefile.am +++ b/services/Makefile.am @@ -27,6 +27,7 @@ ovirt-firstboot.service \ ovirt-cim.service \ ovirt-kdump.service \ + ovirt-node-hooks.service \ ovirt-node-igor-slave.service else dist_initd_SCRIPTS = \ diff --git a/services/ovirt-node-hooks.service b/services/ovirt-node-hooks.service new file mode 100644 index 0000000..3f0e66f --- /dev/null +++ b/services/ovirt-node-hooks.service @@ -0,0 +1,13 @@ +[Unit] +Description=oVirt Node Hooks configuration service +After=ovirt.service libvirtd.service +Before=vdsmd.service ovirt-node-plugin-vdsm.service +Requires=libvirtd.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/libexec/ovirt-node-hooks trigger on-boot + +[Install] +WantedBy=multi-user.target -- To view, visit https://gerrit.ovirt.org/47547 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8a6e4533628fc217c8e6b0d9028b51f38895f4d2 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-node Gerrit-Branch: master Gerrit-Owner: Douglas Schilling Landgraf <[email protected]> _______________________________________________ node-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/node-patches
