Remove layout option, adapt -t option accordingly

The layout option no longer makes much sense since config repos are
where layouts come from now. The -t option is still useful for testing
the static config, and may one day be expanded to fully load all config
repos and test them.

There were also chunks left in the scheduler from the old way.

Change-Id: I0a0b521b3ed20762e1cd60a042daa1f8c4f57a65
This commit is contained in:
Clint Byrum 2017-02-20 14:10:39 -05:00
parent 40728e3ef4
commit 240d86045a
2 changed files with 13 additions and 47 deletions

View File

@ -44,15 +44,11 @@ class Scheduler(zuul.cmd.ZuulApp):
parser = argparse.ArgumentParser(description='Project gating system.') parser = argparse.ArgumentParser(description='Project gating system.')
parser.add_argument('-c', dest='config', parser.add_argument('-c', dest='config',
help='specify the config file') help='specify the config file')
parser.add_argument('-l', dest='layout',
help='specify the layout file')
parser.add_argument('-d', dest='nodaemon', action='store_true', parser.add_argument('-d', dest='nodaemon', action='store_true',
help='do not run as a daemon') help='do not run as a daemon')
parser.add_argument('-t', dest='validate', nargs='?', const=True, parser.add_argument('-t', dest='validate', action='store_true',
metavar='JOB_LIST', help='validate config file syntax (Does not'
help='validate layout file syntax (optionally ' 'validate config repo validity)')
'providing the path to a file with a list of '
'available job names)')
parser.add_argument('--version', dest='version', action='version', parser.add_argument('--version', dest='version', action='version',
version=self._get_version(), version=self._get_version(),
help='show zuul version') help='show zuul version')
@ -79,38 +75,19 @@ class Scheduler(zuul.cmd.ZuulApp):
self.stop_gear_server() self.stop_gear_server()
os._exit(0) os._exit(0)
def test_config(self, job_list_path): def test_config(self):
# See comment at top of file about zuul imports # See comment at top of file about zuul imports
import zuul.scheduler import zuul.scheduler
import zuul.launcher.gearman import zuul.launcher.client
import zuul.trigger.gerrit
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
try:
self.sched = zuul.scheduler.Scheduler(self.config, self.sched = zuul.scheduler.Scheduler(self.config,
testonly=True) testonly=True)
self.configure_connections() except Exception as e:
self.sched.registerConnections(self.connections, load=False) self.log.error("%s" % e)
layout = self.sched.testConfig(self.config.get('zuul', return -1
'layout_config'), return 0
self.connections)
if not job_list_path:
return False
failure = False
path = os.path.expanduser(job_list_path)
if not os.path.exists(path):
raise Exception("Unable to find job list: %s" % path)
jobs = set()
jobs.add('noop')
for line in open(path):
v = line.strip()
if v:
jobs.add(v)
for job in sorted(layout.jobs):
if job not in jobs:
print("FAILURE: Job %s not defined" % job)
failure = True
return failure
def start_gear_server(self): def start_gear_server(self):
pipe_read, pipe_write = os.pipe() pipe_read, pipe_write = os.pipe()
@ -223,14 +200,8 @@ def main():
scheduler.read_config() scheduler.read_config()
if scheduler.args.layout:
scheduler.config.set('zuul', 'layout_config', scheduler.args.layout)
if scheduler.args.validate: if scheduler.args.validate:
path = scheduler.args.validate sys.exit(scheduler.test_config())
if path is True:
path = None
sys.exit(scheduler.test_config(path))
if scheduler.config.has_option('zuul', 'pidfile'): if scheduler.config.has_option('zuul', 'pidfile'):
pid_fn = os.path.expanduser(scheduler.config.get('zuul', 'pidfile')) pid_fn = os.path.expanduser(scheduler.config.get('zuul', 'pidfile'))

View File

@ -293,11 +293,6 @@ class Scheduler(threading.Thread):
self.stopConnections() self.stopConnections()
self.wake_event.set() self.wake_event.set()
def testConfig(self, config_path, connections):
# Take the list of set up connections directly here rather than with
# registerConnections as we don't want to do the onLoad event yet.
return self._parseConfig(config_path, connections)
def registerConnections(self, connections, load=True): def registerConnections(self, connections, load=True):
# load: whether or not to trigger the onLoad for the connection. This # load: whether or not to trigger the onLoad for the connection. This
# is useful for not doing a full load during layout validation. # is useful for not doing a full load during layout validation.