Revert "Create notifications for dependent ports"
This reverts commit 0c18b43893
.
Change-Id: I4d5c74d6c0329a5cbeb2205bb8a11920071a1d8d
This commit is contained in:
parent
b0d38c4342
commit
4907620836
|
@ -48,7 +48,6 @@ from neutron.plugins.ml2 import driver_api as api
|
|||
from neutron.plugins.ml2 import driver_context as ml2_context
|
||||
from neutron.plugins.ml2 import models
|
||||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib.api.definitions import provider_net as provider
|
||||
from neutron_lib import constants as n_constants
|
||||
from neutron_lib import context as nctx
|
||||
from neutron_lib import exceptions as n_exceptions
|
||||
|
@ -438,37 +437,6 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
|||
if not self.aim.get(aim_ctx, ap):
|
||||
self.aim.create(aim_ctx, ap)
|
||||
|
||||
def _is_dependent_port_change(self, port):
|
||||
# For now, we are only handling changes to DHCP
|
||||
# ports and LBaaS ports. This can be expanded in
|
||||
# the future to handle other changes, if needed
|
||||
return bool(port and any(port['device_owner'].startswith(x) for x in
|
||||
(n_constants.DEVICE_OWNER_DHCP,
|
||||
n_constants.DEVICE_OWNER_LOADBALANCERV2)))
|
||||
|
||||
def _notify_if_dependent_port_change(self, context, port):
|
||||
# Under some scenarios, opflex agents might not get
|
||||
# triggers to update EP files, even though parameters
|
||||
# contained in the files have changed (e.g. metadata
|
||||
# route when using HA DHCP). We ensure that the EP files
|
||||
# get updated by triggering port update notifications
|
||||
# to the agents, which tells them to go get all their EP
|
||||
# files for the ports they own on that network.
|
||||
if self._is_dependent_port_change(port):
|
||||
plugin_context = context._plugin_context
|
||||
net = self.plugin.get_network(plugin_context, port['network_id'])
|
||||
# Notifications are only needed to opflex networks, which will
|
||||
# have opflex agents
|
||||
if not net or not self._is_opflex_type(net[provider.NETWORK_TYPE]):
|
||||
return
|
||||
|
||||
filters = {'network_id': [net['id']]}
|
||||
ports_to_update = self.plugin.get_ports(plugin_context, filters)
|
||||
# Exclude ports that triggered this notification
|
||||
affected_port_ids = [p['id'] for p in ports_to_update
|
||||
if not self._is_dependent_port_change(p)]
|
||||
self._notify_port_update_bulk(plugin_context, affected_port_ids)
|
||||
|
||||
def _get_unique_domains(self, mappings):
|
||||
domains = []
|
||||
unique_domains = set()
|
||||
|
@ -1883,8 +1851,6 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
|||
context.bottom_bound_segment,
|
||||
context.host
|
||||
)
|
||||
# REVISIT: it may be possible to move this to the precommit
|
||||
self._notify_if_dependent_port_change(context, port)
|
||||
|
||||
def delete_port_precommit(self, context):
|
||||
port = context.current
|
||||
|
@ -2042,8 +2008,6 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
|||
context.bottom_bound_segment,
|
||||
context.host
|
||||
)
|
||||
# REVISIT: it may be possible to move this to the precommit
|
||||
self._notify_if_dependent_port_change(context, port)
|
||||
|
||||
def create_floatingip(self, context, current):
|
||||
if current['port_id']:
|
||||
|
|
|
@ -330,10 +330,9 @@ class ApicAimTestCase(test_address_scope.AddressScopeTestCase,
|
|||
self.fmt)
|
||||
return self.deserialize(self.fmt, req.get_response(self.api))
|
||||
|
||||
def _bind_other_port_to_host(self, port_id, host,
|
||||
owner=n_constants.DEVICE_OWNER_DHCP):
|
||||
def _bind_dhcp_port_to_host(self, port_id, host):
|
||||
data = {'port': {'binding:host_id': host,
|
||||
'device_owner': owner,
|
||||
'device_owner': 'network:dhcp',
|
||||
'device_id': 'someid'}}
|
||||
# Create EP with bound port
|
||||
req = self.new_update_request('ports', data, port_id,
|
||||
|
@ -4030,45 +4029,6 @@ class TestPortBinding(ApicAimTestCase):
|
|||
port['binding:vif_details'])
|
||||
self.assertEqual(n_constants.PORT_STATUS_ACTIVE, port['status'])
|
||||
|
||||
def test_bind_dependent_port_triggers_port_notify(self):
|
||||
# Test that a port update to a DHCP or LBaaS port triggers a
|
||||
# port update notification to a compute port on the same net,
|
||||
# but not to a compute port on a different net
|
||||
self._register_agent('host1', AGENT_CONF_OPFLEX)
|
||||
self._register_agent('host2', AGENT_CONF_OPFLEX)
|
||||
net1 = self._make_network(self.fmt, 'net1', True)
|
||||
self._make_subnet(self.fmt, net1, '10.0.1.1', '10.0.1.0/24')
|
||||
net2 = self._make_network(self.fmt, 'net2', True)
|
||||
self._make_subnet(self.fmt, net1, '20.0.1.1', '20.0.1.0/24')
|
||||
|
||||
p1 = self._make_port(self.fmt, net1['network']['id'])['port']
|
||||
p1 = self._bind_port_to_host(p1['id'], 'host1')['port']
|
||||
self.assertEqual(net1['network']['id'], p1['network_id'])
|
||||
self.assertEqual('ovs', p1['binding:vif_type'])
|
||||
self.assertEqual({'port_filter': False, 'ovs_hybrid_plug': False},
|
||||
p1['binding:vif_details'])
|
||||
p2 = self._make_port(self.fmt, net2['network']['id'])['port']
|
||||
p2 = self._bind_port_to_host(p2['id'], 'host2')['port']
|
||||
self.assertEqual(net2['network']['id'], p2['network_id'])
|
||||
self.assertEqual('ovs', p2['binding:vif_type'])
|
||||
self.assertEqual({'port_filter': False, 'ovs_hybrid_plug': False},
|
||||
p2['binding:vif_details'])
|
||||
with mock.patch.object(self.driver,
|
||||
'_notify_port_update_bulk') as notify:
|
||||
p3 = self._make_port(self.fmt, net1['network']['id'],
|
||||
device_owner=n_constants.DEVICE_OWNER_DHCP)['port']
|
||||
p3 = self._bind_other_port_to_host(p3['id'], 'host1',
|
||||
owner=n_constants.DEVICE_OWNER_DHCP)['port']
|
||||
mock_calls = [mock.call(mock.ANY, p1['id']),
|
||||
mock.call(mock.ANY, p1['id'])]
|
||||
notify.has_calls(mock_calls)
|
||||
notify.reset_mock()
|
||||
p4 = self._make_port(self.fmt, net1['network']['id'],
|
||||
device_owner=n_constants.DEVICE_OWNER_LOADBALANCERV2)['port']
|
||||
p4 = self._bind_other_port_to_host(p4['id'], 'host1',
|
||||
owner=n_constants.DEVICE_OWNER_LOADBALANCERV2)['port']
|
||||
notify.has_calls(mock_calls)
|
||||
|
||||
# TODO(rkukura): Add tests for opflex, local and unsupported
|
||||
# network_type values.
|
||||
|
||||
|
@ -4166,7 +4126,7 @@ class TestPortBindingDvs(ApicAimTestCase):
|
|||
self.driver.dvs_notifier.reset_mock()
|
||||
p2 = self._make_port(self.fmt, net['network']['id'])['port']
|
||||
self.assertEqual(net['network']['id'], p2['network_id'])
|
||||
newp2 = self._bind_other_port_to_host(p2['id'], 'h1')
|
||||
newp2 = self._bind_dhcp_port_to_host(p2['id'], 'h1')
|
||||
# Called on the network's tenant
|
||||
vif_det = newp2['port']['binding:vif_details']
|
||||
self.assertIsNone(vif_det.get('dvs_port_group_name', None))
|
||||
|
@ -4202,7 +4162,7 @@ class TestPortBindingDvs(ApicAimTestCase):
|
|||
p2 = self._make_port(self.fmt, net['network']['id'])['port']
|
||||
self.assertEqual(net['network']['id'], p2['network_id'])
|
||||
# Bind port to trigger path binding
|
||||
newp2 = self._bind_other_port_to_host(p2['id'], 'h1')
|
||||
newp2 = self._bind_dhcp_port_to_host(p2['id'], 'h1')
|
||||
# Called on the network's tenant
|
||||
vif_det = newp2['port']['binding:vif_details']
|
||||
self.assertIsNone(vif_det.get('dvs_port_group_name', None))
|
||||
|
|
Loading…
Reference in New Issue