Change in vdsm[master]: netinfo: remove an assertion from getBondingForNic

osvoboda at redhat.com osvoboda at redhat.com
Wed Aug 19 10:20:00 UTC 2015


Ondřej Svoboda has uploaded a new change for review.

Change subject: netinfo: remove an assertion from getBondingForNic
......................................................................

netinfo: remove an assertion from getBondingForNic

The following commands show that a NIC cannot be enslaved to multiple bonds:

 # ip link add type dummy
 # ip link add type bond
 # ip link add type bond
 # echo +dummy0 > /sys/class/net/bond0/bonding/slaves
 # echo +dummy0 > /sys/class/net/bond1/bonding/slaves
 -bash: echo: write error: Device or resource busy

The reason to remove assertions is quoted from Nir Soffer's
https://gerrit.ovirt.org/34361/ (which this patch replaces,
partially):

The code was assuming that asserts are always available, and if running
within optimized mode, the code would skip the assert and use invalid
configuration, possibly corrupting application state or failing with
unrelated errors, hiding the root cause of the error.

Change-Id: I0b39d3b0040c86a8c4c4babe4af03b9cf8f6bdd4
Signed-off-by: Ondřej Svoboda <osvoboda at redhat.com>
---
M lib/vdsm/netinfo.py
1 file changed, 2 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/45072/1

diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index dfe8994..bac6ec5 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -897,11 +897,8 @@
     def getBondingForNic(self, nic):
         bondings = [b for (b, attrs) in self.bondings.iteritems() if
                     nic in attrs['slaves']]
-        if bondings:
-            assert len(bondings) == 1, \
-                "Unexpected configuration: More than one bonding per nic"
-            return bondings[0]
-        return None
+        # only a single bond can have the NIC as a slave
+        return bondings[0] if bondings else None
 
     def getNicsVlanAndBondingForNetwork(self, network):
         vlan = None


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b39d3b0040c86a8c4c4babe4af03b9cf8f6bdd4
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvoboda at redhat.com>


More information about the vdsm-patches mailing list