diff --git a/tests/nodepool/test_nodepool_integration.py b/tests/nodepool/test_nodepool_integration.py index 6e8405a5a4..e212ef8ff5 100644 --- a/tests/nodepool/test_nodepool_integration.py +++ b/tests/nodepool/test_nodepool_integration.py @@ -39,7 +39,8 @@ class TestNodepoolIntegration(BaseTestCase): self.provisioned_requests = [] # This class implements the scheduler methods zuul.nodepool # needs, so we pass 'self' as the scheduler. - self.nodepool = zuul.nodepool.Nodepool(self) + self.nodepool = zuul.nodepool.Nodepool( + self.zk_client, self.hostname, self.statsd, self) def waitForRequests(self): # Wait until all requests are complete. diff --git a/tests/unit/test_nodepool.py b/tests/unit/test_nodepool.py index 6d6552c7ce..3b6bfca3ce 100644 --- a/tests/unit/test_nodepool.py +++ b/tests/unit/test_nodepool.py @@ -46,7 +46,8 @@ class TestNodepool(BaseTestCase): self.provisioned_requests = [] # This class implements the scheduler methods zuul.nodepool # needs, so we pass 'self' as the scheduler. - self.nodepool = zuul.nodepool.Nodepool(self) + self.nodepool = zuul.nodepool.Nodepool( + self.zk_client, self.hostname, self.statsd, self) self.fake_nodepool = FakeNodepool(self.zk_chroot_fixture) self.addCleanup(self.fake_nodepool.stop) diff --git a/zuul/nodepool.py b/zuul/nodepool.py index a9732dec7f..69ce515f4e 100644 --- a/zuul/nodepool.py +++ b/zuul/nodepool.py @@ -17,6 +17,7 @@ from collections import defaultdict from zuul import model from zuul.lib.logutil import get_annotated_logger from zuul.zk.exceptions import LockException +from zuul.zk.nodepool import ZooKeeperNodepool def add_resources(target, source): @@ -32,9 +33,16 @@ def subtract_resources(target, source): class Nodepool(object): log = logging.getLogger('zuul.nodepool') - def __init__(self, scheduler): - self.requests = {} + def __init__(self, zk_client, hostname, statsd, scheduler=None): + self.hostname = hostname + self.statsd = statsd + # TODO (felix): Remove the scheduler parameter once the nodes are + # locked on the executor side. self.sched = scheduler + + self.zk_nodepool = ZooKeeperNodepool(zk_client) + + self.requests = {} self.current_resources_by_tenant = {} self.current_resources_by_project = {} @@ -47,10 +55,9 @@ class Nodepool(object): # timer zuul.nodepool.requests.(fulfilled|failed).