Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Cloud:OpenStack:Newton:Staging
openstack-neutron
0001-Fixing-the-filter-in-get-MTU-by-network-li...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Fixing-the-filter-in-get-MTU-by-network-list-query.patch of Package openstack-neutron
From bb361e59ed418f17d558e5a5956ced523429dfcf Mon Sep 17 00:00:00 2001 From: Vadim ponomarev <velizarx@gmail.com> Date: Mon, 12 Feb 2018 16:48:29 +0300 Subject: [PATCH] Fixing the filter in get MTU by network list query. Based on the observation that a call to sync_routers can be slow (10-15 seconds for one virtual router), and that profiling data show that a significant amount of time is spent in function _get_mtus_by_network_list, this change fixes incorrect the database query for getting information about networks. What changed: - before: SQL query spent time O(#networks in database) (select all exists networks from database) - after : SQL query spent time O(#network_ids passed to the function) (select only needed networks) A basic test shows a drastic improvements, from 2 second to around ~0.2 second, in the processing of a _get_mtus_by_network_list call with 300 networks in database. Change-Id: Id50d1aaddd0d2a1110502de9c5b974063daa296a Closes-Bug: #1748888 (cherry picked from commit d15244ab4f2562b46c5fbdb6ccebe18f66e5a579) (cherry picked from commit 7c5a5631eba520601039e21b8b51e30f6d29e667) --- neutron/db/l3_db.py | 2 +- neutron/tests/unit/db/test_l3_db.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index 2f2cde2ca1..9f024e260a 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -1661,7 +1661,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase, def _get_mtus_by_network_list(self, context, network_ids): if not network_ids: return {} - filters = {'network_id': network_ids} + filters = {'id': network_ids} fields = ['id', 'mtu'] networks = self._core_plugin.get_networks(context, filters=filters, fields=fields) diff --git a/neutron/tests/unit/db/test_l3_db.py b/neutron/tests/unit/db/test_l3_db.py index 44d5a34724..ec6dc3132d 100644 --- a/neutron/tests/unit/db/test_l3_db.py +++ b/neutron/tests/unit/db/test_l3_db.py @@ -70,6 +70,22 @@ class TestL3_NAT_dbonly_mixin(base.BaseTestCase): 'address_scope_id': mock.sentinel.address_scope_id, 'network_id': mock.sentinel.network_id}]}, subnets) + def test__get_mtus_by_network_list(self): + """Basic test that the query get_networks is correctly""" + network = {'id': mock.sentinel.network_id, + 'name': mock.sentinel.name, + 'mtu': mock.sentinel.mtu} + with mock.patch.object(directory, 'get_plugin') as get_p: + get_p().get_networks.return_value = [network] + result = self.db._get_mtus_by_network_list( + mock.sentinel.context, [mock.sentinel.network_id]) + get_p().get_networks.assert_called_once_with( + mock.sentinel.context, + filters={'id': [mock.sentinel.network_id]}, + fields=['id', 'mtu']) + self.assertEqual({mock.sentinel.network_id: mock.sentinel.mtu}, + result) + def test__populate_ports_for_subnets_none(self): """Basic test that the method runs correctly with no ports""" ports = [] -- 2.19.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor