Add various locking support to DCManager

Support the following lock updates in DCManager:
 - Provide a function decorator in common/utility.py for a synchronized
   lock that supports both external locks and internal fair locks. This
   decorator is setup, by default, for external locks.
 - Refactor update_subcloud_endpoint_status() so that a common private
   method is provided that is suitable for locking.
 - Update subcloud_manager.py to provide a function decorator to produce
   an internal fair lock based on a unique subcloud name. This decorator
   is specifically designed to be used with
   _update_subcloud_endpoint_status(). This will ensure that the
   multi-threaded DCManager process will only update subcloud endpoint
   information in a synchronized manner.
 - Provide an API lock to the SubcloudsController for the post, patch,
   and delete operations

Update distributedcloud requirements and spec file to require
oslo.concurrency >= 3.29.1. This is the latest version supported by the
Openstack Stein and is a version containing fair lock support.

Update unit tests:
 - Added unit test for update_subcloud_endpoint_status. This verifies
   high level functionality and the calling of fair locks based on the
   unique subcloud name.
 - Fixed intermittent failure seen when executing the add_subcloud unit
   test by mocking thread.Threading.
 - Leverage the use of oslo_concurrency's behavior to use the
   OSLO_LOCK_PATH environment variable if the lock_path config option is
   not set. Currently this is not set as we specify a hard coded
   external lock path at runtime. This allows us to set the lock path
   for tox tests via the test environment.

Change-Id: Id1902e8553408cbdd60b648efc39d59e8edcdb55
Depends-On: https://review.opendev.org/#/c/707188/
Closes-Bug: #1855359
Signed-off-by: Robert Church <robert.church@windriver.com>
This commit is contained in:
Robert Church
2020-02-06 16:44:48 -05:00
parent 8f84108a37
commit 9180e7df84
8 changed files with 386 additions and 123 deletions

View File

@@ -51,6 +51,7 @@ setenv =
CURRENT_CFG_FILE={toxinidir}/.current.cfg
DATA_DIRECTORY={toxinidir}/dcmanager/tests/data
SINGLE_REPO=True
OSLO_LOCK_PATH={toxinidir}
commands =
find {toxinidir} -not -path '{toxinidir}/.tox/*' -name '*.py[c|o]' -delete
python setup_ddt_tests.py testr --slowest --testr-args='{posargs}'