Remove lock on SchedulerReportClient._create_client

This is a follow up to change Idf6e548d725db0181629a451f46b6a3a5850d186
where the compute API started lazy-loading the SchedulerReportClient
because of slow startup times, presumably because of the locking
when creating SchedulerReportClient.

The lock on SchedulerReportClient._create_client is removed
since there is no clear indication that it is necessary. It was
added in change I02ac615dc26a4a0d1fd28a638f622777e41d14e4 as a
precaution:

  "I've made the _client method synchronized so that in the unlikely event
   that the resource tracker is trying to do its update job while some
   other thing is happening, we won't waste the client. This may not be
   necessary, but probably doesn't harm anything."

Long-term we could consider making SchedulerReportClient a global
singleton so a TODO is left for that since it would require inspecting
cache-sensitive methods to see if a lock is necessary.

Change-Id: I127e8b78c0dfd5c42a1e1f509dc4fca1af3d5f89
Related-Bug: #1807219
Related-Bug: #1806912
This commit is contained in:
Matt Riedemann 2018-12-12 12:32:23 -05:00
parent 4cec0c7650
commit 901fb45421
1 changed files with 4 additions and 2 deletions

View File

@ -47,7 +47,6 @@ DISK_GB = fields.ResourceClass.DISK_GB
_RE_INV_IN_USE = re.compile("Inventory for (.+) on resource provider "
"(.+) in use")
WARN_EVERY = 10
PLACEMENT_CLIENT_SEMAPHORE = 'placement_client'
RESHAPER_VERSION = '1.30'
CONSUMER_GENERATION_VERSION = '1.28'
NESTED_AC_VERSION = '1.29'
@ -254,6 +253,10 @@ def get_placement_request_id(response):
return response.headers.get(request_id.HTTP_RESP_HEADER_REQUEST_ID)
# TODO(mriedem): Consider making SchedulerReportClient a global singleton so
# that things like the compute API do not have to lazy-load it. That would
# likely require inspecting methods that use a ProviderTree cache to see if
# they need locks.
class SchedulerReportClient(object):
"""Client class for updating the scheduler."""
@ -280,7 +283,6 @@ class SchedulerReportClient(object):
self._provider_tree = provider_tree.ProviderTree()
self._association_refresh_time = {}
@utils.synchronized(PLACEMENT_CLIENT_SEMAPHORE)
def _create_client(self):
"""Create the HTTP session accessing the placement service."""
# Flush provider tree and associations so we start from a clean slate.