From 9a487f3e53a0acdb4bf414a43da554790bbbf7be Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Mon, 29 Feb 2016 15:22:07 -0500 Subject: [PATCH] Return BadRequest for invalid unicode names (continued) Follow-up to "Return BadRequest for invalid Unicode names", we missed a couple of operations here: type-key set quota-class-update qos-create Related-Bug: #1531400 Change-Id: Id966b74dce87acb15ede9cb4c02ae0f74d59b08c --- cinder/db/sqlalchemy/api.py | 6 ++++++ cinder/volume/qos_specs.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index 89afe4a00..66af8310e 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -689,6 +689,7 @@ def _quota_class_get_all_by_resource(context, resource, session): return result +@handle_db_data_error @require_admin_context def quota_class_create(context, class_name, resource, limit): quota_class_ref = models.QuotaClass() @@ -2946,6 +2947,7 @@ def _volume_type_extra_specs_get_item(context, volume_type_id, key, return result +@handle_db_data_error @require_context def volume_type_extra_specs_update_or_create(context, volume_type_id, specs): @@ -3010,6 +3012,10 @@ def qos_specs_create(context, values): spec_entry = models.QualityOfServiceSpecs() spec_entry.update(item) spec_entry.save(session=session) + except db_exc.DBDataError: + msg = _('Error writing field to database') + LOG.exception(msg) + raise exception.Invalid(msg) except Exception as e: raise db_exc.DBError(e) diff --git a/cinder/volume/qos_specs.py b/cinder/volume/qos_specs.py index 52527d78e..49668f2fc 100644 --- a/cinder/volume/qos_specs.py +++ b/cinder/volume/qos_specs.py @@ -79,6 +79,10 @@ def create(context, name, specs=None): try: qos_specs_ref = db.qos_specs_create(context, values) + except db_exc.DBDataError: + msg = _('Error writing field to database') + LOG.exception(msg) + raise exception.Invalid(msg) except db_exc.DBError: LOG.exception(_LE('DB error:')) raise exception.QoSSpecsCreateFailed(name=name,