Public bug reported:

in method unbind_router_servicenode, it will check if there is still any
dvr serviced port exist on node, by getting all ports on host that
related to given router:

            for subnet in subnet_ids:
                ports = (
                    self._core_plugin.get_ports_on_host_by_subnet(
                        context, host, subnet))
                for port in ports:
                    if (n_utils.is_dvr_serviced(port['device_owner'])):
                        port_found = True
                        LOG.debug('One or more ports exist on the snat '
                                  'enabled l3_agent host %(host)s and '
                                  'router_id %(id)s',
                                  {'host': host, 'id': router_id})
                        break
https://github.com/openstack/neutron/blob/master/neutron/db/l3_dvrscheduler_db.py#L293-L303

but the logic in inner for loop here is duplicated and unnecessary, since 
get_ports_on_host_by_subnet will get all dvr serviced ports already, so it 
doesn't need to check again.
in get_ports_on_host_by_subnet:

        for port in ports:
            device_owner = port['device_owner']
            if (utils.is_dvr_serviced(device_owner)):
                if port[portbindings.HOST_ID] == host:
                    port_dict = self.plugin._make_port_dict(port,
                        process_extensions=False)
                    ports_by_host.append(port_dict)

https://github.com/openstack/neutron/blob/master/neutron/db/dvr_mac_db.py#L128-L156

** Affects: neutron
     Importance: Undecided
     Assignee: ZongKai LI (lzklibj)
         Status: New

** Changed in: neutron
     Assignee: (unassigned) => ZongKai LI (lzklibj)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1527049

Title:
  is_dvr_serviced in unbind_router_servicenode is duplicated and
  unnecessary

Status in neutron:
  New

Bug description:
  in method unbind_router_servicenode, it will check if there is still
  any dvr serviced port exist on node, by getting all ports on host that
  related to given router:

              for subnet in subnet_ids:
                  ports = (
                      self._core_plugin.get_ports_on_host_by_subnet(
                          context, host, subnet))
                  for port in ports:
                      if (n_utils.is_dvr_serviced(port['device_owner'])):
                          port_found = True
                          LOG.debug('One or more ports exist on the snat '
                                    'enabled l3_agent host %(host)s and '
                                    'router_id %(id)s',
                                    {'host': host, 'id': router_id})
                          break
  
https://github.com/openstack/neutron/blob/master/neutron/db/l3_dvrscheduler_db.py#L293-L303

  but the logic in inner for loop here is duplicated and unnecessary, since 
get_ports_on_host_by_subnet will get all dvr serviced ports already, so it 
doesn't need to check again.
  in get_ports_on_host_by_subnet:

          for port in ports:
              device_owner = port['device_owner']
              if (utils.is_dvr_serviced(device_owner)):
                  if port[portbindings.HOST_ID] == host:
                      port_dict = self.plugin._make_port_dict(port,
                          process_extensions=False)
                      ports_by_host.append(port_dict)

  
https://github.com/openstack/neutron/blob/master/neutron/db/dvr_mac_db.py#L128-L156

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1527049/+subscriptions

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to