placement/placement/handlers
Stephen Finucane ba8228eb04 Correctly handle integrity errors on MySQL 8.x
We attempt to parse the 'DBDuplicateEntry' exceptions raised by oslo.db
in the event of an integrity error to provide more useful information to
the user about what they did wrong. To do that, we're looking at the
'columns' attribute of this exception, which should list the conflicting
column(s), and extracting entries from the user-provided data based on
these columns names. However, on MySQL 8.x this does not return a column
name but rather a constraint name. This results in a KeyError when we
attempt to show the offending data by pulling it out by "column" name.
For example:

  KeyError: 'resource_providers.uniq_resource_providers0name'

The solution is simple. Since there are only two unique constraints for
the 'ResourceProvider' model, we can simply check for these and map them
to their corresponding columns if found. The existing code can be
retained as a fallback for other database backends and legacy MySQL
versions.

Change-Id: I1dda02d46cb019eedd6e3ef64e327ac85bb7c484
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Story: 2008750
Task: 42110
2021-03-25 12:06:24 +00:00
..
__init__.py Move the placement code to the base 2018-09-04 10:31:23 -05:00
aggregate.py Remove use of oslo.i18n and translation 2019-03-25 16:59:21 +00:00
allocation.py [goal] Migrate testing to ubuntu focal 2020-08-16 21:07:26 +00:00
allocation_candidate.py Remove all usage of six library 2020-06-09 14:13:53 +02:00
inventory.py Remove use of oslo.i18n and translation 2019-03-25 16:59:21 +00:00
reshaper.py Implement allocation candidate mappings 2019-06-12 21:19:14 +00:00
resource_class.py [goal] Migrate testing to ubuntu focal 2020-08-16 21:07:26 +00:00
resource_provider.py Correctly handle integrity errors on MySQL 8.x 2021-03-25 12:06:24 +00:00
root.py Remove the import pathing for the old structure 2018-09-04 10:31:24 -05:00
trait.py Fix l-c job and move to latest hacking 4.0.0 2020-12-15 10:21:18 -06:00
usage.py Implement secure RBAC for usage 2021-01-27 17:29:47 +00:00
util.py Remove use of oslo.i18n and translation 2019-03-25 16:59:21 +00:00