From 74ea5ca44eb7ae92cdf1ff46e87e47d1824cee3c Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Wed, 30 Mar 2016 16:19:41 -0700 Subject: [PATCH] Remove conditional blocking on server list When the server list cache proceduce was imported from nodepool, it grew this internal conditional which caused all server list calls to block on aquiring the server list cache update lock iff the server list cache is empty. This means that on startup, we could have a thundering herd of threads which all insisted on waiting for the lock because there was no cached server list. This does not seem to be necessary, and the original nodepool logic of always performing non-blocking acquisitions of the lock and returning the old (possibly empty) list of servers for any thread that did not get the lock (but will try again a few seconds later and should receive updated data at that time) should be sufficient. Change-Id: I5640f60da2b7789a98bea033e16695389c6062e0 --- shade/openstackcloud.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index bc7887914..68467c1fa 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -1150,9 +1150,7 @@ class OpenStackCloud(object): # a lock, and the non-blocking acquire method will cause # subsequent threads to just skip this and use the old # data until it succeeds. - # For the first time, when there is no data, make the call - # blocking. - if self._ports_lock.acquire(len(self._ports) == 0): + if self._ports_lock.acquire(False): try: self._ports = self._list_ports(filters) self._ports_time = time.time() @@ -1270,9 +1268,7 @@ class OpenStackCloud(object): # a lock, and the non-blocking acquire method will cause # subsequent threads to just skip this and use the old # data until it succeeds. - # For the first time, when there is no data, make the call - # blocking. - if self._servers_lock.acquire(len(self._servers) == 0): + if self._servers_lock.acquire(False): try: self._servers = self._list_servers(detailed=detailed) self._servers_time = time.time()