assignment and identity backends should use normal dependency injection

Bug #1204605 reported by Brant Knudson on 2013-07-24
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Medium
Brant Knudson

Bug Description

The assignment and identity backends don't use Keystone's normal dependency injection and the constructor code for these parts is unnecessarily complicated.

The reason the backends don't use the assignment backend is because the assignment backend uses the identity backend and the identity backend uses the assignment backend; so there's a circular dependency. The dependency injection code doesn't handle circular dependencies.

So the fix is to change the dependency injection code to support circular dependency and then the assignment and identity backends can use the normal dependency injection.

alexius ludeman (lexinator) wrote :

+1

Brant Knudson (blk-u) wrote :

I've got the changes out for review just didn't open a bug report... updating commit messages.

Changed in keystone:
assignee: nobody → Brant Knudson (blk-u)
Changed in keystone:
status: New → In Progress
Dolph Mathews (dolph) on 2013-07-24
Changed in keystone:
importance: Undecided → Medium
alexius ludeman (lexinator) wrote :
Download full text (3.6 KiB)

where are we on this? this bug is actually affecting me.

the strange thing for me is the circular reference works on my development machine, but fails on my production machine.

Here is the failure
Traceback (most recent call last):
  File "/usr/local/csi/share/csi-keystone.venv/bin/keystone-all", line 108, in <module>
    int(CONF.admin_port)))
  File "/usr/local/csi/share/csi-keystone.venv/bin/keystone-all", line 37, in create_server
    app = deploy.loadapp('config:%s' % conf, name=name)
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 144, in invoke
    **context.local_conf)
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/util.py", line 56, in fix_call
    val = callable(*args, **kw)
  File "/usr/local/csi/lib/python2.6/site-packages/paste/urlmap.py", line 25, in urlmap_factory
    app = loader.get_app(app_name, global_conf=global_conf)
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 350, in get_app
    name=name, global_conf=global_conf).create()
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 362, in app_context
    APP, name=name, global_conf=global_conf)
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 450, in get_context
    global_additions=global_additions)
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 559, in _pipeline_app_context
    APP, pipeline[-1], global_conf)
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 458, in get_context
    section)
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 517, in _context_from_explicit
    value = import_string(found_expr)
  File "/usr/local/csi/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 22, in import_string
    return pkg_resources.EntryPoint.parse("x=" + s).load(False)
  File "/usr/local/csi/share/csi-keystone.venv/lib/python2.6/site-packages/distribute-0.6.31-py2.6.egg/pkg_resources.py", line 2039, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/local/csi/share/csi-keystone.venv/lib/python2.6/site-packages/keystone/service.py", line 41, in <module>
    identity_api=identity.Manager(),
  File "/usr/local/csi/share/csi-keystone.venv/lib/python2.6/site-packages/keystone/common/dependency.py", line 32, in __wrapped_init__
    init(self, *args, **kwargs)
  File "/usr/local/csi/share/csi-keystone.venv/lib/python2.6/site-packages/keystone/identity/core.py", line 68, in __init__
    assignment_api = assignment.Manager(self)
  File "/usr/local/csi/share/csi-keystone.venv/lib/python2.6/site-packages/keystone/common/dependency.py", line 32, in __wrapped_init__
    init(self, ...

Read more...

Brant Knudson (blk-u) wrote :

@lexinator - you can try out the proposed fix https://review.openstack.org/#/c/37821/

alexius ludeman (lexinator) wrote :
alexius ludeman (lexinator) wrote :

sorry I just realized that this error is in our plugin code.

alexius ludeman (lexinator) wrote :

ok I ruled it out that it is my plugin causing this problem.

I get the same gist stacktrace on both development/production machine where as prior to this patch the circular reference works on my development machine(os x + fusion + oel6) and not my production machine(oel6 on hp).

Though now I think my plugin is the source of this race condition on my production machine.

alexius ludeman (lexinator) wrote :

ugh.

"ok I ruled it out that it *isn't* my plugin causing this problem."

Brant Knudson (blk-u) wrote :

@lexinator - Is keystone-all not working for you either with or without the patch?

alexius ludeman (lexinator) wrote :

ok I missed that https://review.openstack.org/#/c/37821/ required https://review.openstack.org/#/c/37988/7.

now I have both applied, all is good on my development box but again failing on my production box.

thanks for the patches but apparently this is not my exact issue.

alexius ludeman (lexinator) wrote :

ok figured out my problem.

There were remnants of when ldap was a directory and moved to a file:
    https://github.com/openstack/keystone/commit/b9e46fb9c455eed584cb52db3b92ff3d8060a414

This caused the keystone/identity/ldap/__init__.pyc to win over keystone/identity/ldap.py.

sorry for the chatter. I'm looking forward to this patch though. =]

Reviewed: https://review.openstack.org/37821
Committed: http://github.com/openstack/keystone/commit/3268a4b96449647faa76e5521660516fbc9e8a84
Submitter: Jenkins
Branch: master

commit 3268a4b96449647faa76e5521660516fbc9e8a84
Author: Brant Knudson <email address hidden>
Date: Fri Jul 19 17:11:43 2013 -0500

    Use dependency injection for assignment and identity

    The assignment and identity backends don't use normal
    dependency injection because of a circular reference.

    Support for circular references was added, so these
    backends can now use normal dependency injection.

    Fixes: bug 1200769
    Fixes: bug 1204605

    Change-Id: I8716a65b984c26fcaaf2595463db09e1f02cb475

Changed in keystone:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2013-09-05
Changed in keystone:
milestone: none → havana-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2013-10-17
Changed in keystone:
milestone: havana-3 → 2013.2
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers