Notify port_update to agent for status change

Notify agents about port update when "port_update" is called to update
port's status change. L3 agent will spawn keepalived only when HA
network port status is ACTIVE. When L3 agent is restarted, it sets HA
network port status to DOWN (through "port_update"), with the assumption
that L2 agent will again rewire the port (set status to ACTIVE) allowing
L3 agent to spawn keepalived. As server is not notifying L2 agent, port
is remaining in DOWN status and L3 agent was never spawning keepalived
on L3 agent restart(if keepalived is killed).

Closes-Bug: 1723848
Change-Id: I629eeff905bf02ec5f7ee68cccc7c19f1b47d5aa
(cherry picked from commit 4f9a6a8b76)
This commit is contained in:
venkata anil 2017-10-16 06:03:35 +00:00
parent dde92f0472
commit 11254ef87b
2 changed files with 12 additions and 0 deletions

View File

@ -1410,6 +1410,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
if original_port['admin_state_up'] != updated_port['admin_state_up']:
need_port_update_notify = True
if original_port['status'] != updated_port['status']:
need_port_update_notify = True
# NOTE: In the case of DVR ports, the port-binding is done after
# router scheduling when sync_routers is called and so this call
# below may not be required for DVR routed interfaces. But still

View File

@ -808,6 +808,16 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
self.assertEqual('DOWN', port['port']['status'])
self.assertEqual('DOWN', self.port_create_status)
def test_notify_port_updated_for_status_change(self):
ctx = context.get_admin_context()
plugin = directory.get_plugin()
with self.port() as port:
with mock.patch.object(self.plugin,
'_notify_port_updated') as notify_mock:
port['port']['status'] = constants.PORT_STATUS_ACTIVE
plugin.update_port(ctx, port['port']['id'], port)
self.assertTrue(notify_mock.called)
def test_update_port_status_short_id(self):
ctx = context.get_admin_context()
plugin = directory.get_plugin()