policy.init called too many time for each API request

Bug #1302611 reported by Salvatore Orlando
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Salvatore Orlando
Havana
Fix Released
Undecided
Unassigned
Icehouse
Fix Released
Medium
Attila Fazekas

Bug Description

policy.init() checks whether the rule cache is populated and valid, and if not reloads the policy cache from the policy.json file.

As the current code runs init() each time a policy is checked or enforced, list operations will call init() several times (*)
If policy.json is updated while a response is being generated, this will lead to a situation where some item are processed according to the old policies, and other according to the new ones, which would be wrong.

Also, init() checks the last update time of the policy file, and repeating this check multiple time is wasteful.

A simple solution would be to explicitly call policy.init from api.v2.base.Controller in order to ensure the method is called only once per API request.

(*) a GET /ports operation returning 1600 ports calls policy.init() 9606 times

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

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

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

Reviewed: https://review.openstack.org/85354
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=1d41ba485f060a4d6dbe0767845391f955247b08
Submitter: Jenkins
Branch: master

commit 1d41ba485f060a4d6dbe0767845391f955247b08
Author: Salvatore Orlando <email address hidden>
Date: Fri Apr 4 03:09:57 2014 -0700

    Call policy.init() once per API request

    This patch changes the policy engine behaviour and the API base
    controller in order to ensure policy.init is invoked only once
    for each API request.
    This will avoid issues arising from policy file updates during
    API processing and speed up response generation for list operations,
    by about 5%.

    This patch also removes an obsolete TODO comment.

    Change-Id: I108ebd26fccdea19cb00959f70d87c3bc1587df9
    Closes-Bug: 1302611

Changed in neutron:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/havana)

Fix proposed to branch: stable/havana
Review: https://review.openstack.org/94138

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/havana)

Reviewed: https://review.openstack.org/94138
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=003d84a02b76c3a9cffe4c25d5d140097a91c7fc
Submitter: Jenkins
Branch: stable/havana

commit 003d84a02b76c3a9cffe4c25d5d140097a91c7fc
Author: Salvatore Orlando <email address hidden>
Date: Fri Apr 4 03:09:57 2014 -0700

    Call policy.init() once per API request

    This patch changes the policy engine behaviour and the API base
    controller in order to ensure policy.init is invoked only once
    for each API request.
    This will avoid issues arising from policy file updates during
    API processing and speed up response generation for list operations,
    by about 5%.

    This patch also removes an obsolete TODO comment.

    Change-Id: I108ebd26fccdea19cb00959f70d87c3bc1587df9
    Closes-Bug: 1302611
    (cherry picked from commit 1d41ba485f060a4d6dbe0767845391f955247b08)

tags: added: in-stable-havana
Thierry Carrez (ttx)
Changed in neutron:
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/icehouse)

Fix proposed to branch: stable/icehouse
Review: https://review.openstack.org/118586

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/icehouse)

Reviewed: https://review.openstack.org/118586
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=8b5f6be9abd6b36df6f8f3b126758d288f23a867
Submitter: Jenkins
Branch: stable/icehouse

commit 8b5f6be9abd6b36df6f8f3b126758d288f23a867
Author: Salvatore Orlando <email address hidden>
Date: Fri Apr 4 03:09:57 2014 -0700

    Call policy.init() once per API request

    This patch changes the policy engine behaviour and the API base
    controller in order to ensure policy.init is invoked only once
    for each API request.
    This will avoid issues arising from policy file updates during
    API processing and speed up response generation for list operations,
    by about 5%.

    This patch also removes an obsolete TODO comment.

    Change-Id: I108ebd26fccdea19cb00959f70d87c3bc1587df9
    Closes-Bug: 1302611
    (cherry picked from commit 1d41ba485f060a4d6dbe0767845391f955247b08)

tags: added: in-stable-icehouse
Thierry Carrez (ttx)
Changed in neutron:
milestone: juno-1 → 2014.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.