summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-07-27 21:24:16 +0000
committerGerrit Code Review <review@openstack.org>2022-07-27 21:24:16 +0000
commitb2b36d413e3413a76118b74b2cf003d7b7fe7bad (patch)
treed8a063f0a193c26a037e62452b81d5612cac8d42
parentba2f4b8eac744f14df5790fc96cc8c1aff1ab0ff (diff)
parentdcd860cfc17c2829502c84c4bd2f74a35ae06160 (diff)
downloadzuul-b2b36d413e3413a76118b74b2cf003d7b7fe7bad.tar.gz
Merge "Fix nodepool label query"
-rw-r--r--tests/base.py7
-rw-r--r--zuul/zk/nodepool.py14
2 files changed, 10 insertions, 11 deletions
diff --git a/tests/base.py b/tests/base.py
index 1ea699a51..cebcf2e1f 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -3668,7 +3668,7 @@ class FakeSMTP(object):
class FakeNodepool(object):
REQUEST_ROOT = '/nodepool/requests'
NODE_ROOT = '/nodepool/nodes'
- LAUNCHER_ROOT = '/nodepool/launchers'
+ COMPONENT_ROOT = '/nodepool/components'
log = logging.getLogger("zuul.test.FakeNodepool")
@@ -3732,10 +3732,11 @@ class FakeNodepool(object):
self.fulfillRequest(req)
def registerLauncher(self, labels=["label1"], id="FakeLauncher"):
- path = os.path.join(self.LAUNCHER_ROOT, id)
+ path = os.path.join(self.COMPONENT_ROOT, 'pool', id)
data = {'id': id, 'supported_labels': labels}
self.client.create(
- path, json.dumps(data).encode('utf8'), makepath=True)
+ path, json.dumps(data).encode('utf8'),
+ ephemeral=True, makepath=True, sequence=True)
def getNodeRequests(self):
try:
diff --git a/zuul/zk/nodepool.py b/zuul/zk/nodepool.py
index 109053f11..1be4dc2b5 100644
--- a/zuul/zk/nodepool.py
+++ b/zuul/zk/nodepool.py
@@ -12,6 +12,7 @@
import json
import logging
+import os
import time
from enum import Enum
from typing import Optional, List
@@ -43,7 +44,7 @@ class ZooKeeperNodepool(ZooKeeperBase):
Class implementing Nodepool related ZooKeeper interface.
"""
NODES_ROOT = "/nodepool/nodes"
- LAUNCHER_ROOT = "/nodepool/launchers"
+ COMPONENT_ROOT = "/nodepool/components"
REQUEST_ROOT = '/nodepool/requests'
REQUEST_LOCK_ROOT = "/nodepool/requests-lock"
HOLD_REQUEST_ROOT = '/zuul/hold-requests'
@@ -95,9 +96,6 @@ class ZooKeeperNodepool(ZooKeeperBase):
self._node_tree.close()
self._node_tree = None
- def _launcherPath(self, launcher):
- return "%s/%s" % (self.LAUNCHER_ROOT, launcher)
-
def _nodePath(self, node):
return "%s/%s" % (self.NODES_ROOT, node)
@@ -113,15 +111,15 @@ class ZooKeeperNodepool(ZooKeeperBase):
:returns: A list of Launcher objects, or empty list if none are found.
"""
+ root_path = os.path.join(self.COMPONENT_ROOT, 'pool')
try:
- launcher_ids = self.kazoo_client\
- .get_children(self.LAUNCHER_ROOT)
+ pools = self.kazoo_client.get_children(root_path)
except NoNodeError:
return []
objs = []
- for launcher in launcher_ids:
- path = self._launcherPath(launcher)
+ for pool in pools:
+ path = os.path.join(root_path, pool)
try:
data, _ = self.kazoo_client.get(path)
except NoNodeError: