Get the new build system working for enterprise

This commit is contained in:
Joseph Schorr 2014-11-13 19:41:17 -05:00
parent f93c0a46e8
commit 4322b5f81c
8 changed files with 319 additions and 55 deletions

View file

@ -15,10 +15,16 @@ from buildjob import BuildJob, BuildJobLoadException
logger = logging.getLogger(__name__)
WORK_CHECK_TIMEOUT = 30
WORK_CHECK_TIMEOUT = 10
TIMEOUT_PERIOD_MINUTES = 20
RESERVATION_SECONDS = (TIMEOUT_PERIOD_MINUTES + 5) * 60
class BUILD_JOB_RESULT(object):
""" Build job result enum """
INCOMPLETE = 'incomplete'
COMPLETE = 'complete'
ERROR = 'error'
class BuilderServer(object):
""" Server which handles both HTTP and WAMP requests, managing the full state of the build
controller.
@ -101,18 +107,20 @@ class BuilderServer(object):
self._session_factory.remove(component)
def _job_complete(self, build_job, job_status):
if job_status == 'incomplete':
self._queue.incomplete(build_job.job_item(), restore_retry=True)
elif job_status == 'error':
if job_status == BUILD_JOB_RESULT.INCOMPLETE:
self._queue.incomplete(build_job.job_item(), restore_retry=True, retry_after=30)
elif job_status == BUILD_JOB_RESULT.ERROR:
self._queue.incomplete(build_job.job_item(), restore_retry=False)
else:
self._queue.complete(job)
self._queue.complete(build_job.job_item())
self._job_count = self._job_count - 1
if self._current_status == 'shutting_down' and not self._job_count:
self._shutdown_event.set()
# TODO: check for work here?
@trollius.coroutine
def _work_checker(self):
while self._current_status == 'running':
@ -135,7 +143,7 @@ class BuilderServer(object):
logger.debug('Build job scheduled. Running: %s', self._job_count)
else:
logger.debug('All workers are busy. Requeuing.')
self._queue.incomplete(job_item, restore_retry=True)
self._queue.incomplete(job_item, restore_retry=True, retry_after=0)
yield From(trollius.sleep(WORK_CHECK_TIMEOUT))