Add version checking to the python side

This commit is contained in:
Joseph Schorr 2014-12-01 12:11:23 -05:00
parent 09cc4ba4c1
commit 4f5bf8185a

View file

@ -20,6 +20,8 @@ HEARTBEAT_DELTA = datetime.timedelta(seconds=30)
HEARTBEAT_TIMEOUT = 10
INITIAL_TIMEOUT = 25
SUPPORTED_WORKER_VERSIONS = ['0.1-beta']
logger = logging.getLogger(__name__)
class ComponentStatus(object):
@ -281,14 +283,18 @@ class BuildComponent(BaseComponent):
""" Ping pong. """
return 'pong'
def _on_ready(self, token):
def _on_ready(self, token, version):
if not version in SUPPORTED_WORKER_VERSIONS:
logger.warning('Build component (token "%s") is running an out-of-date version: %s', version)
return False
if self._component_status != 'waiting':
logger.warning('Build component (token "%s") is already connected', self.expected_token)
return
return False
if token != self.expected_token:
logger.warning('Builder token mismatch. Expected: "%s". Found: "%s"', self.expected_token, token)
return
return False
self._set_status(ComponentStatus.RUNNING)