Revert "Use vif_type='tap' for LinuxBridge for consistency"

This reverts commit 1b987be2b5.

This probably triggered a race between nova and l2 agent when
hot-detaching VIFs.

Change-Id: I2fc20666d43942446878da358ccf4472e04ad94c
Related-Bug: #1696125
This commit is contained in:
Ihar Hrachyshka 2017-06-08 18:00:39 +00:00
parent 8d9fcb2d30
commit 6ad51779f3
5 changed files with 31 additions and 40 deletions

View File

@ -523,15 +523,25 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
# inherit from the bridge its plugged into, which will be 1500
# at the time. See bug/1684326 for details.
self._set_tap_mtu(tap_device_name, mtu)
# Check if device needs to be added to bridge
if not bridge_lib.BridgeDevice.get_interface_bridge(
tap_device_name):
# Avoid messing with plugging devices into a bridge that the agent
# does not own
if not device_owner.startswith(constants.DEVICE_OWNER_COMPUTE_PREFIX):
# Check if device needs to be added to bridge
if not bridge_lib.BridgeDevice.get_interface_bridge(
tap_device_name):
data = {'tap_device_name': tap_device_name,
'bridge_name': bridge_name}
LOG.debug("Adding device %(tap_device_name)s to bridge "
"%(bridge_name)s", data)
if bridge_lib.BridgeDevice(bridge_name).addif(tap_device_name):
return False
else:
data = {'tap_device_name': tap_device_name,
'device_owner': device_owner,
'bridge_name': bridge_name}
LOG.debug("Adding device %(tap_device_name)s to bridge "
"%(bridge_name)s", data)
if bridge_lib.BridgeDevice(bridge_name).addif(tap_device_name):
return False
LOG.debug("Skip adding device %(tap_device_name)s to "
"%(bridge_name)s. It is owned by %(device_owner)s and "
"thus added elsewhere.", data)
return True
def _set_tap_mtu(self, tap_device_name, mtu):
@ -768,8 +778,8 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
def get_agent_configurations(self):
configurations = {'bridge_mappings': self.bridge_mappings,
'interface_mappings': self.interface_mappings,
'wires_compute_ports': True}
'interface_mappings': self.interface_mappings
}
if self.vxlan_mode != lconst.VXLAN_NONE:
configurations['tunneling_ip'] = self.local_ip
configurations['tunnel_types'] = [p_const.TYPE_VXLAN]

View File

@ -36,7 +36,7 @@ class LinuxbridgeMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
sg_enabled = securitygroups_rpc.is_firewall_enabled()
super(LinuxbridgeMechanismDriver, self).__init__(
constants.AGENT_TYPE_LINUXBRIDGE,
portbindings.VIF_TYPE_TAP,
portbindings.VIF_TYPE_BRIDGE,
{portbindings.CAP_PORT_FILTER: sg_enabled})
lb_qos_driver.register()
@ -50,13 +50,6 @@ class LinuxbridgeMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
**agent['configurations'].get('bridge_mappings', {}))
return mappings
def get_vif_type(self, context, agent, segment):
# TODO(kevinbenton): remove this function after we no longer support
# Ocata agents
if not agent['configurations'].get('wires_compute_ports'):
return portbindings.VIF_TYPE_BRIDGE
return self.vif_type
def check_vlan_transparency(self, context):
"""Linuxbridge driver vlan transparency support."""
return True

View File

@ -527,6 +527,15 @@ class TestLinuxBridgeManager(base.BaseTestCase):
p_const.TYPE_VLAN, "physnet1", None, "tap1",
"foo", None)
def test_add_tap_interface_owner_compute(self):
with mock.patch.object(ip_lib, "device_exists"):
with mock.patch.object(self.lbm, "ensure_local_bridge"):
self.assertTrue(self.lbm.add_tap_interface("123",
p_const.TYPE_LOCAL,
"physnet1", None,
"tap1",
"compute:1", None))
def _test_add_tap_interface(self, dev_owner_prefix):
with mock.patch.object(ip_lib, "device_exists") as de_fn:
de_fn.return_value = False

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
from neutron_lib.api.definitions import portbindings
from neutron_lib import constants
@ -24,14 +22,13 @@ from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base
class LinuxbridgeMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
VIF_TYPE = portbindings.VIF_TYPE_TAP
VIF_TYPE = portbindings.VIF_TYPE_BRIDGE
CAP_PORT_FILTER = True
AGENT_TYPE = constants.AGENT_TYPE_LINUXBRIDGE
GOOD_MAPPINGS = {'fake_physical_network': 'fake_interface'}
GOOD_TUNNEL_TYPES = ['gre', 'vxlan']
GOOD_CONFIGS = {'wires_compute_ports': True,
'interface_mappings': GOOD_MAPPINGS,
GOOD_CONFIGS = {'interface_mappings': GOOD_MAPPINGS,
'tunnel_types': GOOD_TUNNEL_TYPES}
BAD_MAPPINGS = {'wrong_physical_network': 'wrong_interface'}
@ -81,11 +78,3 @@ class LinuxbridgeMechanismVlanTestCase(LinuxbridgeMechanismBaseTestCase,
class LinuxbridgeMechanismGreTestCase(LinuxbridgeMechanismBaseTestCase,
base.AgentMechanismGreTestCase):
pass
class LegacyLinuxbridgeMechanismTestCase(LinuxbridgeMechanismBaseTestCase,
base.AgentMechanismVlanTestCase):
"""An old agent doesn't wire compute ports so it needs VIF_TYPE_BRIDGE."""
VIF_TYPE = portbindings.VIF_TYPE_BRIDGE
AGENTS = copy.deepcopy(LinuxbridgeMechanismBaseTestCase.AGENTS)
AGENTS[0]['configurations'].pop('wires_compute_ports')

View File

@ -1,10 +0,0 @@
---
prelude: >
The Linux Bridge driver now informs Nova to use the 'tap' interface type
to wire interfaces. This requires '/dev/net/tun' to be added to the
'cgroup_device_acl' in 'qemu.conf' before upgrading.
upgrade:
- |
The Linux Bridge driver now informs Nova to use the 'tap' interface type
to wire interfaces. This requires '/dev/net/tun' to be added to the
'cgroup_device_acl' in 'qemu.conf' before upgrading.