placement/placement
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
..
cmd [goal] Deprecate the JSON formatted policy file 2021-01-15 20:34:51 +00:00
conf [goal] Deprecate the JSON formatted policy file 2021-01-15 20:34:51 +00:00
db Stop to use the __future__ module. 2020-06-03 10:38:03 +02:00
handlers Correctly handle integrity errors on MySQL 8.x 2021-03-25 12:06:24 +00:00
objects Fix l-c job and move to latest hacking 4.0.0 2020-12-15 10:21:18 -06:00
policies Implement secure RBAC for reshaper 2021-02-10 11:00:40 +00:00
schemas Support `same_subtree` queryparam 2019-07-09 07:21:53 +00:00
tests Correctly handle integrity errors on MySQL 8.x 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
attribute_cache.py Make a TraitCache similar to ResourceClassCache 2019-07-24 11:23:50 +01:00
auth.py policy: Add note about keystone's expansion of roles 2021-02-09 14:46:05 +00:00
context.py Make a TraitCache similar to ResourceClassCache 2019-07-24 11:23:50 +01:00
db_api.py Make the PlacementFixture usable without intercept 2019-03-04 20:55:22 +00:00
deploy.py Fix misspell word 2019-09-06 16:51:04 +08:00
direct.py Fix l-c job and move to latest hacking 4.0.0 2020-12-15 10:21:18 -06:00
errors.py Add query.duplicate_key and .bad_value in api-ref 2019-07-09 10:32:45 +00:00
exception.py Make a TraitCache similar to ResourceClassCache 2019-07-24 11:23:50 +01:00
fault_wrap.py Remove all usage of six library 2020-06-09 14:13:53 +02:00
handler.py [goal] Migrate testing to ubuntu focal 2020-08-16 21:07:26 +00:00
lib.py Merge "Support `same_subtree` queryparam" 2019-07-09 22:49:26 +00:00
microversion.py Further simplify microversion utils 2019-07-23 08:57:58 -05:00
policy.py Implement secure RBAC for resource providers 2021-01-27 17:05:06 +00:00
requestlog.py Fix l-c job and move to latest hacking 4.0.0 2020-12-15 10:21:18 -06:00
rest_api_version_history.rst Follow up fix for same_subtree documentation 2019-07-09 10:23:54 +00:00
util.py Negative member_of query with microversion 1.32 2019-03-29 05:14:27 +00:00
wsgi.py Deprecate [placement]/policy_file config option 2019-09-12 18:18:49 -04:00
wsgi_wrapper.py Remove the import pathing for the old structure 2018-09-04 10:31:24 -05:00