DBDuplicateEntry not being handled when updating/creating Ports with the same address

Bug #1257673 reported by Lucas Alvares Gomes
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ironic
Fix Released
High
Lucas Alvares Gomes

Bug Description

We should handle the DBDuplicateEntry at the db level and return a custom message to the internals from the error.

OUTPUT:

{{{
Server-side error: "(IntegrityError) column address is not unique u'UPDATE ports SET updated_at=?, address=? WHERE ports.id = ?' ('2013-12-04 10:01:59.664396', u'BB:BB:BB:BB:BB:BB', 2)". Detail:
Traceback (most recent call last):

  File "/home/lucasagomes/Projects/ironic/.tox/venv/lib/python2.7/site-packages/wsmeext/pecan.py", line 77, in callfunction
    result = f(self, *args, **kwargs)

  File "ironic/api/controllers/v1/port.py", line 245, in patch
    rpc_port.save()

  File "ironic/objects/base.py", line 127, in wrapper
    return fn(self, ctxt, *args, **kwargs)

  File "ironic/objects/port.py", line 65, in save
    self.dbapi.update_port(self.uuid, updates)

  File "ironic/objects/__init__.py", line 28, in wrapper
    result = fn(*args, **kwargs)

  File "ironic/db/sqlalchemy/api.py", line 400, in update_port
    ref.update(values)

  File "/home/lucasagomes/Projects/ironic/.tox/venv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 456, in __exit__
    self.commit()

  File "/home/lucasagomes/Projects/ironic/.tox/venv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 368, in commit
    self._prepare_impl()

  File "/home/lucasagomes/Projects/ironic/.tox/venv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 347, in _prepare_impl
    self.session.flush()

  File "ironic/openstack/common/db/sqlalchemy/session.py", line 550, in _wrap
    _raise_if_duplicate_entry_error(e, get_engine().name)

  File "ironic/openstack/common/db/sqlalchemy/session.py", line 495, in _raise_if_duplicate_entry_error
    raise exception.DBDuplicateEntry(columns, integrity_error)

DBDuplicateEntry: (IntegrityError) column address is not unique u'UPDATE ports SET updated_at=?, address=? WHERE ports.id = ?' ('2013-12-04 10:01:59.664396', u'BB:BB:BB:BB:BB:BB', 2)
}}}

Changed in ironic:
assignee: nobody → Lucas Alvares Gomes (lucasagomes)
description: updated
summary: - DBDuplicateEntry not being handled when updating resources
+ DBDuplicateEntry not being handled when updating/creating Ports with the
+ same address
description: updated
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ironic (master)

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

Changed in ironic:
status: New → In Progress
aeva black (tenbrae)
Changed in ironic:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ironic (master)

Reviewed: https://review.openstack.org/59955
Committed: https://git.openstack.org/cgit/openstack/ironic/commit/?id=9acdc455395d2929938acd5e609bd4ca9392b6b1
Submitter: Jenkins
Branch: master

commit 9acdc455395d2929938acd5e609bd4ca9392b6b1
Author: Lucas Alvares Gomes <email address hidden>
Date: Wed Dec 4 11:59:50 2013 +0000

    Handle DBDuplicateEntry on Ports with same address

    Handle the DBDuplicateEntry exception when creating/updating ports with
    the same address and raise MACAlreadyExists to give user a better feedback
    about the problem.

    Change-Id: I87feb27776bb2fee2a4a6b28f9468e235063f5f7
    Closes-Bug: #1257673

Changed in ironic:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in ironic:
milestone: none → icehouse-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ironic:
milestone: icehouse-2 → 2014.1
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.