Hello Meni Yakove, Antoni Segura Puimedon, Dan Kenigsberg,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/13813
to review the following change.
Change subject: split restore-net-conf away of vdsmd.init service
......................................................................
split restore-net-conf away of vdsmd.init service
There is no need to revert network configuration when vdsmd is
restarted, only when the host is rebooted after being fenced.
This becomes painfully visisble if vdsm is restarted due to spm
failover, and while at it - rolls back an unrelated network
configuration.
Change-Id: Iabe00320d090b9055c3d619260ed57ee953702f1
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
Reviewed-on:
http://gerrit.ovirt.org/10334
Reviewed-by: Antoni Segura Puimedon <asegurap(a)redhat.com>
Tested-by: Meni Yakove <myakove(a)redhat.com>
---
M .gitignore
M vdsm.spec.in
M vdsm/Makefile.am
A vdsm/vdsm-restore-net-config.init.in
A vdsm/vdsm-restore-net-config.service
M vdsm/vdsmd.init.in
6 files changed, 86 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/13813/1
diff --git a/.gitignore b/.gitignore
index 49a78ef..e962f08 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,6 +40,7 @@
vdsm/vdsm.rwtab
vdsm/vdsmd.8
vdsm/vdsmd.init
+vdsm/vdsm-restore-net-config.init
vdsm-tool/load_needed_modules.py
vdsm-tool/validate_ovirt_certs.py
vdsm_cli/vdsClient
diff --git a/vdsm.spec.in b/vdsm.spec.in
index f8a2924..7d1b001 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -458,6 +458,8 @@
# Install the SysV init scripts
install -Dm 0755 vdsm/vdsmd.init %{buildroot}%{_initrddir}/vdsmd
install -Dm 0755 vdsm_reg/vdsm-reg.init %{buildroot}%{_initrddir}/vdsm-reg
+install -Dm 0755 vdsm/vdsm-restore-net-config.init \
+ %{buildroot}%{_initrddir}/vdsm-restore-net-config
# This is not commonplace, but we want /var/log/core to be a world-writable
# dropbox for core dumps
@@ -470,6 +472,8 @@
# Install the systemd scripts
install -Dm 0755 vdsm/vdsmd.init %{buildroot}/lib/systemd/systemd-vdsmd
install -Dm 0644 vdsm/vdsmd.service %{buildroot}%{_unitdir}/vdsmd.service
+install -Dm 0644 vdsm/vdsm-restore-net-config.service \
+ %{buildroot}%{_unitdir}/vdsm-restore-net-config.service
install -Dm 0755 vdsm_reg/vdsm-reg.init \
%{buildroot}/lib/systemd/systemd-vdsm-reg
install -Dm 0644 vdsm_reg/vdsm-reg.service \
@@ -519,10 +523,12 @@
%if 0%{?rhel}
if [ "$1" -eq 1 ] ; then
/sbin/chkconfig --add vdsmd
+ /sbin/chkconfig --add vdsm-restore-net-config
fi
%else
if [ "$1" -eq 1 ] ; then
/bin/systemctl enable vdsmd.service >/dev/null 2>&1 || :
+ /bin/systemctl enable vdsm-restore-net-config.service >/dev/null 2>&1 || :
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
exit 0
@@ -548,6 +554,7 @@
then
/sbin/service vdsmd stop > /dev/null 2>&1 || :
/sbin/chkconfig --del vdsmd
+ /sbin/chkconfig --del vdsm-restore-net-config
/bin/sed -i '/# VDSM section begin/,/# VDSM section end/d' \
/etc/sysctl.conf
@@ -567,6 +574,7 @@
%else
if [ "$1" -eq 0 ]; then
/bin/systemctl --no-reload disable vdsmd.service > /dev/null 2>&1 || :
+ /bin/systemctl --no-reload disable vdsm-restore-net-config.service > /dev/null
2>&1 || :
/bin/systemctl stop vdsmd.service > /dev/null 2>&1 || :
fi
exit 0
@@ -630,9 +638,11 @@
%doc COPYING README vdsm/vdsm.conf.sample
%if 0%{?rhel}
%{_initrddir}/vdsmd
+%{_initrddir}/vdsm-restore-net-config
%else
/lib/systemd/systemd-vdsmd
%{_unitdir}/vdsmd.service
+%{_unitdir}/vdsm-restore-net-config.service
%endif
%dir %attr(-, %{vdsm_user}, %{vdsm_group}) @vdsmrepo@
%ghost %dir %attr(-, %{vdsm_user}, %{vdsm_group}) @vdsmrepo@/hsm-tasks
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index 88b3287..224a31f 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -89,9 +89,11 @@
mom.conf \
sudoers.vdsm \
vdsm-logrotate.conf \
+ vdsm-restore-net-config.init \
vdsm.conf.sample \
vdsm.rwtab \
- vdsmd.init
+ vdsmd.init \
+ $(NULL)
dist_vdsm_SCRIPTS = \
addNetwork \
@@ -137,6 +139,8 @@
vdsm-libvirt-logrotate \
vdsm-logrotate \
vdsm-logrotate.conf.in \
+ vdsm-restore-net-config.init.in \
+ vdsm-restore-net-config.service \
vdsm.rwtab.in \
vdsm-store-net-config.in \
vdsm-sysctl.conf
diff --git a/vdsm/vdsm-restore-net-config.init.in b/vdsm/vdsm-restore-net-config.init.in
new file mode 100644
index 0000000..83a437a
--- /dev/null
+++ b/vdsm/vdsm-restore-net-config.init.in
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+# vdsm-restore-net-config: restore network interface configuration
+#
+# chkconfig: 2345 98 01
+# description: roll back the host network configuration to the last \
+# known-good one.
+
+### BEGIN INIT INFO
+# Provides: vdsm-restore-net-config
+# Required-Start: $network
+# Short-Description: restore network configuration files
+# Description: roll back the host network configuration to the last \
+# known-good one.
+#
+### END INIT INFO
+
+sysconfdir="/etc"
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# usage [val]
+# Display usage string, then exit with VAL (defaults to 2).
+usage() {
+ echo $"Usage: $0
{start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+ exit ${1-2}
+}
+
+retval=0
+case "$1" in
+ # commands required in all Fedora initscripts
+ start|restart|reload|force-reload|condrestart|try-restart)
+ echo -n $"Running $prog $1: "
+ @VDSMDIR@/vdsm-restore-net-config
+ retval=$?
+ echo
+ ;;
+ stop|status)
+ snapshotdir=`python -c 'from vdsm.netinfo import NET_LOGICALNET_CONF_BACK_DIR
as d;print d'`
+ if test -d "$snapshotdir"
+ then
+ echo $"There are uncommitted network configuration changes"
+ else
+ echo $"No pending network configuration changes"
+ fi
+ ;;
+
+ --help)
+ usage 0
+ ;;
+ *)
+ usage
+ ;;
+esac
+
+exit $retval
diff --git a/vdsm/vdsm-restore-net-config.service b/vdsm/vdsm-restore-net-config.service
new file mode 100644
index 0000000..a43da99
--- /dev/null
+++ b/vdsm/vdsm-restore-net-config.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Restore failed Vdsm network configuration on boot
+Requires=libvirtd.service
+Before=vdsmd.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/share/vdsm/vdsm-restore-net-config
+
+[Install]
+WantedBy=multi-user.target
diff --git a/vdsm/vdsmd.init.in b/vdsm/vdsmd.init.in
index c8223d3..873b585 100755
--- a/vdsm/vdsmd.init.in
+++ b/vdsm/vdsmd.init.in
@@ -475,7 +475,6 @@
return $ret_val
fi
- @VDSMDIR@/vdsm-restore-net-config
/usr/bin/vdsm-tool load-needed-modules
mk_data_center
mk_core_path
--
To view, visit
http://gerrit.ovirt.org/13813
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iabe00320d090b9055c3d619260ed57ee953702f1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.2
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Meni Yakove <myakove(a)redhat.com>