Circular dependencies in dashboard settings

Bug #1154564 reported by Alexey Izbyshev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
High
Alexey Izbyshev

Bug Description

Importing horizon.utils from dashboard local_settings.py to generate
SECRET_KEY results in a sequence of imports, and horizon.conf.default
module gets imported at some point. During initialization of default
HORIZON_CONFIG this module uses settings.LOGIN_REDIRECT_URL and
ugettext() call. Both of them need django settings to be ready to use,
therefore settings initialization starts again before it could finish.

Since Python processes module only when it is imported the first time,
this process stops, but the 'inner' settings object contains only
parameters that were set above the point of import of local_settings.
Therefore Django complains about missing SECRET_KEY when it processes
'inner' settings. Also, logging is configured twice: the first time with default
Django parameters and the second time with those specified in settings,
so effectively parameters are combined.

Changed in horizon:
assignee: nobody → Alexey Izbyshev (izbyshev)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/23958
Committed: http://github.com/openstack/horizon/commit/50c21151b54759d297fdbef222aaa45c17f70027
Submitter: Jenkins
Branch: master

commit 50c21151b54759d297fdbef222aaa45c17f70027
Author: Alexey Izbyshev <email address hidden>
Date: Fri Mar 8 23:42:11 2013 +0400

    Fix circular dependencies in dashboard settings

    Importing horizon.utils from dashboard local_settings.py to generate
    SECRET_KEY results in a sequence of imports, and horizon.conf.default
    module gets imported at some point. During initialization of default
    HORIZON_CONFIG this module uses settings.LOGIN_REDIRECT_URL and
    ugettext() call. Both of them need django settings to be ready to use,
    therefore settings initialization starts again before it could finish.

    Since Python processes module only when it is imported the first time,
    this process stops, but the 'inner' settings object contains only
    parameters that were set above the point of import of local_settings.
    Therefore Django complains about missing SECRET_KEY when it processes
    'inner' settings.

    The fix moves the import of horizon.conf.default to
    LazySetting._setup(). If keys of HORIZON_CONFIG obtained from
    horizon.conf are not used within openstask_dashboard settings.py
    or local_settings.py, the circular import won't happen.

    Fixes bug #1154564

    Change-Id: If63ab1920ecc8e646fd5b6cc52c106ae0876fa2d

Changed in horizon:
status: In Progress → Fix Committed
Changed in horizon:
importance: Undecided → High
milestone: none → grizzly-rc1
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: grizzly-rc1 → 2013.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.