Merge "Remove layout option, adapt -t option accordingly" into feature/zuulv3

This commit is contained in:
Jenkins 2017-02-23 19:35:59 +00:00 committed by Gerrit Code Review
commit 28452c246b
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)
self.sched = zuul.scheduler.Scheduler(self.config, try:
testonly=True) self.sched = zuul.scheduler.Scheduler(self.config,
self.configure_connections() testonly=True)
self.sched.registerConnections(self.connections, load=False) except Exception as e:
layout = self.sched.testConfig(self.config.get('zuul', self.log.error("%s" % e)
'layout_config'), return -1
self.connections) return 0
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()
@ -239,14 +216,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.