refactor lockedobjects_db.py

Bug #1740667 reported by Omer Anson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DragonFlow
New
Medium
Lihi Wishnitzer

Bug Description

There are several issues with lockedobjects_db.py:

It is a decorator, which gets a 'type' (defined only locally), which tells it how to find the 'id' by which it locks. This code is overly complex, error prone, and unintuitive.

A more intuitive method would be one of the following:

1. Have a specific decorator per type. The decorator passes a method to extract the lock 'id', rather than figuring it out during locking with a huge (15 elements and counting) if-else dispatch list.

2. Have a context (e.g. 'with lockedobjects_db.lock(id):' which locks when we enter the block, and unlocks when we leave. The ID is given during call. The benefit of this is that we can lock only the calls to nb_api (which is what we want to lock), additional mangling of e.g. Neutron data is outside the lock, and this solution is more general i.e. it is not Neutron specific (unlike the current solution)

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

Reviewed: https://review.openstack.org/560792
Committed: https://git.openstack.org/cgit/openstack/dragonflow/commit/?id=d083aa621178d283a98d9f0a7d57d7b412a68b4b
Submitter: Zuul
Branch: master

commit d083aa621178d283a98d9f0a7d57d7b412a68b4b
Author: Omer Anson <email address hidden>
Date: Wed Apr 11 12:29:39 2018 +0300

    lockedobjects_db: Extract nested lock detection to a method

    Partial-Bug: #1740667
    Change-Id: If349f337ae0279b0b846ec92e0df209700bc83c5

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/560793
Committed: https://git.openstack.org/cgit/openstack/dragonflow/commit/?id=dc8610a2bcefbd4ca46710a0df0446b2cf4df438
Submitter: Zuul
Branch: master

commit dc8610a2bcefbd4ca46710a0df0446b2cf4df438
Author: Omer Anson <email address hidden>
Date: Wed Apr 11 13:07:36 2018 +0300

    lockedobjects_db: Move lock logic to a context-manager method

    Partial-Bug: #1740667
    Change-Id: I4b1fd42e05785dc7ec3b06ba69c3655f60d43a19

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on dragonflow (master)

Change abandoned by Sean McGinnis (<email address hidden>) on branch: master
Review: https://review.opendev.org/560794

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.