Don't trigger DVR port update if status the same
The DVR path was missing logic to avoid triggering DB updates even if the status was already correct. This was leading to a constant back-and-forth updating between the agent and the server effectively not changing anything but the updated_at timestamp and the revision_number. Closes-Bug: #1716522 Change-Id: I88c678ac8a562db91c71edbc71dc43d1ada6c452
This commit is contained in:
parent
3e341a9941
commit
1edd0c7924
|
@ -1749,8 +1749,9 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||||
context, port['id'], host)
|
context, port['id'], host)
|
||||||
if not binding:
|
if not binding:
|
||||||
return
|
return
|
||||||
binding.status = status
|
if binding.status != status:
|
||||||
updated = True
|
binding.status = status
|
||||||
|
updated = True
|
||||||
|
|
||||||
if (updated and
|
if (updated and
|
||||||
port['device_owner'] == const.DEVICE_OWNER_DVR_INTERFACE):
|
port['device_owner'] == const.DEVICE_OWNER_DVR_INTERFACE):
|
||||||
|
|
|
@ -1269,6 +1269,35 @@ class TestMl2PortsV2WithRevisionPlugin(Ml2PluginV2TestCase):
|
||||||
self.assertGreater(updated_ports[0]['revision_number'],
|
self.assertGreater(updated_ports[0]['revision_number'],
|
||||||
created_ports[0]['revision_number'])
|
created_ports[0]['revision_number'])
|
||||||
|
|
||||||
|
def test_update_port_status_dvr_port_no_update_on_same_status(self):
|
||||||
|
ctx = context.get_admin_context()
|
||||||
|
plugin = directory.get_plugin()
|
||||||
|
# enable subscription for events
|
||||||
|
p_update_receiver = mock.Mock()
|
||||||
|
registry.subscribe(p_update_receiver, resources.PORT,
|
||||||
|
events.AFTER_UPDATE)
|
||||||
|
host_arg = {portbindings.HOST_ID: HOST}
|
||||||
|
with self.port(device_owner=constants.DEVICE_OWNER_DVR_INTERFACE,
|
||||||
|
device_id=TEST_ROUTER_ID,
|
||||||
|
arg_list=(portbindings.HOST_ID,),
|
||||||
|
**host_arg) as port:
|
||||||
|
ml2_db.ensure_distributed_port_binding(ctx, port['port']['id'],
|
||||||
|
HOST)
|
||||||
|
p_update_receiver.reset_mock()
|
||||||
|
plugin.update_port_status(
|
||||||
|
ctx, port['port']['id'],
|
||||||
|
constants.PORT_STATUS_ACTIVE, host=HOST)
|
||||||
|
self.assertTrue(p_update_receiver.called)
|
||||||
|
after_1 = plugin.get_port(ctx, port['port']['id'])
|
||||||
|
p_update_receiver.reset_mock()
|
||||||
|
plugin.update_port_status(
|
||||||
|
ctx, port['port']['id'],
|
||||||
|
constants.PORT_STATUS_ACTIVE, host=HOST)
|
||||||
|
self.assertFalse(p_update_receiver.called)
|
||||||
|
after_2 = plugin.get_port(ctx, port['port']['id'])
|
||||||
|
self.assertEqual(after_1['revision_number'],
|
||||||
|
after_2['revision_number'])
|
||||||
|
|
||||||
|
|
||||||
class TestMl2PortsV2WithL3(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
|
class TestMl2PortsV2WithL3(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
|
||||||
"""For testing methods that require the L3 service plugin."""
|
"""For testing methods that require the L3 service plugin."""
|
||||||
|
|
Loading…
Reference in New Issue