Merge "Ensure dvr ha router gateway port binding host" into stable/queens

This commit is contained in:
Zuul 2019-05-20 22:51:23 +00:00 committed by Gerrit Code Review
commit 22ee94d32a
3 changed files with 35 additions and 1 deletions

View File

@ -145,7 +145,8 @@ class L3RpcCallback(object):
self._ensure_host_set_on_port(context,
gw_port_host,
router.get('gw_port'),
router['id'])
router['id'],
ha_router_port=router.get('ha'))
for p in router.get(n_const.SNAT_ROUTER_INTF_KEY, []):
self._ensure_host_set_on_port(
context, gw_port_host, p, router['id'],
@ -185,6 +186,10 @@ class L3RpcCallback(object):
# All ports, including ports created for SNAT'ing for
# DVR are handled here
try:
LOG.debug("Updating router %(router)s port %(port)s "
"binding host %(host)s",
{"router": router_id, "port": port['id'],
"host": host})
self.plugin.update_port(
context,
port['id'],
@ -211,6 +216,10 @@ class L3RpcCallback(object):
# port binding will be corrected when an active is
# elected.
try:
LOG.debug("Updating router %(router)s port %(port)s "
"binding host %(host)s",
{"router": router_id, "port": port['id'],
"host": host})
self.plugin.update_port(
context,
port['id'],

View File

@ -723,6 +723,16 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
ha_binding_agent.host == gateway_port_binding_host):
return ha_binding_agent.host
LOG.debug("No gateway port host retrieved. HA router %(router_id)s "
"gateway port %(gw_port_id)s "
"binding host: %(host)s, status: %(status)s, "
"router HA bindings: %(ha_bindings)s",
{"router_id": router_id,
"gw_port_id": gateway_port['id'],
"host": gateway_port_binding_host,
"status": gateway_port_status,
"ha_bindings": ha_bindings})
def is_ha_router(router):
"""Return True if router to be handled is ha."""

View File

@ -3956,6 +3956,21 @@ class L3RpcCallbackTestCase(base.BaseTestCase):
actual_message = mock_log.call_args[0][0] % mock_log.call_args[0][1]
self.assertEqual(expected_message, actual_message)
def test__ensure_host_set_on_ports_dvr_ha_router_with_gatway(self):
context = mock.Mock()
host = "fake_host"
router_id = 'foo_router_id'
router = {"id": router_id,
"gw_port_host": host,
"gw_port": {"id": "foo_port_id"},
"distributed": True,
"ha": True}
mock__ensure = mock.Mock()
self.l3_rpc_cb._ensure_host_set_on_port = mock__ensure
self.l3_rpc_cb._ensure_host_set_on_ports(context, host, [router])
mock__ensure.assert_called_once_with(
context, host, router["gw_port"], router_id, ha_router_port=True)
class L3AgentDbIntTestCase(L3BaseForIntTests, L3AgentDbTestCaseBase):