Dan Kenigsberg has uploaded a new change for review.

Change subject: sysv init: wait for network service
......................................................................

sysv init: wait for network service

sysv's network service is not synchronous. It returns before all of the
interfaces that itstarted are actually up.

This is particularly problematic when upgrading from ovirt-3.4 to
ovirt-3.5, as one of the first pre-run tasks is to upgrade network
configuration to the "unified persistence" model.

This patch waits up to 5 seconds for each vdsm-controlled interface to
obtain its IPv4 address. It's a hack, an ugly hack, that does not solve
the inherent race. The race would be solved only when we tap into
netlink's event monitor and stall ifup until the interface is actually
up.

Change-Id: I89abe7a83673c2232f8b249f23a39e27e01e50be
Bug-Url: https://bugzilla.redhat.com/1174611
Signed-off-by: Dan Kenigsberg <[email protected]>
---
M init/sysvinit/vdsmd.init.in
1 file changed, 47 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/47/36647/1

diff --git a/init/sysvinit/vdsmd.init.in b/init/sysvinit/vdsmd.init.in
index 7c02cff..169108e 100755
--- a/init/sysvinit/vdsmd.init.in
+++ b/init/sysvinit/vdsmd.init.in
@@ -42,6 +42,49 @@
 log_failure_msg() { printf "$@"; failure "$@"; echo; }
 log_success_msg() { printf "$@"; success "$@"; echo; }
 
+has_ipv4() {
+    local dev="$1"
+    ip -o address show "$dev" | grep -q ' inet '
+}
+
+wait_for_ipv4() {
+    local dev="$1"
+    local i
+
+    for i in `seq 50`
+    do
+        has_ipv4 "$dev" && return 0
+        sleep 0.1
+    done
+    echo "timeout waiting for ipv4 address on $dev"
+    return 1
+}
+
+wait_for_vdsm_devices() {
+    local interfaces dev
+
+    pushd /etc/sysconfig/network-scripts/ > /dev/null
+
+    # copied from /etc/init.d/network
+    interfaces=$(ls ifcfg-* | \
+            LC_ALL=C sed -e "$__sed_discard_ignored_files" \
+                   -e '/\(ifcfg-lo$\|:\|ifcfg-.*-range\)/d' \
+                   -e '{ s/^ifcfg-//g;s/[0-9]/ &/}' | \
+            LC_ALL=C sort -k 1,1 -k 2n | \
+            LC_ALL=C sed 's/ //')
+
+    for dev in $interfaces;
+    do
+        ifcfg="/etc/sysconfig/network-scripts/ifcfg-$dev"
+        grep -q '# Generated by VDSM version' "$ifcfg" || continue
+        grep -q 'ONBOOT=yes' "$ifcfg" || continue
+        grep -q 'IPADDR=' "$ifcfg" || continue
+        wait_for_ipv4 "$dev"
+    done
+
+    popd > /dev/null
+}
+
 shutdown_conflicting_srv() {
     local srv
     local ret_val
@@ -111,6 +154,10 @@
     shutdown_conflicting_srv "${CONFLICTING_SERVICES}" || return 1
     start_needed_srv "${NEEDED_SERVICES}" || return 1
 
+    # interfaces that we depend upon may not have their IP address ready yet
+    # see https://bugzilla.redhat.com/show_bug.cgi?id=1174611#c34
+    wait_for_vdsm_networks
+
     # "service iscsid start" may not start becasue we configure node.startup to
     # manual. See /etc/init.d/iscsid.
     service iscsid status >/dev/null 2>&1 || service iscsid force-start \


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I89abe7a83673c2232f8b249f23a39e27e01e50be
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to