summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-29 09:59:41 +0000
committerGerrit Code Review <review@openstack.org>2018-11-29 09:59:41 +0000
commit40162102a757621a23fbada8c3bbf22ebf94ee67 (patch)
tree931ba7dde6bd0f7923d642a9cdb583933f6b8a4d
parent103e64ce24545a9c438c309640b6c83812547b24 (diff)
parent9d77f05d8ebb9b5643af2debbef85fb972a633b8 (diff)
Merge "Only setup zNode caches in launcher"
-rwxr-xr-xnodepool/builder.py2
-rwxr-xr-xnodepool/cmd/nodepoolcmd.py2
-rw-r--r--nodepool/tests/__init__.py2
-rwxr-xr-xnodepool/zk.py20
-rw-r--r--tools/print-zk.py2
5 files changed, 15 insertions, 13 deletions
diff --git a/nodepool/builder.py b/nodepool/builder.py
index bb00e67..dce709e 100755
--- a/nodepool/builder.py
+++ b/nodepool/builder.py
@@ -1216,7 +1216,7 @@ class NodePoolBuilder(object):
1216 builder_id = self._getBuilderID(builder_id_file) 1216 builder_id = self._getBuilderID(builder_id_file)
1217 1217
1218 # All worker threads share a single ZooKeeper instance/connection. 1218 # All worker threads share a single ZooKeeper instance/connection.
1219 self.zk = zk.ZooKeeper() 1219 self.zk = zk.ZooKeeper(enable_cache=False)
1220 self.zk.connect(list(self._config.zookeeper_servers.values())) 1220 self.zk.connect(list(self._config.zookeeper_servers.values()))
1221 1221
1222 self.log.debug('Starting listener for build jobs') 1222 self.log.debug('Starting listener for build jobs')
diff --git a/nodepool/cmd/nodepoolcmd.py b/nodepool/cmd/nodepoolcmd.py
index 522556f..f55da98 100755
--- a/nodepool/cmd/nodepoolcmd.py
+++ b/nodepool/cmd/nodepoolcmd.py
@@ -373,7 +373,7 @@ class NodePoolCmd(NodepoolApp):
373 'image-delete', 'alien-image-list', 373 'image-delete', 'alien-image-list',
374 'list', 'delete', 374 'list', 'delete',
375 'request-list', 'info', 'erase'): 375 'request-list', 'info', 'erase'):
376 self.zk = zk.ZooKeeper() 376 self.zk = zk.ZooKeeper(enable_cache=False)
377 self.zk.connect(list(config.zookeeper_servers.values())) 377 self.zk.connect(list(config.zookeeper_servers.values()))
378 378
379 self.pool.setConfig(config) 379 self.pool.setConfig(config)
diff --git a/nodepool/tests/__init__.py b/nodepool/tests/__init__.py
index 8ad9967..1ab83ac 100644
--- a/nodepool/tests/__init__.py
+++ b/nodepool/tests/__init__.py
@@ -539,7 +539,7 @@ class DBTestCase(BaseTestCase):
539 self.zookeeper_host, 539 self.zookeeper_host,
540 self.zookeeper_port)) 540 self.zookeeper_port))
541 self.zookeeper_chroot = kz_fxtr.zookeeper_chroot 541 self.zookeeper_chroot = kz_fxtr.zookeeper_chroot
542 self.zk = zk.ZooKeeper() 542 self.zk = zk.ZooKeeper(enable_cache=False)
543 host = zk.ZooKeeperConnectionConfig( 543 host = zk.ZooKeeperConnectionConfig(
544 self.zookeeper_host, self.zookeeper_port, self.zookeeper_chroot 544 self.zookeeper_host, self.zookeeper_port, self.zookeeper_chroot
545 ) 545 )
diff --git a/nodepool/zk.py b/nodepool/zk.py
index d67342c..0bcd190 100755
--- a/nodepool/zk.py
+++ b/nodepool/zk.py
@@ -693,7 +693,7 @@ class ZooKeeper(object):
693 # Log zookeeper retry every 10 seconds 693 # Log zookeeper retry every 10 seconds
694 retry_log_rate = 10 694 retry_log_rate = 10
695 695
696 def __init__(self): 696 def __init__(self, enable_cache=True):
697 ''' 697 '''
698 Initialize the ZooKeeper object. 698 Initialize the ZooKeeper object.
699 ''' 699 '''
@@ -704,6 +704,7 @@ class ZooKeeper(object):
704 self._request_cache = None 704 self._request_cache = None
705 self._cached_nodes = {} 705 self._cached_nodes = {}
706 self._cached_node_requests = {} 706 self._cached_node_requests = {}
707 self.enable_cache = enable_cache
707 708
708 # ======================================================================= 709 # =======================================================================
709 # Private Methods 710 # Private Methods
@@ -894,15 +895,16 @@ class ZooKeeper(object):
894 except KazooTimeoutError: 895 except KazooTimeoutError:
895 self.logConnectionRetryEvent() 896 self.logConnectionRetryEvent()
896 897
897 self._node_cache = TreeCache(self.client, self.NODE_ROOT) 898 if self.enable_cache:
898 self._node_cache.listen_fault(self.cacheFaultListener) 899 self._node_cache = TreeCache(self.client, self.NODE_ROOT)
899 self._node_cache.listen(self.nodeCacheListener) 900 self._node_cache.listen_fault(self.cacheFaultListener)
900 self._node_cache.start() 901 self._node_cache.listen(self.nodeCacheListener)
902 self._node_cache.start()
901 903
902 self._request_cache = TreeCache(self.client, self.REQUEST_ROOT) 904 self._request_cache = TreeCache(self.client, self.REQUEST_ROOT)
903 self._request_cache.listen_fault(self.cacheFaultListener) 905 self._request_cache.listen_fault(self.cacheFaultListener)
904 self._request_cache.listen(self.requestCacheListener) 906 self._request_cache.listen(self.requestCacheListener)
905 self._request_cache.start() 907 self._request_cache.start()
906 908
907 def disconnect(self): 909 def disconnect(self):
908 ''' 910 '''
diff --git a/tools/print-zk.py b/tools/print-zk.py
index 13a5214..a609eb8 100644
--- a/tools/print-zk.py
+++ b/tools/print-zk.py
@@ -30,7 +30,7 @@ args = parser.parse_args()
30 30
31config = nodepool.config.loadConfig(args.config) 31config = nodepool.config.loadConfig(args.config)
32 32
33zk = nodepool.zk.ZooKeeper() 33zk = nodepool.zk.ZooKeeper(enable_cache=False)
34zk.connect(config.zookeeper_servers.values()) 34zk.connect(config.zookeeper_servers.values())
35 35
36def join(a, b): 36def join(a, b):