Switch build queue limiter query to use total number of alive jobs

This is slightly more accurate and, not being based on time, will work better under MySQL
This commit is contained in:
Joseph Schorr 2018-02-21 14:04:40 -05:00
parent d77aa9228f
commit e446eb5757
2 changed files with 10 additions and 8 deletions

View file

@ -31,8 +31,8 @@ def start_build(repository, prepared_build, pull_robot_name=None):
if repository.namespace_user.maximum_queued_builds_count is not None:
queue_item_canonical_name = [repository.namespace_user.username]
available_builds = dockerfile_build_queue.num_available_jobs(queue_item_canonical_name)
if available_builds >= repository.namespace_user.maximum_queued_builds_count:
alive_builds = dockerfile_build_queue.num_alive_jobs(queue_item_canonical_name)
if alive_builds >= repository.namespace_user.maximum_queued_builds_count:
logger.debug('Prevented queueing of build under namespace %s due to reaching max: %s',
repository.namespace_user.username,
repository.namespace_user.maximum_queued_builds_count)