diff options
author | Zuul <zuul@review.opendev.org> | 2021-07-23 15:48:05 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-07-23 15:48:05 +0000 |
commit | 35e4745b0986185710573d8fac21ab338d589fbc (patch) | |
tree | 84e86abcb9ab9c6a2591111c133ee98f931441bd | |
parent | 9a7bd8407002d47605acf469a38407b2ccc2c45e (diff) | |
parent | 9c569377fc0388aefbbd94ba8f6334175685e317 (diff) | |
download | zuul-35e4745b0986185710573d8fac21ab338d589fbc.tar.gz |
Merge "Use a temp ZK config cache for tenant validation"
-rw-r--r-- | zuul/scheduler.py | 21 | ||||
-rw-r--r-- | zuul/zk/config_cache.py | 9 |
2 files changed, 20 insertions, 10 deletions
diff --git a/zuul/scheduler.py b/zuul/scheduler.py index a31e6a4d8..ecec8d890 100644 --- a/zuul/scheduler.py +++ b/zuul/scheduler.py @@ -24,6 +24,7 @@ import threading import time import traceback import urllib +import uuid from collections import defaultdict from apscheduler.schedulers.background import BackgroundScheduler @@ -855,12 +856,20 @@ class Scheduler(threading.Thread): invalid = tenants_to_load.difference(available_tenants) raise RuntimeError(f"Invalid tenant(s) found: {invalid}") - abide = Abide() - loader.loadAdminRules(abide, unparsed_abide) - loader.loadTPCs(abide, unparsed_abide) - for tenant_name in tenants_to_load: - loader.loadTenant(abide, tenant_name, self.ansible_manager, - unparsed_abide, min_ltimes=None) + # Use a temporary config cache for the validation + validate_root = f"/zuul/validate/{uuid.uuid4().hex}" + self.unparsed_config_cache = UnparsedConfigCache(self.zk_client, + validate_root) + + try: + abide = Abide() + loader.loadAdminRules(abide, unparsed_abide) + loader.loadTPCs(abide, unparsed_abide) + for tenant_name in tenants_to_load: + loader.loadTenant(abide, tenant_name, self.ansible_manager, + unparsed_abide, min_ltimes=None) + finally: + self.zk_client.client.delete(validate_root, recursive=True) loading_errors = [] for tenant in abide.tenants.values(): diff --git a/zuul/zk/config_cache.py b/zuul/zk/config_cache.py index a3d258c07..41cc60492 100644 --- a/zuul/zk/config_cache.py +++ b/zuul/zk/config_cache.py @@ -23,6 +23,8 @@ from kazoo.exceptions import NoNodeError from zuul.zk import sharding, ZooKeeperSimpleBase +CONFIG_ROOT = "/zuul/config" + def _safe_path(root_path, *keys): return "/".join((root_path, *(quote_plus(k) for k in keys))) @@ -134,13 +136,12 @@ class FilesCache(ZooKeeperSimpleBase, MutableMapping): class UnparsedConfigCache(ZooKeeperSimpleBase): """Zookeeper cache for unparsed config files.""" - CONFIG_ROOT = "/zuul/config" log = logging.getLogger("zuul.zk.config_cache.UnparsedConfigCache") - def __init__(self, client): + def __init__(self, client, config_root=CONFIG_ROOT): super().__init__(client) - self.cache_path = f"{self.CONFIG_ROOT}/cache" - self.lock_path = f"{self.CONFIG_ROOT}/lock" + self.cache_path = f"{config_root}/cache" + self.lock_path = f"{config_root}/lock" def readLock(self, project_cname): return self.kazoo_client.ReadLock( |