diff --git a/scheduler/schedule.py b/scheduler/schedule.py index dd806be0fe55cbeb297db28cd8971d531739be05..26bae56478fda8d3be0c7a52164c976d03b8f874 100755 --- a/scheduler/schedule.py +++ b/scheduler/schedule.py @@ -38,10 +38,10 @@ def error(**kwargs): try: nomad_token = os.environ['NOMAD_TOKEN'] except KeyError: - error(message='Error obtaining Nomad token!') + error(comment='Error obtaining Nomad token!') sys.exit(1) -debug(message='Connecting to Nomad at: {}'.format(os.getenv('NOMAD_ADDR', None))) +debug(comment='Connecting to Nomad at: {}'.format(os.getenv('NOMAD_ADDR', None))) n = nomad.Nomad(secure=True, token=nomad_token, timeout=5, verify=False) #print('nomad self token: {}'.format(n.acl.get_self_token())) @@ -49,7 +49,7 @@ try: with open(CONFIG) as f: repoconf = yaml.load(f.read()) except IOError as e: - error(message='Unable to read configuration file {}'.format(CONFIG), exception=str(e)) + error(comment='Unable to read configuration file {}'.format(CONFIG), exception=str(e)) sys.exit(1) # Don't fail even with an empty config file @@ -58,14 +58,14 @@ if not repoconf: jobs = {} for repofile in os.listdir(REPOPATH): - debug(message='Syncing {}'.format(repofile)) + debug(comment='Syncing {}'.format(repofile)) try: config = configparser.ConfigParser() with open('{}/{}'.format(REPOPATH, repofile), 'r') as f: config.read_file(f) except IOError as e: - error(message='error while reading repo: {}/{}'.format(REPOPATH, repofile), exception=str(e)) + error(comment='error while reading repo: {}/{}'.format(REPOPATH, repofile), exception=str(e)) continue for rid in config.sections(): @@ -101,20 +101,20 @@ for repofile in os.listdir(REPOPATH): try: job = n.job.dispatch_job(JOBNAME, payload=payload) - log(message='dispatched job', repoid=rid, job=job, payload=payload) + log(comment='dispatched job', repoid=rid, job=job, payload=payload) jobs[job['DispatchedJobID']] = 'created' except (exceptions.URLNotFoundNomadException, exceptions.BaseNomadException) as e: - error(message='Error dispatching job', exception=e.nomad_resp.text) + error(comment='Error dispatching job', exception=e.nomad_resp.text) raise e -log(message='Waiting for jobs to finish') +log(comment='Waiting for jobs to finish') results = {} while jobs: for j in jobs.keys(): state = n.job.get_job(j) - log(message='Job state', job=j, state=state['Status']) + log(comment='Job state', job=j, state=state['Status']) if state['Status'] == 'dead': allocations = n.job.get_allocations(j) @@ -128,7 +128,7 @@ while jobs: pass output.append(o) except nomad.api.exceptions.URLNotFoundNomadException as e: - error(message='File not found for allocation {}'.format(a['ID']), exception=str(e)) + error(comment='File not found for allocation {}'.format(a['ID']), exception=str(e)) results[j] = output del jobs[j] @@ -136,10 +136,10 @@ while jobs: jobs[j] = state['Status'] time.sleep(STATUS_CHECK_SECS) -log(message='All done!') +log(comment='All done!') final_results = [] for j in results.keys(): - log(message='Job result', job=j, result=results[j]) + log(comment='Job result', job=j, result=results[j]) exit_codes = [x[0]['exit_code'] for x in results.values()] @@ -148,7 +148,7 @@ total_pre_count = sum([x[0]['pre_count'] for x in results.values()]) total_post_count = sum([x[0]['post_count'] for x in results.values()]) total_changes = list(itertools.chain.from_iterable([x[0]['changes'] for x in results.values()])) -log(message='Job summary', +log(comment='Job summary', #results=results, total_results = len(exit_codes), total_results_by_exit_code = total_results_by_exit,