$ cinder type-create foo
$ cinder --debug encryption-type-create foo foobar
$ cinder --debug encryption-type-delete foo
$ cinder --debug encryption-type-create foo foobar
The above command sequence is rewarded by 500 and with the exception visible below:
2014-05-06 10:54:33.798 32003 ERROR cinder.api.middleware.fault [req-84b40273-9a16-4ab0-a521-c9aceb5f2021 8be40a280b234e8e84f9927ab1970477 f3910d12269f4a868adbca3e641b7038 - - -] Caught error: (IntegrityError) (1062, "Duplicate entry 'e1667fc3-8f19-4a83-b9cf-114d8ed297a1' for key 'PRIMARY'") 'INSERT INTO encryption (created_at, updated_at, deleted_at, deleted, cipher, key_size, provider, control_location, volume_type_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2014, 5, 6, 10, 54, 33, 795603), None, None, 0, None, None, 'foobar', 'front-end', 'e1667fc3-8f19-4a83-b9cf-114d8ed297a1')
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault Traceback (most recent call last):
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/cinder/cinder/api/middleware/fault.py", line 75, in __call__
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault return req.get_response(self.application)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/request.py", line 1296, in send
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault application, catch_exc_info=False)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/request.py", line 1260, in call_application
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault app_iter = application(self.environ, start_response)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 144, in __call__
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault return resp(environ, start_response)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/python-keystoneclient/keystoneclient/middleware/auth_token.py", line 632, in __call__
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault return self.app(env, start_response)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 144, in __call__
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault return resp(environ, start_response)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 144, in __call__
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault return resp(environ, start_response)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/routes/middleware.py", line 131, in __call__
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault response = self.app(environ, start_response)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 144, in __call__
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault return resp(environ, start_response)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 130, in __call__
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault resp = self.call_func(req, *args, **self.kwargs)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 195, in call_func
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault return self.func(req, *args, **kwargs)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/cinder/cinder/api/openstack/wsgi.py", line 895, in __call__
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault content_type, body, accept)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/cinder/cinder/api/openstack/wsgi.py", line 943, in _process_stack
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault action_result = self.dispatch(meth, request, action_args)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/cinder/cinder/api/openstack/wsgi.py", line 1019, in dispatch
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault return method(req=request, **action_args)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/cinder/cinder/api/contrib/volume_type_encryption.py", line 128, in create
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault db.volume_type_encryption_create(context, type_id, encryption_specs)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/cinder/cinder/db/api.py", line 455, in volume_type_encryption_create
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault encryption_specs)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/cinder/cinder/db/sqlalchemy/api.py", line 119, in wrapper
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault return f(*args, **kwargs)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/cinder/cinder/db/sqlalchemy/api.py", line 2321, in volume_type_encryption_create
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault encryption.save(session=session)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/cinder/cinder/openstack/common/db/sqlalchemy/models.py", line 51, in save
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault session.flush()
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/cinder/cinder/openstack/common/db/sqlalchemy/session.py", line 484, in _wrap
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault _raise_if_duplicate_entry_error(e, get_engine().name)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault File "/opt/stack/new/cinder/cinder/openstack/common/db/sqlalchemy/session.py", line 436, in _raise_if_duplicate_entry_error
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault raise exception.DBDuplicateEntry(columns, integrity_error)
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault DBDuplicateEntry: (IntegrityError) (1062, "Duplicate entry 'e1667fc3-8f19-4a83-b9cf-114d8ed297a1' for key 'PRIMARY'") 'INSERT INTO encryption (created_at, updated_at, deleted_at, deleted, cipher, key_size, provider, control_location, volume_type_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2014, 5, 6, 10, 54, 33, 795603), None, None, 0, None, None, 'foobar', 'front-end', 'e1667fc3-8f19-4a83-b9cf-114d8ed297a1')
2014-05-06 10:54:33.798 32003 TRACE cinder.api.middleware.fault
this is expected behavior for the most part.
We do soft-deletes for a number of reasons, I don't know that recreating types that you deleted with the same name is all that common, but....
This is a good reason to push back towards using UUID as the unique indicator and NOT the name. I proposed doing just that a while back and received a lot of push-back, maybe we should take another look at that?
I'd propose that volume-types should behave like everything else in OpenStack and use UUID as the unique identifier and not the name. If you want to keep the ability to specify by name that's fine, and you could even just limit the check for unique name to "active" entries.