From 4ca224b44bb6bee57708de4dbfd14480097fc7ec Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Mar 01 2024 16:59:01 +0000 Subject: implicit task refusals --- diff --git a/kojihub/scheduler.py b/kojihub/scheduler.py index b35d4d6..b5e54bc 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'] @@ -371,12 +370,14 @@ class TaskScheduler(object): # TODO fix if task['state'] == koji.TASK_STATES['ASSIGNED']: - # TODO check time since assigned - # if not taken within a timeout - # - if host not checking in, then make sure host marked unavail and free - # - if host *is* checking in, then treat as refusal and free - age = time.time() - min([r['create_ts'] for r in taskruns]) + assign_ts = min([r['create_ts'] for r in taskruns]) + age = time.time() - assign_ts if age > self.assign_timeout: + # has the host checked in since we assigned? + if host['update_ts'] and host['update_ts'] > assign_ts: + # treat this as an implicit refusal + # possibly an older koji version on builder + set_refusal(host['id'], task['task_id'], msg='assignment timeout') log_both('Task assignment timeout', task_id=task['task_id'], host_id=host['id']) kojihub.Task(task['task_id']).free() @@ -422,6 +423,9 @@ class TaskScheduler(object): values={'host_ids': [h['id'] for h in hosts_to_mark]}, ) update.execute() + # also update our data + for host in hosts_to_mark: + host['ready'] = False def get_active_runs(self): runs = get_task_runs([["active", True]])