Add support for adjusting etcd ttl on job_heartbeat. Switch the heartbeat method to a coroutine.

This commit is contained in:
Jake Moshenko 2014-12-22 17:24:44 -05:00
parent 2b6c2a2a50
commit 34bf92673b
6 changed files with 62 additions and 13 deletions

View file

@ -24,6 +24,8 @@ MINIMUM_JOB_EXTENSION = timedelta(minutes=2)
WEBSOCKET_PORT = 8787
CONTROLLER_PORT = 8686
HEARTBEAT_PERIOD_SEC = 30
class BuildJobResult(object):
""" Build job result enum """
INCOMPLETE = 'incomplete'
@ -52,6 +54,7 @@ class BuilderServer(object):
self._job_heartbeat,
self._job_complete,
manager_public_ip,
HEARTBEAT_PERIOD_SEC,
)
self._lifecycle_manager_config = lifecycle_manager_config
@ -140,7 +143,8 @@ class BuilderServer(object):
@trollius.coroutine
def _work_checker(self):
while self._current_status == 'running':
logger.debug('Checking for more work for %d active workers', self._lifecycle_manager.num_workers())
logger.debug('Checking for more work for %d active workers',
self._lifecycle_manager.num_workers())
job_item = self._queue.get(processing_time=self._lifecycle_manager.setup_time())
if job_item is None:
logger.debug('No additional work found. Going to sleep for %s seconds', WORK_CHECK_TIMEOUT)