Browse Source

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
tags/3.4.0
Tobias Henkel 6 months ago
parent
commit
9d77f05d8e
No account linked to committer's email address
5 changed files with 15 additions and 13 deletions
  1. 1
    1
      nodepool/builder.py
  2. 1
    1
      nodepool/cmd/nodepoolcmd.py
  3. 1
    1
      nodepool/tests/__init__.py
  4. 11
    9
      nodepool/zk.py
  5. 1
    1
      tools/print-zk.py

+ 1
- 1
nodepool/builder.py View File

@@ -1216,7 +1216,7 @@ class NodePoolBuilder(object):
1216 1216
             builder_id = self._getBuilderID(builder_id_file)
1217 1217
 
1218 1218
             # All worker threads share a single ZooKeeper instance/connection.
1219
-            self.zk = zk.ZooKeeper()
1219
+            self.zk = zk.ZooKeeper(enable_cache=False)
1220 1220
             self.zk.connect(list(self._config.zookeeper_servers.values()))
1221 1221
 
1222 1222
             self.log.debug('Starting listener for build jobs')

+ 1
- 1
nodepool/cmd/nodepoolcmd.py View File

@@ -373,7 +373,7 @@ class NodePoolCmd(NodepoolApp):
373 373
                                  'image-delete', 'alien-image-list',
374 374
                                  'list', 'delete',
375 375
                                  'request-list', 'info', 'erase'):
376
-            self.zk = zk.ZooKeeper()
376
+            self.zk = zk.ZooKeeper(enable_cache=False)
377 377
             self.zk.connect(list(config.zookeeper_servers.values()))
378 378
 
379 379
         self.pool.setConfig(config)

+ 1
- 1
nodepool/tests/__init__.py View File

@@ -539,7 +539,7 @@ class DBTestCase(BaseTestCase):
539 539
             self.zookeeper_host,
540 540
             self.zookeeper_port))
541 541
         self.zookeeper_chroot = kz_fxtr.zookeeper_chroot
542
-        self.zk = zk.ZooKeeper()
542
+        self.zk = zk.ZooKeeper(enable_cache=False)
543 543
         host = zk.ZooKeeperConnectionConfig(
544 544
             self.zookeeper_host, self.zookeeper_port, self.zookeeper_chroot
545 545
         )

+ 11
- 9
nodepool/zk.py View File

@@ -693,7 +693,7 @@ class ZooKeeper(object):
693 693
     # Log zookeeper retry every 10 seconds
694 694
     retry_log_rate = 10
695 695
 
696
-    def __init__(self):
696
+    def __init__(self, enable_cache=True):
697 697
         '''
698 698
         Initialize the ZooKeeper object.
699 699
         '''
@@ -704,6 +704,7 @@ class ZooKeeper(object):
704 704
         self._request_cache = None
705 705
         self._cached_nodes = {}
706 706
         self._cached_node_requests = {}
707
+        self.enable_cache = enable_cache
707 708
 
708 709
     # =======================================================================
709 710
     # Private Methods
@@ -894,15 +895,16 @@ class ZooKeeper(object):
894 895
                 except KazooTimeoutError:
895 896
                     self.logConnectionRetryEvent()
896 897
 
897
-            self._node_cache = TreeCache(self.client, self.NODE_ROOT)
898
-            self._node_cache.listen_fault(self.cacheFaultListener)
899
-            self._node_cache.listen(self.nodeCacheListener)
900
-            self._node_cache.start()
898
+            if self.enable_cache:
899
+                self._node_cache = TreeCache(self.client, self.NODE_ROOT)
900
+                self._node_cache.listen_fault(self.cacheFaultListener)
901
+                self._node_cache.listen(self.nodeCacheListener)
902
+                self._node_cache.start()
901 903
 
902
-            self._request_cache = TreeCache(self.client, self.REQUEST_ROOT)
903
-            self._request_cache.listen_fault(self.cacheFaultListener)
904
-            self._request_cache.listen(self.requestCacheListener)
905
-            self._request_cache.start()
904
+                self._request_cache = TreeCache(self.client, self.REQUEST_ROOT)
905
+                self._request_cache.listen_fault(self.cacheFaultListener)
906
+                self._request_cache.listen(self.requestCacheListener)
907
+                self._request_cache.start()
906 908
 
907 909
     def disconnect(self):
908 910
         '''

+ 1
- 1
tools/print-zk.py View File

@@ -30,7 +30,7 @@ args = parser.parse_args()
30 30
 
31 31
 config = nodepool.config.loadConfig(args.config)
32 32
 
33
-zk = nodepool.zk.ZooKeeper()
33
+zk = nodepool.zk.ZooKeeper(enable_cache=False)
34 34
 zk.connect(config.zookeeper_servers.values())
35 35
 
36 36
 def join(a, b):

Loading…
Cancel
Save