From fadee51affc5acaf27e8015cd54d3bd289a2a183 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Mon, 4 Mar 2024 11:44:33 -0500 Subject: [PATCH] handle missing host data, use self.maxjobs as default --- kojihub/scheduler.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kojihub/scheduler.py b/kojihub/scheduler.py index f3c26e0b..12ae9894 100644 --- a/kojihub/scheduler.py +++ b/kojihub/scheduler.py @@ -191,7 +191,6 @@ class TaskScheduler(object): self.active_tasks = [] self.free_tasks = [] - # TODO these things need proper config self.maxjobs = context.opts['MaxJobs'] self.capacity_overcommit = context.opts['CapacityOvercommit'] self.ready_timeout = context.opts['ReadyTimeout'] @@ -282,6 +281,11 @@ class TaskScheduler(object): host.setdefault('_load', 0.0) host.setdefault('_ntasks', 0) host.setdefault('_demand', 0.0) + # host data might be unset + hostdata = host['data'] + if hostdata is None: + hostdata = {} + host.setdefault('_maxjobs', hostdata.get('maxjobs') or self.maxjobs) # temporary test code logger.info(f'Host: {host}') ldiff = host['task_load'] - host['_load'] @@ -297,8 +301,8 @@ class TaskScheduler(object): min_avail = min(0, task['weight'] - self.capacity_overcommit) h_refused = refusals.get(task['task_id'], {}) for host in self.hosts_by_bin.get(task['_bin'], []): - if (host['ready'] and host['_ntasks'] < self.maxjobs and - host['_ntasks'] < host['data']['maxjobs'] and + if (host['ready'] and + host['_ntasks'] < host['_maxjobs'] and host['capacity'] - host['_load'] > min_avail and host['id'] not in h_refused): task['_hosts'].append(host) @@ -325,8 +329,7 @@ class TaskScheduler(object): [(h['name'], "%(_rank).2f" % h) for h in task['_hosts']]) for host in task['_hosts']: if (host['capacity'] - host['_load'] > min_avail and - host['_ntasks'] < self.maxjobs and - host['_ntasks'] < host['data']['maxjobs']): + host['_ntasks'] < host['_maxjobs']): # add run entry self.assign(task, host) # update our totals and rank