diff --git a/releasenotes/notes/tenant-conf-check-50ca470132bef55a.yaml b/releasenotes/notes/tenant-conf-check-50ca470132bef55a.yaml new file mode 100644 index 0000000000..2c0202aae4 --- /dev/null +++ b/releasenotes/notes/tenant-conf-check-50ca470132bef55a.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + The zuul tenant-conf-check command no longer needs a ZooKeeper connection + to validate the tenants configuration file is valid. diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 461a8b4aba..c48a8f37b3 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -28,6 +28,7 @@ from tests.base import FIXTURE_DIR class BaseClientTestCase(BaseTestCase): config_file = 'zuul.conf' + config_with_zk = True def setUp(self): super(BaseClientTestCase, self).setUp() @@ -35,6 +36,10 @@ class BaseClientTestCase(BaseTestCase): rootdir=os.environ.get("ZUUL_TEST_ROOT"))).path self.config = configparser.ConfigParser() self.config.read(os.path.join(FIXTURE_DIR, self.config_file)) + if self.config_with_zk: + self.config_add_zk() + + def config_add_zk(self): self.setupZK() self.config.add_section('zookeeper') self.config.set('zookeeper', 'hosts', self.zk_chroot_fixture.zk_hosts) @@ -48,8 +53,9 @@ class BaseClientTestCase(BaseTestCase): class TestTenantValidationClient(BaseClientTestCase): - def test_client_tenant_conf_check(self): + config_with_zk = False + def test_client_tenant_conf_check(self): self.config.set( 'scheduler', 'tenant_config', os.path.join(FIXTURE_DIR, 'config/tenant-parser/simple.yaml')) diff --git a/zuul/cmd/client.py b/zuul/cmd/client.py index d7154184c7..707c4b8404 100755 --- a/zuul/cmd/client.py +++ b/zuul/cmd/client.py @@ -718,8 +718,16 @@ class Client(zuul.cmd.ZuulApp): from zuul import scheduler from zuul import configloader self.configure_connections(source_only=True) - sched = scheduler.Scheduler(self.config, self.connections, - self, testonly=True) + + class SchedulerConfig(scheduler.Scheduler): + # A custom scheduler constructor adapted for config check + # to avoid loading runtime clients. + def __init__(self, config, connections): + self.config = config + self.connections = connections + self.unparsed_config_cache = None + + sched = SchedulerConfig(self.config, self.connections) loader = configloader.ConfigLoader( sched.connections, sched, None, None) tenant_config, script = sched._checkTenantSourceConf(self.config)