Change in vdsm[master]: [WIP] Don't fail silently when ifup fails.

asegurap at redhat.com asegurap at redhat.com
Tue Oct 9 06:55:29 UTC 2012


Antoni Segura Puimedon has uploaded a new change for review.

Change subject: [WIP] Don't fail silently when ifup fails.
......................................................................

[WIP] Don't fail silently when ifup fails.

Up until now we discarded ifup return codes and ignored
the possible errors present in ifup stdout. Use this
information to perform better error reporting.

Change-Id: I1cc9dcc0a6b55d36fc937e1d364bd9c256ecd70a
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
Bug-Url: https://bugzilla.redhat.com/856737
---
M vdsm/configNetwork.py
M vdsm/neterrors.py
2 files changed, 28 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/15/8415/1

diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index a114798..fb7cd94 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -29,6 +29,7 @@
 from xml.sax.saxutils import escape
 import glob
 import shutil
+from functools import partial
 
 import libvirt
 import selinux
@@ -60,15 +61,23 @@
     return rc
 
 
-def ifup(iface, async=False):
+def ifup(iface, async=False, final=None):
     "Bring up an interface"
-    _ifup = lambda netIf: execCmd([constants.EXT_IFUP, netIf], raw=True)
+    def _ifup(netIf, toCall=None):
+        rc, out, err = execCmd([constants.EXT_IFUP, netIf], raw=False)
+
+        if rc != 0:
+            # In /etc/sysconfig/network-scripts/ifup* the last line usually
+            # contains the error reason.
+            raise ConfigNetworkError(ne.ERR_FAILED_IFUP, out[-1])
+        elif toCall is not None:
+            toCall()
 
     if async:
         # wait for dhcp in another thread,
         # so vdsm won't get stuck (BZ#498940)
         t = threading.Thread(target=_ifup, name='ifup-waiting-on-dhcp',
-                             args=(iface,))
+                             args=(iface, final))
         t.daemon = True
         t.start()
     else:
@@ -899,6 +908,11 @@
     nic = nics[0] if nics else None
     iface = bonding or nic
     blockingDhcp = utils.tobool(options.get('blockingdhcp'))
+    # Asynchronous top level ifup creation variables.
+    async = options['bootproto'] and blockingDhcp
+    libvirtNetworkCreation = partial(configWriter.createLibvirtNetwork,
+                                          network, bridged, iface)
+
 
     # take down nics that need to be changed
     vlanedIfaces = [v['iface'] for v in _netinfo.vlans.values()]
@@ -959,22 +973,27 @@
 
     # Now we can run ifup for all interfaces
     if bonding:
-        ifup(bonding, bondBootproto == 'dhcp' and not blockingDhcp)
+        ifup(bonding, bondBootproto == 'dhcp' and not blockingDhcp,
+             libvirtNetworkCreation)
 
     # NICs must be activated in the same order of boot time
     # to expose the correct MAC address.
     for nic in nicSort(nics):
-        ifup(nic, options['bootproto'] and not blockingDhcp)
+        ifup(nic, options['bootproto'] and not blockingDhcp,
+             libvirtNetworkCreation)
 
     # Now we can ifup VLAN interface, because bond and nic already up
     if vlan:
-        ifup(iface, vlanBootproto == 'dhcp' and not blockingDhcp)
+        ifup(iface, vlanBootproto == 'dhcp' and not blockingDhcp,
+             libvirtNetworkCreation)
 
     if bridged:
-        ifup(network, bridgeBootproto == 'dhcp' and not blockingDhcp)
+        ifup(network, bridgeBootproto == 'dhcp' and not blockingDhcp,
+             libvirtNetworkCreation)
 
     # add libvirt network
-    configWriter.createLibvirtNetwork(network, bridged, iface)
+    if not async:
+        libvirtNetworkCreation()
 
 
 def assertBridgeClean(bridge, vlan, bonding, nics):
diff --git a/vdsm/neterrors.py b/vdsm/neterrors.py
index 65e2674..92faa59 100644
--- a/vdsm/neterrors.py
+++ b/vdsm/neterrors.py
@@ -27,4 +27,5 @@
 ERR_BAD_VLAN = 26
 ERR_BAD_BRIDGE = 27
 ERR_USED_BRIDGE = 28
+ERR_FAILED_IFUP = 30
 ERR_LOST_CONNECTION = 10    # noConPeer


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1cc9dcc0a6b55d36fc937e1d364bd9c256ecd70a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>


More information about the vdsm-patches mailing list