policy.json is reloaded at each request

Bug #1023649 reported by Salvatore Orlando
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Salvatore Orlando

Bug Description

For every request, quantum v2 API invokes quantum's policy engine (quantum.api.v2.policy). Both policy checking routines, check and enforce, call init(), which reads the policy config file and resets the brain of the policy engine:

def init():
    global _POLICY_PATH
    if not _POLICY_PATH:
        _POLICY_PATH = find_config_file({}, 'policy.json')
        if not _POLICY_PATH:
            raise exceptions.PolicyNotFound(path=FLAGS.policy_file)
    with open(_POLICY_PATH) as f:
        _set_brain(f.read())

This is quite inefficient and might became problematic when the quantum server is under load.

The fix for this bug might consist in the same approach adopted for nova, where the file is reloaded only if its modification time differs from the cached version.

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

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

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

Reviewed: https://review.openstack.org/9692
Committed: http://github.com/openstack/quantum/commit/b7501f2be1f423755b1fef56d9e79561215ff673
Submitter: Jenkins
Branch: master

commit b7501f2be1f423755b1fef56d9e79561215ff673
Author: Salvatore Orlando <email address hidden>
Date: Wed Jul 18 17:59:42 2012 -0700

    Ensures policy file is reloaded only if updated.

    Fixes bug 1023649

    The fix is 'inspired' (ie: copied) from nova. It is cached in memory unless a
    change in policy file is detected. In that case, a reload is triggered.

    This patch also adds a set of unit tests for quantum/policy.py, which was
    previously not covered.

    Change-Id: I337042ae418b518268acd30c26ef02559887a8be

Changed in quantum:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in quantum:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in quantum:
milestone: folsom-3 → 2012.2
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.