Merge "Don't add duplicate metadata rules after router update" into stable/newton
This commit is contained in:
commit
4c02ef2a1c
@ -170,8 +170,14 @@ def after_router_added(resource, event, l3_agent, **kwargs):
|
|||||||
def after_router_updated(resource, event, l3_agent, **kwargs):
|
def after_router_updated(resource, event, l3_agent, **kwargs):
|
||||||
router = kwargs['router']
|
router = kwargs['router']
|
||||||
proxy = l3_agent.metadata_driver
|
proxy = l3_agent.metadata_driver
|
||||||
if not proxy.monitors.get(router.router_id):
|
if (not proxy.monitors.get(router.router_id) and
|
||||||
after_router_added(resource, event, l3_agent, **kwargs)
|
not isinstance(router, ha_router.HaRouter)):
|
||||||
|
proxy.spawn_monitored_metadata_proxy(
|
||||||
|
l3_agent.process_monitor,
|
||||||
|
router.ns_name,
|
||||||
|
proxy.metadata_port,
|
||||||
|
l3_agent.conf,
|
||||||
|
router_id=router.router_id)
|
||||||
|
|
||||||
|
|
||||||
def before_router_removed(resource, event, l3_agent, **kwargs):
|
def before_router_removed(resource, event, l3_agent, **kwargs):
|
||||||
|
@ -21,6 +21,7 @@ from neutron.agent.common import config as agent_config
|
|||||||
from neutron.agent.l3 import agent as l3_agent
|
from neutron.agent.l3 import agent as l3_agent
|
||||||
from neutron.agent.l3 import ha as l3_ha_agent
|
from neutron.agent.l3 import ha as l3_ha_agent
|
||||||
from neutron.agent.l3 import router_info
|
from neutron.agent.l3 import router_info
|
||||||
|
from neutron.agent.linux import iptables_manager
|
||||||
from neutron.agent.metadata import config
|
from neutron.agent.metadata import config
|
||||||
from neutron.agent.metadata import driver as metadata_driver
|
from neutron.agent.metadata import driver as metadata_driver
|
||||||
from neutron.common import constants
|
from neutron.common import constants
|
||||||
@ -93,6 +94,24 @@ class TestMetadataDriverProcess(base.BaseTestCase):
|
|||||||
f.assert_called_once_with(
|
f.assert_called_once_with(
|
||||||
'router', 'after_update', agent, router=ri)
|
'router', 'after_update', agent, router=ri)
|
||||||
|
|
||||||
|
def test_after_router_updated_should_not_call_add_metadata_rules(self):
|
||||||
|
with mock.patch.object(iptables_manager.IptablesTable,
|
||||||
|
'add_rule') as f,\
|
||||||
|
mock.patch.object(iptables_manager.IptablesManager,
|
||||||
|
'apply'),\
|
||||||
|
mock.patch.object(metadata_driver.MetadataDriver,
|
||||||
|
'spawn_monitored_metadata_proxy'),\
|
||||||
|
mock.patch.object(router_info.RouterInfo, 'process'):
|
||||||
|
agent = l3_agent.L3NATAgent('localhost')
|
||||||
|
router_id = _uuid()
|
||||||
|
router = {'id': router_id}
|
||||||
|
ri = router_info.RouterInfo(router_id, router,
|
||||||
|
agent.conf, mock.ANY)
|
||||||
|
agent.router_info[router_id] = ri
|
||||||
|
f.reset_mock()
|
||||||
|
agent._process_updated_router(router)
|
||||||
|
f.assert_not_called()
|
||||||
|
|
||||||
def _test_spawn_metadata_proxy(self, expected_user, expected_group,
|
def _test_spawn_metadata_proxy(self, expected_user, expected_group,
|
||||||
user='', group='', watch_log=True):
|
user='', group='', watch_log=True):
|
||||||
router_id = _uuid()
|
router_id = _uuid()
|
||||||
|
Loading…
Reference in New Issue
Block a user