Merge "improve dvr port update under large scale deployment" into stable/queens
This commit is contained in:
commit
5dae33de0e
|
@ -13,6 +13,8 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import collections
|
||||||
|
|
||||||
from neutron_lib.api.definitions import portbindings
|
from neutron_lib.api.definitions import portbindings
|
||||||
from neutron_lib.callbacks import events
|
from neutron_lib.callbacks import events
|
||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
|
@ -133,19 +135,22 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
|
||||||
for router_id in router_ids:
|
for router_id in router_ids:
|
||||||
hosts |= set(self.get_hosts_to_notify(context, router_id))
|
hosts |= set(self.get_hosts_to_notify(context, router_id))
|
||||||
|
|
||||||
for host in hosts:
|
host_routers = collections.defaultdict(set)
|
||||||
updated_routers = set()
|
for router_id in router_ids:
|
||||||
for router_id in router_ids:
|
# avoid calling get_ports in host loop
|
||||||
|
subnet_ids = self.get_subnet_ids_on_router(
|
||||||
|
context.elevated(), router_id)
|
||||||
|
for host in hosts:
|
||||||
LOG.debug('DVR: Handle new service port, host %(host)s, '
|
LOG.debug('DVR: Handle new service port, host %(host)s, '
|
||||||
'router ids %(router_id)s',
|
'router ids %(router_id)s',
|
||||||
{'host': host, 'router_id': router_id})
|
{'host': host, 'router_id': router_id})
|
||||||
if self._check_for_rtr_serviceable_ports(
|
if self._check_dvr_serviceable_ports_on_host(
|
||||||
context.elevated(), router_id, host):
|
context.elevated(), host, subnet_ids):
|
||||||
updated_routers.add(router_id)
|
host_routers[host].add(router_id)
|
||||||
|
|
||||||
if updated_routers:
|
for host, router_ids in host_routers.items():
|
||||||
self.l3_rpc_notifier.routers_updated_on_host(
|
self.l3_rpc_notifier.routers_updated_on_host(
|
||||||
context, updated_routers, host)
|
context, router_ids, host)
|
||||||
|
|
||||||
def get_dvr_snat_agent_list(self, context):
|
def get_dvr_snat_agent_list(self, context):
|
||||||
agent_filters = {'agent_modes': [n_const.L3_AGENT_MODE_DVR_SNAT]}
|
agent_filters = {'agent_modes': [n_const.L3_AGENT_MODE_DVR_SNAT]}
|
||||||
|
@ -349,7 +354,7 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
|
||||||
Port.device_owner.in_(
|
Port.device_owner.in_(
|
||||||
n_utils.get_other_dvr_serviced_device_owners()))
|
n_utils.get_other_dvr_serviced_device_owners()))
|
||||||
query = query.filter(owner_filter)
|
query = query.filter(owner_filter)
|
||||||
hosts = [item[0] for item in query]
|
hosts = [item[0] for item in query if item[0] != '']
|
||||||
return hosts
|
return hosts
|
||||||
|
|
||||||
def _get_dvr_subnet_ids_on_host_query(self, context, host):
|
def _get_dvr_subnet_ids_on_host_query(self, context, host):
|
||||||
|
|
|
@ -1234,9 +1234,9 @@ class L3DvrSchedulerTestCase(L3SchedulerBaseMixin,
|
||||||
return_value=[agent_on_host]) as get_l3_agents,\
|
return_value=[agent_on_host]) as get_l3_agents,\
|
||||||
mock.patch.object(
|
mock.patch.object(
|
||||||
self.dut, 'get_hosts_to_notify',
|
self.dut, 'get_hosts_to_notify',
|
||||||
return_value=['other_host']),\
|
return_value=['other_host', 'host1']),\
|
||||||
mock.patch.object(
|
mock.patch.object(
|
||||||
self.dut, '_check_for_rtr_serviceable_ports',
|
self.dut, '_check_dvr_serviceable_ports_on_host',
|
||||||
return_value=True):
|
return_value=True):
|
||||||
|
|
||||||
self.dut.dvr_handle_new_service_port(
|
self.dut.dvr_handle_new_service_port(
|
||||||
|
|
Loading…
Reference in New Issue