From 969f28f12638b53eeb6a663865ae56d65830cf99 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Fri, 4 Jul 2014 14:12:12 +0200 Subject: [PATCH] [FIX] correctly skip builds when they get too old --- runbot/runbot.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/runbot/runbot.py b/runbot/runbot.py index 2fb18125..e6380369 100644 --- a/runbot/runbot.py +++ b/runbot/runbot.py @@ -265,10 +265,8 @@ class runbot_repo(osv.osv): Build.create(cr, uid, v) # skip old builds (if their sequence number is too low, they will not ever be built) - max_seq_id = Build.search(cr, uid, [('repo_id', '=', repo.id)], limit=1)[0] - max_seq = Build.browse(cr, uid, max_seq_id).sequence - skippable_domain = [('repo_id', '=', repo.id), ('state', '=', 'pending'), ('sequence', '<', max_seq - repo.running)] - to_be_skipped_ids = Build.search(cr, uid, skippable_domain) + skippable_domain = [('repo_id', '=', repo.id), ('state', '=', 'pending')] + to_be_skipped_ids = Build.search(cr, uid, skippable_domain, order='sequence', offset=repo.running) Build.write(cr, uid, to_be_skipped_ids, {'state': 'done', 'result': 'skipped'}) def scheduler(self, cr, uid, ids=None, context=None): @@ -281,9 +279,14 @@ class runbot_repo(osv.osv): bo.schedule(cr, uid, build_ids) # launch new tests - testing = bo.search(cr, uid, dom + [('state', '=', 'testing')], count=True) + testing = bo.search_count(cr, uid, dom + [('state', '=', 'testing')]) while testing < repo.testing: + # select sticky build if any + + # pending_ids = bo.search(cr, uid, dom + [('state', '=', 'pending')]) + + # select the next build to process pending_ids = bo.search(cr, uid, dom + [('state', '=', 'pending')]) if pending_ids: @@ -305,7 +308,7 @@ class runbot_repo(osv.osv): break # compute the number of testing job again - testing = bo.search(cr, uid, dom + [('state', '=', 'testing')], count=True) + testing = bo.search_count(cr, uid, dom + [('state', '=', 'testing')]) # terminate and reap doomed build build_ids = bo.search(cr, uid, dom + [('state', '=', 'running')])