From df55636d6dcb4a27d8fdf0dc1e9955924ddfc5e5 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Mar 06 2024 10:14:12 +0000 Subject: implicit task refusals --- diff --git a/kojihub/scheduler.py b/kojihub/scheduler.py index 511fcd8..d80f8fd 100644 --- a/kojihub/scheduler.py +++ b/kojihub/scheduler.py @@ -387,12 +387,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() @@ -438,6 +440,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]])