keystone doesn't handle duplicate tenant names gracefully

Bug #955464 reported by Joe Gordon
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Medium
Dolph Mathews

Bug Description

Using latest Essex.

$keystone tenant-create --name=demo
$keystone tenant-create --name=demo

root@cc1:/opt/devstack/devstack/files# keystone tenant-create --name=demo
No handlers could be found for logger "keystoneclient.client"
Unable to communicate with identity service: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 336, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/lib/python2.7/dist-packages/paste/urlmap.py", line 203, in __call__
    return app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/keystone/keystone/common/wsgi.py", line 284, in __call__
    response = request.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/keystone/keystone/common/wsgi.py", line 284, in __call__
    response = request.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/keystone/keystone/common/wsgi.py", line 284, in __call__
    response = request.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/keystone/keystone/common/wsgi.py", line 284, in __call__
    response = request.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/keystone/keystone/common/wsgi.py", line 307, in __call__
    resp = req.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/WebOb-1.0.8-py2.7.egg/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/keystone/keystone/common/wsgi.py", line 181, in __call__
    result = method(context, **params)
  File "/opt/keystone/keystone/identity/core.py", line 303, in create_tenant
    context, tenant_id, tenant_ref)
  File "/opt/keystone/keystone/common/manager.py", line 48, in _wrapper
    return f(*args, **kw)
  File "/opt/keystone/keystone/identity/backends/sql.py", line 319, in create_tenant
    session.flush()
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1547, in flush
    self._flush(objects)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1616, in _flush
    flush_context.execute()
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 328, in execute
    rec.execute(self)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 472, in execute
    uow
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/mapper.py", line 2264, in _save_obj
    execute(statement, multiparams)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1405, in execute
    params)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1538, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1646, in _execute_context
    context)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1639, in _execute_context
    context)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 330, in do_execute
    cursor.execute(statement, parameters)
IntegrityError: (IntegrityError) column name is not unique u'INSERT INTO tenant (id, name, extra) VALUES (?, ?, ?)' ('cfabb987dba6434dbdfecb2e75d86876', u'demo', '{"enabled": true, "description": null}')
. (HTTP 500)

Joe Gordon (jogo)
description: updated
Dolph Mathews (dolph)
Changed in keystone:
status: New → Confirmed
Dolph Mathews (dolph)
Changed in keystone:
assignee: nobody → Dolph Mathews (dolph)
importance: Undecided → Medium
milestone: none → essex-rc1
Revision history for this message
Dolph Mathews (dolph) wrote :

This is improved a tiny bit by the proposed patch for bug 955411:

    $ keystone tenant-create --name=asdf
    No handlers could be found for logger "keystoneclient.client"
    An unexpected error prevented the server from fulfilling your request. (IntegrityError) column name is not unique u'INSERT INTO tenant (id, name, extra) VALUES (?, ?, ?)' ('b4f30dc979c74bc8afbf6310032dcac6', u'asdf', '{"enabled": true, "description": null}') (HTTP 500)

However, IntegrityErrors should be expected and return 409 Conflict instead of 500.

Changed in keystone:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

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

Changed in keystone:
assignee: Dolph Mathews (dolph) → Justin Shepherd (jshepher)
Revision history for this message
Justin Shepherd (jshepher) wrote :

With the proposed fix:

 keystone tenant-create --name=asdf
No handlers could be found for logger "keystoneclient.client"
Duplicate name (HTTP 409)

Revision history for this message
Dolph Mathews (dolph) wrote :

Was this intentionally reassigned? The "no handlers..." warning is being tracked in another bug.

Revision history for this message
Justin Shepherd (jshepher) wrote :

Dolph.. sorry i did not see any open reviews.. was trying to help with RC1..

I was not trying to fix the "no handlers" issue.. i submitted a review for generating a 409 instead of a 500 on the IntegrityError

Revision history for this message
Justin Shepherd (jshepher) wrote :

Also.. gerrit reassigned.. i did not reassign

Revision history for this message
Dolph Mathews (dolph) wrote :

Not sure what happened then.. this bug was assigned to me, marked In Progress (based on https://review.openstack.org/#change,5358 ) and overlaps with work I'm doing for another bug (related to exception handling, see linked merge prop).

Changed in keystone:
assignee: Justin Shepherd (jshepher) → Dolph Mathews (dolph)
Revision history for this message
Justin Shepherd (jshepher) wrote :

Abandoned conflicting review.. Sorry about the confusion.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/5358
Committed: http://github.com/openstack/keystone/commit/009d661a7e06ad72ab39b93433839bf567755ece
Submitter: Jenkins
Branch: master

commit 009d661a7e06ad72ab39b93433839bf567755ece
Author: Dolph Mathews <email address hidden>
Date: Wed Mar 14 15:06:16 2012 -0500

    Wrapped unexpected exceptions (bug 955411)

    - Replaced all webob.exc's (outside of middleware) with
      keystone.exception's
    - Raised 409 Conflict when creating/updating existing
      user/tenant ID/names (bug 955464)
    - Raised 501 Not Implemented for user-role-add w/o tenant_id
      (bug 955548)

    Change-Id: I9f16cac502c20dd35a6b8da778e85bf3d9cfae49

Changed in keystone:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in keystone:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: essex-rc1 → 2012.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.