add rate limiting to build queues
This commit is contained in:
parent
f0b19b26c9
commit
7877c6ab94
6 changed files with 36 additions and 8 deletions
|
@ -11,10 +11,22 @@ from endpoints.notificationhelper import spawn_notification
|
|||
from util.names import escape_tag
|
||||
from util.morecollections import AttrDict
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
MAX_BUILD_QUEUE_SIZE = app.config.get('MAX_BUILD_QUEUE_SIZE', -1)
|
||||
|
||||
|
||||
class MaximumBuildsQueuedException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def start_build(repository, prepared_build, pull_robot_name=None):
|
||||
queue_item_prefix = '%s/%s' % repository.namespace_user.username, repository.name
|
||||
available_builds = dockerfile_build_queue.num_available_jobs(queue_item_prefix)
|
||||
if available_builds >= MAX_BUILD_QUEUE_SIZE and MAX_BUILD_QUEUE_SIZE > -1:
|
||||
raise MaximumBuildsQueuedException()
|
||||
|
||||
host = app.config['SERVER_HOSTNAME']
|
||||
repo_path = '%s/%s/%s' % (host, repository.namespace_user.username, repository.name)
|
||||
|
||||
|
|
Reference in a new issue