← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1778870] [NEW] flaws in neutronv2's _get_port_id_by_fixed_address method

 

Public bug reported:

Problem description:
When doing associcate-floating-ip to an instance, we will call the following method
https://github.com/openstack/nova/blob/master/nova/network/neutronv2/api.py#L1869
def _get_port_id_by_fixed_address(self, client,
                                      instance, address):
        """Return port_id from a fixed address."""
        zone = 'compute:%s' % instance.availability_zone
        search_opts = {'device_id': instance.uuid,
                       'device_owner': zone}
        data = client.list_ports(**search_opts)
        ports = data['ports']
        port_id = None
        for p in ports:
            for ip in p['fixed_ips']:
                if ip['ip_address'] == address:
                    port_id = p['id']
                    break
        if not port_id:
            raise exception.FixedIpNotFoundForAddress(address=address)
        return port_id
 
to get the port id from the fixed ip the floating ip is to be associated with.
This method will return the last matched port that has the provided fixed ip, only neglecting
the fact that multiple ports can satisfy the condition.

That is, we can
1. create an instance on subnetA with allocated fixed ip 10.0.0.2/24 (portA)
2. create a portB on subnetB with fixed ip 10.0.0.2/24
3. associate portB to the instance
then the instance has portA and portB with the same address 10.0.0.2/24 on it.

Desired outcome:
The method _get_port_id_by_fixed_address should be aware of this circumstance and address
it in some way.

** Affects: nova
     Importance: Undecided
     Assignee: Chen (chenn2)
         Status: New

** Changed in: nova
     Assignee: (unassigned) => Chen (chenn2)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1778870

Title:
  flaws in neutronv2's _get_port_id_by_fixed_address method

Status in OpenStack Compute (nova):
  New

Bug description:
  Problem description:
  When doing associcate-floating-ip to an instance, we will call the following method
  https://github.com/openstack/nova/blob/master/nova/network/neutronv2/api.py#L1869
  def _get_port_id_by_fixed_address(self, client,
                                        instance, address):
          """Return port_id from a fixed address."""
          zone = 'compute:%s' % instance.availability_zone
          search_opts = {'device_id': instance.uuid,
                         'device_owner': zone}
          data = client.list_ports(**search_opts)
          ports = data['ports']
          port_id = None
          for p in ports:
              for ip in p['fixed_ips']:
                  if ip['ip_address'] == address:
                      port_id = p['id']
                      break
          if not port_id:
              raise exception.FixedIpNotFoundForAddress(address=address)
          return port_id
   
  to get the port id from the fixed ip the floating ip is to be associated with.
  This method will return the last matched port that has the provided fixed ip, only neglecting
  the fact that multiple ports can satisfy the condition.

  That is, we can
  1. create an instance on subnetA with allocated fixed ip 10.0.0.2/24 (portA)
  2. create a portB on subnetB with fixed ip 10.0.0.2/24
  3. associate portB to the instance
  then the instance has portA and portB with the same address 10.0.0.2/24 on it.

  Desired outcome:
  The method _get_port_id_by_fixed_address should be aware of this circumstance and address
  it in some way.

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