Change in vdsm[ovirt-3.5]: init: fix network service status checking

phoracek at redhat.com phoracek at redhat.com
Wed Mar 4 12:15:46 UTC 2015


Hello Dan Kenigsberg,

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

    https://gerrit.ovirt.org/38369

to review the following change.

Change subject: init: fix network service status checking
......................................................................

init: fix network service status checking

In init file, we check if network service is running by its status
return code. Problem is, that this code is "always" 0, therefore we never
start network service when needed (for example, it's not autostarted
on CentOS 6).

`service network status` returns lists of configured and active devices,
if the list of active devices (on the last row) does not contains all
VDSM's ONBOOT=yes devices, it means, that network service did not start
our devices and we should call service network start.

Change-Id: Idfe796744e44af21f08974f2ccb4bbb503cc6d67
Signed-off-by: Petr Horáček <phoracek at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/38173
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M init/sysvinit/vdsmd.init.in
1 file changed, 39 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/69/38369/1

diff --git a/init/sysvinit/vdsmd.init.in b/init/sysvinit/vdsmd.init.in
index 7c02cff..2ba8011 100755
--- a/init/sysvinit/vdsmd.init.in
+++ b/init/sysvinit/vdsmd.init.in
@@ -25,8 +25,7 @@
 prog=vdsm
 PIDFILE=@VDSMRUNDIR@/vdsmd.pid
 RESPAWNPIDFILE=@VDSMRUNDIR@/respawn.pid
-NEEDED_SERVICES="multipathd rpcbind ntpd wdmd sanlock network libvirtd
-                 supervdsmd"
+NEEDED_SERVICES="multipathd rpcbind ntpd wdmd sanlock libvirtd supervdsmd"
 CONFLICTING_SERVICES="libvirt-guests ksmtuned"
 LOCK_FILE="/var/lock/subsys/vdsmd"
 VDSM_TOOL="@BINDIR@/vdsm-tool"
@@ -89,6 +88,43 @@
     done
 }
 
+start_network() {
+    # Check if there are unactivated VDSM devices
+    local interfaces dev static_devs activated_devs
+
+    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="ifcfg-$dev"
+        grep -q '# Generated by VDSM version' "$ifcfg" || continue
+        grep -q 'ONBOOT=yes' "$ifcfg" || continue
+        static_devs="$static_devs $dev"
+    done
+    popd > /dev/null
+
+    activated_devs="`service network status | tail -1`"
+
+    for static_dev in $static_devs; do
+        if [[ $activated_devs != *"$static_dev"* ]]; then
+            service network start
+            ret_val=$?
+            if [ "${ret_val}" -ne 0 ]; then
+                log_failure_msg "${prog}: Start dependent network"
+                return "${ret_val}"
+            fi
+            break
+        fi
+    done
+}
+
 test_already_running()
 {
     if pidofproc -p "$RESPAWNPIDFILE" >/dev/null || \
@@ -108,6 +144,7 @@
 start() {
     test_already_running && return 0
 
+    start_network || return 1
     shutdown_conflicting_srv "${CONFLICTING_SERVICES}" || return 1
     start_needed_srv "${NEEDED_SERVICES}" || return 1
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idfe796744e44af21f08974f2ccb4bbb503cc6d67
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list