summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Henkel <tobias.henkel@bmw.de>2018-11-22 07:05:58 +0100
committerTobias Henkel <tobias.henkel@bmw.de>2018-11-26 20:13:39 +0100
commit9d77f05d8ebb9b5643af2debbef85fb972a633b8 (patch)
tree27f2df0faa3fb97e8eaa401511e8ef30e56afd2b
parent6eb80deb36ba3f1c6975ce321ef1c391905b661e (diff)
Only setup zNode caches in launcher
We currently only need to setup the zNode caches in the launcher. Within the commandline client and the builders this is just unneccessary work. Change-Id: I03aa2a11b75cab3932e4b45c5e964811a7e0b3d4
Notes
Notes (review): Code-Review+2: James E. Blair <corvus@inaugust.com> Code-Review+2: David Shrewsbury <shrewsbury.dave@gmail.com> Workflow+1: David Shrewsbury <shrewsbury.dave@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 29 Nov 2018 09:59:41 +0000 Reviewed-on: https://review.openstack.org/619440 Project: openstack-infra/nodepool Branch: refs/heads/master
-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):