nova.network.lease_fixed_ip doesn't raise correct exceptions

Bug #873686 reported by Nayna Patel
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Low
Unassigned

Bug Description

nova.network.lease_fixed_ip throws exceptions .Error. This should be exception.instanceNotFound

Changed in nova:
status: New → Incomplete
status: Incomplete → Confirmed
Revision history for this message
Gavin B (gavin-brebner-orange) wrote :

There are actually 2 places in lease_fixed_ip where exceptions are thrown.

One =

       if not instance_ref:
            raise exception.Error(_('IP %s leased that is not associated') %
                                  address)

which should indeed be a instanceNotFound.

However there is also a second exception which looks like it needs to stay as is (bad MAC).

Changed in nova:
importance: Undecided → Low
Nachi Ueno (nati-ueno)
Changed in openstack-qa:
assignee: nobody → Nachi Ueno (nati-ueno)
importance: Undecided → Medium
status: New → Confirmed
Nachi Ueno (nati-ueno)
Changed in openstack-qa:
assignee: Nachi Ueno (nati-ueno) → nobody
Changed in nova:
assignee: nobody → Bavirisetty Ramya (bavirisetty-ramya)
status: Confirmed → In Progress
Revision history for this message
Bavirisetty Ramya (bavirisetty-ramya) wrote :

 def lease_fixed_ip(self, context, address):
        """Called by dhcp-bridge when ip is leased."""
        LOG.debug(_('Leased IP |%(address)s|'), locals(), context=context)
        fixed_ip = self.db.fixed_ip_get_by_address(context, address)
        if fixed_ip['instance_id'] is None:
            raise exception.Error(_('IP %s leased that is not associated') %
                                      address)
.
.
.
I see that this was the exception raised. Can you be more specific regarding this exception to be changed to InstanceNotFoundException.

Changed in nova:
assignee: Bavirisetty Ramya (bavirisetty-ramya) → nobody
Thierry Carrez (ttx)
Changed in nova:
status: In Progress → Incomplete
Revision history for this message
Thierry Carrez (ttx) wrote :

We cannot solve the issue you reported without more information. Could you please provide the requested information ?

Revision history for this message
Gavin B (gavin-brebner-orange) wrote :

I think the issue is that we should try to be more specific with the exception being raised to provide the possibility of handling this particular case appropriately elsewhere. As the problem is that somehow the address is not associated with an instance, InstanceNotFoundException would seem to fit the bill.

Thierry Carrez (ttx)
Changed in nova:
status: Incomplete → New
Revision history for this message
Mark McLoughlin (markmc) wrote :

The code we're talking about is:

    def lease_fixed_ip(self, context, address):
        fixed_ip = self.db.fixed_ip_get_by_address(context, address)

        if fixed_ip['instance_uuid'] is None:
            msg = _('IP %s leased that is not associated') % address
            raise exception.NovaException(msg)

This is called when dnsmasq leases out the IP address. There basically is no way for users to trigger this error and exceptions we throw from this method would just be logged to a log file.

InstanceNotFoundException is not appropriate. Something like FixedIpNotAssociated would be more accurate. But, again, since this is not an error ever seen by users, I think just using NovaException is fine.

Mark McLoughlin (markmc)
Changed in nova:
status: New → Invalid
Tom Fifield (fifieldt)
no longer affects: openstack-qa
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.