mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[IMP] improve runbot scheduler algorithm
Now it is very simple: it always builds sticky branch if any, otherwise last pending job.
This commit is contained in:
parent
969f28f126
commit
4e1b44e3aa
@ -280,35 +280,21 @@ class runbot_repo(osv.osv):
|
|||||||
|
|
||||||
# launch new tests
|
# launch new tests
|
||||||
testing = bo.search_count(cr, uid, dom + [('state', '=', 'testing')])
|
testing = bo.search_count(cr, uid, dom + [('state', '=', 'testing')])
|
||||||
|
pending = bo.search_count(cr, uid, dom + [('state', '=', 'pending')])
|
||||||
|
|
||||||
while testing < repo.testing:
|
while testing < repo.testing and pending > 0:
|
||||||
# select sticky build if any
|
|
||||||
|
|
||||||
# pending_ids = bo.search(cr, uid, dom + [('state', '=', 'pending')])
|
# find sticky pending build if any, otherwise, last pending (by id, not by sequence) will do the job
|
||||||
|
pending_ids = bo.search(cr, uid, dom + [('state', '=', 'pending'), ('branch_id.sticky', '=', True)], limit=1)
|
||||||
|
if not pending_ids:
|
||||||
|
pending_ids = bo.search(cr, uid, dom + [('state', '=', 'pending')], order="id desc")
|
||||||
|
|
||||||
|
pending = bo.browse(cr, uid, pending_ids[0])
|
||||||
|
pending.schedule()
|
||||||
|
|
||||||
# select the next build to process
|
# compute the number of testing and pending jobs again
|
||||||
pending_ids = bo.search(cr, uid, dom + [('state', '=', 'pending')])
|
|
||||||
if pending_ids:
|
|
||||||
pending = bo.browse(cr, uid, pending_ids[0])
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
|
|
||||||
# gather information about currently running builds
|
|
||||||
running_ids = bo.search(cr, uid, dom + [('state', '=', 'running')])
|
|
||||||
running_len = len(running_ids)
|
|
||||||
running_max = 0
|
|
||||||
if running_ids:
|
|
||||||
running_max = bo.browse(cr, uid, running_ids[0]).sequence
|
|
||||||
|
|
||||||
# determine if pending one should be launched
|
|
||||||
if running_len < repo.running or pending.sequence >= running_max:
|
|
||||||
pending.schedule()
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
|
|
||||||
# compute the number of testing job again
|
|
||||||
testing = bo.search_count(cr, uid, dom + [('state', '=', 'testing')])
|
testing = bo.search_count(cr, uid, dom + [('state', '=', 'testing')])
|
||||||
|
pending = bo.search_count(cr, uid, dom + [('state', '=', 'pending')])
|
||||||
|
|
||||||
# terminate and reap doomed build
|
# terminate and reap doomed build
|
||||||
build_ids = bo.search(cr, uid, dom + [('state', '=', 'running')])
|
build_ids = bo.search(cr, uid, dom + [('state', '=', 'running')])
|
||||||
|
Loading…
Reference in New Issue
Block a user