Fix 404 error fetching metadata when using DVR

The metadata agent was unable to find networks
attached to the DVR router because it was only
filtering ports for 'centralized' routers.

To fix the issue, this patch expands the search
filters to include DVR router interfaces during
the network lookup operation.

The extra filter cause no evident performance
loss while serving the request; a different
approach would require to pass the router type
around to narrow down the search filter, but it
sounds like an overkill.

Closes-bug: #1353271

Change-Id: Iefbefa1ff300adad48ab9fc472d5eb1913fbe488
This commit is contained in:
armando-migliaccio 2014-08-06 10:13:32 -07:00
parent 9bc3812687
commit e10037b4ae
2 changed files with 11 additions and 4 deletions

View File

@ -144,7 +144,8 @@ class MetadataProxyHandler(object):
internal_ports = qclient.list_ports(
device_id=router_id,
device_owner=n_const.DEVICE_OWNER_ROUTER_INTF)['ports']
device_owner=[n_const.DEVICE_OWNER_ROUTER_INTF,
n_const.DEVICE_OWNER_DVR_INTERFACE])['ports']
return tuple(p['network_id'] for p in internal_ports)
@utils.cache_method_results

View File

@ -27,6 +27,12 @@ from neutron.common import utils
from neutron.tests import base
EXPECTED_OWNER_ROUTERS = [
constants.DEVICE_OWNER_ROUTER_INTF,
constants.DEVICE_OWNER_DVR_INTERFACE
]
class FakeConf(object):
admin_user = 'neutron'
admin_password = 'password'
@ -104,7 +110,7 @@ class TestMetadataProxyHandlerCache(base.BaseTestCase):
networks = self.handler._get_router_networks(router_id)
mock_list_ports.assert_called_once_with(
device_id=router_id,
device_owner=constants.DEVICE_OWNER_ROUTER_INTF)
device_owner=EXPECTED_OWNER_ROUTERS)
self.assertEqual(expected, networks)
def _test_get_router_networks_twice_helper(self):
@ -119,7 +125,7 @@ class TestMetadataProxyHandlerCache(base.BaseTestCase):
networks = self.handler._get_router_networks(router_id)
mock_list_ports.assert_called_once_with(
device_id=router_id,
device_owner=constants.DEVICE_OWNER_ROUTER_INTF)
device_owner=EXPECTED_OWNER_ROUTERS)
self.assertEqual(expected_networks, networks)
networks = self.handler._get_router_networks(router_id)
@ -232,7 +238,7 @@ class TestMetadataProxyHandlerCache(base.BaseTestCase):
new_qclient_call,
mock.call().list_ports(
device_id=router_id,
device_owner=constants.DEVICE_OWNER_ROUTER_INTF
device_owner=EXPECTED_OWNER_ROUTERS
)
])