Hello Dan Kenigsberg,

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

    http://gerrit.ovirt.org/22436

to review the following change.

Change subject: configNetwork: Fix bridgeless broken network deletion
......................................................................

configNetwork: Fix bridgeless broken network deletion

When trying to delete a broken bridgeless vdsm network, if the iface
referenced by the network definition was missing, delNetwork would
not get any device on its call for vlan, nic and bonds, but
objectivize would be called nonetheless, failing with a:

ERR_BAD_PARAMS: 'Network defined without devices.'

The fix consists on just removing the network from libvirt when the
backing device is missing.

Change-Id: I92c641d91da9ef7eab876ed8c77fff7a9becb503
Bug-Url: https://bugzilla.redhat.com/1020356
Signed-off-by: Antoni S. Puimedon <[email protected]>
Reviewed-on: http://gerrit.ovirt.org/22354
Reviewed-by: Dan Kenigsberg <[email protected]>
---
M tests/functional/networkTests.py
M tests/functional/utils.py
M vdsm/configNetwork.py
3 files changed, 34 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/36/22436/1

diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index 3e0eed8..c010bcc 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -27,6 +27,7 @@
 from testValidation import RequireDummyMod, ValidateRunningAsRoot
 
 import dummy
+import ipwrapper
 from utils import cleanupNet, restoreNetConfig, SUCCESS, VdsProxy, cleanupRules
 
 from vdsm.ipwrapper import (ruleAdd, ruleDel, routeAdd, routeDel, routeExists,
@@ -1405,3 +1406,27 @@
                 status, msg = self.vdsm_net.setupNetworks(delete_networks,
                                                           {}, {})
                 self.assertEqual(status, SUCCESS, msg)
+
+    @RequireDummyMod
+    @ValidateRunningAsRoot
+    def testBrokenBridgelessNetReplacement(self):
+        with dummyIf(1) as nics:
+            nic, = nics
+            network = {NETWORK_NAME: {'nic': nic, 'vlan': VLAN_ID,
+                                      'bridged': False}}
+            status, msg = self.vdsm_net.setupNetworks(network, {},
+                                                      {'connectivityCheck': 0})
+            self.assertEqual(status, SUCCESS, msg)
+            self.assertNetworkExists(NETWORK_NAME)
+            ipwrapper.linkDel(nic + '.' + VLAN_ID)
+            self.vdsm_net.refreshNetinfo()
+            self.assertNetworkDoesntExist(NETWORK_NAME)
+            status, msg = self.vdsm_net.setupNetworks(network, {},
+                                                      {'connectivityCheck': 0})
+            self.assertEqual(status, SUCCESS, msg)
+            self.assertNetworkExists(NETWORK_NAME)
+            network[NETWORK_NAME] = {'remove': True}
+            status, msg = self.vdsm_net.setupNetworks(network, {},
+                                                      {'connectivityCheck': 0})
+            self.assertEqual(status, SUCCESS, msg)
+            self.assertNetworkDoesntExist(NETWORK_NAME)
diff --git a/tests/functional/utils.py b/tests/functional/utils.py
index f80175e..d8bc939 100644
--- a/tests/functional/utils.py
+++ b/tests/functional/utils.py
@@ -139,6 +139,10 @@
         self.vdscli.setSafeNetworkConfig()
 
     @netinfo_altering
+    def refreshNetinfo(self):
+        pass
+
+    @netinfo_altering
     def restoreNetConfig(self):
         restoreNetConfig()
 
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 28c1200..97d3f09 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -27,6 +27,7 @@
 from vdsm import utils
 from storage.misc import execCmd
 import neterrors as ne
+from netconf import libvirtCfg
 from neterrors import ConfigNetworkError
 from vdsm import netinfo
 from netconf.ifcfg import ConfigWriter
@@ -263,6 +264,10 @@
     _netinfo.networks[network] = netAttr
     if _netinfo.networks[network]['bridged']:
         _netinfo.networks[network]['ports'] = ConfigWriter.ifcfgPorts(network)
+    elif not os.path.exists('/sys/class/net/' + netAttr['iface']):
+        # Bridgeless broken network without underlying device
+        libvirtCfg.removeNetwork(network)
+        return
     delNetwork(network, configurator=configurator, force=True,
                implicitBonding=False, _netinfo=_netinfo)
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I92c641d91da9ef7eab876ed8c77fff7a9becb503
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.3
Gerrit-Owner: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to