← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1531065] [NEW] duplicately fetch subnet_id in get_subnet_for_dvr

 

Public bug reported:

In https://github.com/openstack/neutron/blob/77a6d114eae9de8078b358a9bd8502fb7c393641/neutron/db/dvr_mac_db.py#L159-L163, get_subnet_for_dvr will try to get subnet_id when fixed_ips is not None:
    ...
    def get_subnet_for_dvr(self, context, subnet, fixed_ips=None):
        if fixed_ips:
            subnet_data = fixed_ips[0]['subnet_id']
        else:
            subnet_data = subnet
    ...

But checking its callers :
https://github.com/openstack/neutron/blob/77a6d114eae9de8078b358a9bd8502fb7c393641/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py#L509-L531 , 
and
https://github.com/openstack/neutron/blob/77a6d114eae9de8078b358a9bd8502fb7c393641/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py#L366-L380 , they all have similar logic:
        ...
        fixed_ip = fixed_ips[0]
        ...
        subnet_uuid = fixed_ip['subnet_id']
        ...
            subnet_info = self.plugin_rpc.get_subnet_for_dvr(
                self.context, subnet_uuid, fixed_ips=fixed_ips)

subnet_id has already be fetched and passed into get_subnet_for_dvr. So
in get_subnet_for_dvr, there is no need to fetch again.

** 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/1531065

Title:
  duplicately  fetch subnet_id in get_subnet_for_dvr

Status in neutron:
  New

Bug description:
  In https://github.com/openstack/neutron/blob/77a6d114eae9de8078b358a9bd8502fb7c393641/neutron/db/dvr_mac_db.py#L159-L163, get_subnet_for_dvr will try to get subnet_id when fixed_ips is not None:
      ...
      def get_subnet_for_dvr(self, context, subnet, fixed_ips=None):
          if fixed_ips:
              subnet_data = fixed_ips[0]['subnet_id']
          else:
              subnet_data = subnet
      ...

  But checking its callers :
  https://github.com/openstack/neutron/blob/77a6d114eae9de8078b358a9bd8502fb7c393641/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py#L509-L531 , 
  and
  https://github.com/openstack/neutron/blob/77a6d114eae9de8078b358a9bd8502fb7c393641/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py#L366-L380 , they all have similar logic:
          ...
          fixed_ip = fixed_ips[0]
          ...
          subnet_uuid = fixed_ip['subnet_id']
          ...
              subnet_info = self.plugin_rpc.get_subnet_for_dvr(
                  self.context, subnet_uuid, fixed_ips=fixed_ips)

  subnet_id has already be fetched and passed into get_subnet_for_dvr.
  So in get_subnet_for_dvr, there is no need to fetch again.

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


Follow ups