]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
lb-agent: handle security group updates in main loop
authorDarragh O'Reilly <darragh.oreilly@hp.com>
Tue, 2 Dec 2014 18:28:38 +0000 (18:28 +0000)
committerDarragh O'Reilly <darragh.oreilly@hp.com>
Sat, 27 Jun 2015 05:34:19 +0000 (05:34 +0000)
Patch I1574544734865506ff5383404516cc9349c16ec4 introduced deferring
firewall refreshes to the main loop of the ovs-agent to improve
performance. This patch enables the same on the linuxbridge agent.

Change-Id: Ia8fe229910d2be718da52cb341be163b86ace571
Closes-Bug: #1368281

neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py

index 66be308a29ae5fe5c52ceca3fd930f94d23ebdab..d539fe38f91ddf56bdf383112fafacf5f88547db 100644 (file)
@@ -788,7 +788,7 @@ class LinuxBridgeNeutronAgentRPC(service.Service):
         self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
         self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
         self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context,
-                self.sg_plugin_rpc)
+                self.sg_plugin_rpc, defer_refresh_firewall=True)
         self.setup_rpc(self.interface_mappings.values())
         self.daemon_loop()
 
@@ -859,11 +859,8 @@ class LinuxBridgeNeutronAgentRPC(service.Service):
         resync_a = False
         resync_b = False
 
-        self.sg_agent.prepare_devices_filter(device_info.get('added'))
-
-        if device_info.get('updated'):
-            self.sg_agent.refresh_firewall()
-
+        self.sg_agent.setup_port_filters(device_info.get('added'),
+                                         device_info.get('updated'))
         # Updated devices are processed the same as new ones, as their
         # admin_state_up may have changed. The set union prevents duplicating
         # work when a device is new and updated in the same polling iteration.
@@ -1011,7 +1008,8 @@ class LinuxBridgeNeutronAgentRPC(service.Service):
                 LOG.info(_LI("Agent out of sync with plugin!"))
                 sync = False
 
-            if self._device_info_has_changes(device_info):
+            if (self._device_info_has_changes(device_info)
+                or self.sg_agent.firewall_refresh_needed()):
                 LOG.debug("Agent loop found changes! %s", device_info)
                 try:
                     sync = self.process_network_devices(device_info)
index 8651a14d8ffb207e0f05033e74c784bf2e75f6bd..134b313eef880ddb8fe64616a209d230afb4a051 100644 (file)
@@ -279,16 +279,15 @@ class TestLinuxBridgeAgent(base.BaseTestCase):
                        'added': set(['tap3', 'tap4']),
                        'updated': set(['tap2', 'tap3']),
                        'removed': set(['tap1'])}
-        agent.sg_agent.prepare_devices_filter = mock.Mock()
-        agent.sg_agent.refresh_firewall = mock.Mock()
+        agent.sg_agent.setup_port_filters = mock.Mock()
         agent.treat_devices_added_updated = mock.Mock(return_value=False)
         agent.treat_devices_removed = mock.Mock(return_value=False)
 
         agent.process_network_devices(device_info)
 
-        agent.sg_agent.prepare_devices_filter.assert_called_with(
-                set(['tap3', 'tap4']))
-        self.assertTrue(agent.sg_agent.refresh_firewall.called)
+        agent.sg_agent.setup_port_filters.assert_called_with(
+                device_info['added'],
+                device_info['updated'])
         agent.treat_devices_added_updated.assert_called_with(set(['tap2',
                                                                   'tap3',
                                                                   'tap4']))