Dan Kenigsberg has uploaded a new change for review.
Change subject: Report legacy bond devices instead of actually creating them
......................................................................
Report legacy bond devices instead of actually creating them
Engine <= 3.2 expects to see bonding devices bond0-bond4 predefined on
each host. Therefor, Vdsm creates them on boot, and never deletes them.
This add cumbersome logic, which has lead to bugs.
Instead, this patch simply reports the existence of the 5 expected
bonds, instead of actually creating them.
Bug-Url:
https://bugzilla.redhat.com/1064208
Change-Id: I4028a70cc8fd3e0599f02ac339a783a7d85f045e
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/netinfo.py
M lib/vdsm/tool/load_needed_modules.py.in
M tests/functional/networkTests.py
M vdsm/caps.py
M vdsm/network/configurators/ifcfg.py
M vdsm/network/configurators/iproute2.py
6 files changed, 27 insertions(+), 20 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/55/28455/1
diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index cfcc5ef..aec14ed 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -82,8 +82,6 @@
LIBVIRT_NET_PREFIX = 'vdsm-'
DEFAULT_MTU = '1500'
-REQUIRED_BONDINGS = frozenset(('bond0', 'bond1', 'bond2',
'bond3', 'bond4'))
-
_Qos = namedtuple('Qos', 'inbound outbound')
OPERSTATE_UP = 'up'
diff --git a/lib/vdsm/tool/load_needed_modules.py.in
b/lib/vdsm/tool/load_needed_modules.py.in
index efbff4b..47e115b 100644
--- a/lib/vdsm/tool/load_needed_modules.py.in
+++ b/lib/vdsm/tool/load_needed_modules.py.in
@@ -20,7 +20,6 @@
import os.path
-from .. import netinfo
from . import expose, ExtraArgsError
from ..utils import execCmd
@@ -37,15 +36,6 @@
raise RuntimeError(
"Execute command %s failed: %s" % (argv, err)
)
-
-
-def _enable_bond_dev():
- # @ENGINENAME@ currently assumes that all bonding devices pre-exist
- with open(netinfo.BONDING_MASTERS) as f:
- existing = set(f.read().split())
- for bond in netinfo.REQUIRED_BONDINGS - existing:
- with open(netinfo.BONDING_MASTERS, 'w') as f:
- f.write('+%s\n' % bond)
def _enable_softdog():
@@ -65,5 +55,4 @@
for mod in ['bridge', 'tun', 'bonding', '8021q']:
_exec_command([EX_MODPROBE, mod])
- _enable_bond_dev()
_enable_softdog()
diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index f528541..e8d667f 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -44,6 +44,7 @@
from vdsm import ipwrapper
from vdsm.utils import pgrep
+from caps import _REQUIRED_BONDINGS
from network import errors
@@ -263,6 +264,11 @@
self.assertEquals(int(mtu), int(self.vdsm_net.getMtu(elem)))
@cleanupNet
+ def testLegacyBonds(self):
+ for b in _REQUIRED_BONDINGS:
+ self.assertBondExists(b, [])
+
+ @cleanupNet
@permutations([[True], [False]])
@RequireDummyMod
@ValidateRunningAsRoot
diff --git a/vdsm/caps.py b/vdsm/caps.py
index a4caa13..bad36dd 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -76,6 +76,21 @@
RNG_SOURCES = {'random': '/dev/random',
'hwrng': '/dev/hwrng'}
+_REQUIRED_BONDINGS = frozenset(('bond0', 'bond1', 'bond2',
'bond3', 'bond4'))
+
+
+def _report_legacy_bondings(caps):
+ """Engine <= 3.2 expects to always see
bond0-bond4"""
+ for b in _REQUIRED_BONDINGS:
+ if b not in caps['bondings']:
+ caps['bondings'][b] = {
+ 'addr': '',
+ 'cfg': {},
+ 'hwaddr': '00:00:00:00:00:00',
+ 'mtu': '1500',
+ 'netmask': '',
+ 'slaves': []}
+
class Architecture:
X86_64 = 'x86_64'
@@ -558,6 +573,7 @@
caps.update(_getVersionInfo())
caps.update(netinfo.get())
+ _report_legacy_bondings(caps)
try:
caps['hooks'] = hooks.installed()
diff --git a/vdsm/network/configurators/ifcfg.py b/vdsm/network/configurators/ifcfg.py
index 8dc5743..7a97736 100644
--- a/vdsm/network/configurators/ifcfg.py
+++ b/vdsm/network/configurators/ifcfg.py
@@ -711,9 +711,8 @@
def removeBonding(self, bonding):
self._backup(netinfo.NET_CONF_PREF + bonding)
self._removeFile(netinfo.NET_CONF_PREF + bonding)
- if bonding not in netinfo.REQUIRED_BONDINGS:
- with open(netinfo.BONDING_MASTERS, 'w') as f:
- f.write("-%s\n" % bonding)
+ with open(netinfo.BONDING_MASTERS, 'w') as f:
+ f.write("-%s\n" % bonding)
def removeBridge(self, bridge):
self._backup(netinfo.NET_CONF_PREF + bridge)
diff --git a/vdsm/network/configurators/iproute2.py
b/vdsm/network/configurators/iproute2.py
index 19ccdb5..8cd9882 100644
--- a/vdsm/network/configurators/iproute2.py
+++ b/vdsm/network/configurators/iproute2.py
@@ -301,10 +301,9 @@
f.write('+%s' % bond.name)
def removeBond(self, bond):
- if bond.name not in netinfo.REQUIRED_BONDINGS:
- logging.debug('Remove bonding %s', bond)
- with open(netinfo.BONDING_MASTERS, 'w') as f:
- f.write('-%s' % bond.name)
+ logging.debug('Remove bonding %s', bond)
+ with open(netinfo.BONDING_MASTERS, 'w') as f:
+ f.write('-%s' % bond.name)
def addBondSlave(self, bond, slave):
logging.debug('Add slave %s to bonding %s', slave, bond)
--
To view, visit
http://gerrit.ovirt.org/28455
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4028a70cc8fd3e0599f02ac339a783a7d85f045e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>