raising Maximum number of ports exceeded is wrong

Bug #1347778 reported by Chris Behrens
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Matt Riedemann
python-neutronclient
Fix Released
Medium
Matt Riedemann

Bug Description

When neutron API in nova calls create_port(), it looks for exceptions. Any 409 is turned into 'Maximum number of ports exceeded'. This is a horrible assumption. Neutron can return 409s for more than just this reason.

Another case where neutron returns a 409 is this:

2014-07-22 18:10:27.583 26577 INFO neutron.api.v2.resource [req-b7267ae5-bafa-4c34-8e25-9c0fca96ad2d None] create failed (client error):
                     Unable to complete operation for network 00000000-0000-0000-0000-000000000000. The mac address XX:XX:XX:XX:XX:XX is in use.

This can occur when the request to create a port includes the mac address to use (as happens w/ baremetal/ironic in nova) and neutron for some reason still has things assigned with that mac.

This is the offending code:

 174 except neutron_client_exc.NeutronClientException as e:
 175 # NOTE(mriedem): OverQuota in neutron is a 409
 176 if e.status_code == 409:
 177 LOG.warning(_('Neutron error: quota exceeded'))
 178 raise exception.PortLimitExceeded()

Tags: neutron
Revision history for this message
Matt Riedemann (mriedem) wrote :

See related bug 1331353.

In the long long ago python-neutronclient sucked at raising specific exceptions so we were basically left with NeutronClientException and the status code, unless you also wanted to parse the error message, which isn't good either.

Things are a bit better now but we have to get specific exceptions in the client to handle them in nova, we have a few patches in nova already for similar issues.

tags: added: neutron
Changed in nova:
status: New → Confirmed
Revision history for this message
Matt Riedemann (mriedem) wrote :

You need a MacAddressInUseClient exception in python-neutronclient before nova can handle that specifically, based on this neutron server exception:

http://git.openstack.org/cgit/openstack/neutron/tree/neutron/common/exceptions.py#n131

Revision history for this message
Chris Behrens (cbehrens) wrote :

So, MacAddressInUse needs added to neutronclient first it appears... so we don't have to do fun string checking in nova, I guess.

Matt Riedemann (mriedem)
Changed in python-neutronclient:
status: New → Confirmed
Changed in nova:
status: Confirmed → Triaged
Revision history for this message
Chris Behrens (cbehrens) wrote :

So, the new code is going to look like this because of the other bug fixes:

            port_id = port_client.create_port(port_req_body)['port']['id']
            LOG.debug('Successfully created port: %s', port_id,
                      instance=instance)
            return port_id
        except neutron_client_exc.OverQuotaClient:
            LOG.warning(_LW(
                'Neutron error: Port quota exceeded in tenant: %s'),
                port_req_body['port']['tenant_id'], instance=instance)
            raise exception.PortLimitExceeded()
        except neutron_client_exc.IpAddressGenerationFailureClient:
            LOG.warning(_LW('Neutron error: No more fixed IPs in network: %s'),
                        network_id, instance=instance)
            raise exception.NoMoreFixedIps()
        except neutron_client_exc.NeutronClientException:
            with excutils.save_and_reraise_exception():
                LOG.exception(_('Neutron error creating port on network %s'),
                              network_id, instance=instance)

We'll want to add the new neutron_client_exc.MacAddrInUse to this.

Matt Riedemann (mriedem)
Changed in python-neutronclient:
assignee: nobody → Matt Riedemann (mriedem)
status: Confirmed → In Progress
Changed in nova:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-neutronclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/109052

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-neutronclient (master)

Reviewed: https://review.openstack.org/109052
Committed: https://git.openstack.org/cgit/openstack/python-neutronclient/commit/?id=5eeba0ca19a683ef546cacd280a0dd1dfdb4995e
Submitter: Jenkins
Branch: master

commit 5eeba0ca19a683ef546cacd280a0dd1dfdb4995e
Author: Matt Riedemann <email address hidden>
Date: Wed Jul 23 09:27:46 2014 -0700

    Add MacAddressInUseClient exception handling

    Nova needs a specific client exception defined for the server's
    MacAddressInUse exception when allocating ports so it can handle the
    exception properly, otherwise the NeutronClientException with a 409 can
    be confused with other errors.

    Partial-Bug: #1347778

    Change-Id: Ia02dbc8fe32a43adeb229e3b640b9b33ec0dd6c7

Revision history for this message
Matt Riedemann (mriedem) wrote :

The new exception is in python-neutronclient 2.3.6, global-reqs update is here: https://review.openstack.org/#/c/110382/

Changed in python-neutronclient:
status: In Progress → Fix Released
Kyle Mestery (mestery)
Changed in python-neutronclient:
milestone: none → 2.3.6
importance: Undecided → Medium
Matt Riedemann (mriedem)
Changed in nova:
assignee: nobody → Matt Riedemann (mriedem)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/111830

Changed in nova:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/111830
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=c13b33254a367782d1b778c8523b420d425a44e9
Submitter: Jenkins
Branch: master

commit c13b33254a367782d1b778c8523b420d425a44e9
Author: Matt Riedemann <email address hidden>
Date: Mon Aug 4 14:10:18 2014 -0700

    Handle MacAddressInUseClient exception from Neutron when creating port

    This adds exception handling for the new MacAddressInUseClient exception
    from python-neutronclient-2.3.6 when trying to create a port with a
    specific MAC address.

    The PortInUse exception is used so that the build will be rescheduled if
    this error is encountered.

    Also, the servers API already handles PortInUse and translates it to an
    HTTPConflict response.

    Closes-Bug: #1347778

    Change-Id: I929b5f9d79bcb7e60e8b3482e5ee1ca2fababed1

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → juno-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: juno-3 → 2014.2
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.