Add temporary back-compat shims for the build manager

This commit is contained in:
Joseph Schorr 2016-07-18 13:50:16 -04:00
parent 2c1880b944
commit 4420b1bac9

View file

@ -41,7 +41,7 @@ class EtcdAction(object):
BuildInfo = namedtuple('BuildInfo', ['component', 'build_job', 'execution_id', 'executor_name'])
def createAsyncEtcdClient(worker_threads=1, **kwargs):
def _create_async_etcd_client(worker_threads=1, **kwargs):
client = etcd.Client(**kwargs)
async_executor = ThreadPoolExecutor(worker_threads)
return AsyncWrapper(client, executor=async_executor), async_executor
@ -57,7 +57,7 @@ class EphemeralBuilderManager(BaseManager):
}
def __init__(self, *args, **kwargs):
self._etcd_client_creator = kwargs.pop('etcd_creator', createAsyncEtcdClient)
self._etcd_client_creator = kwargs.pop('etcd_creator', _create_async_etcd_client)
super(EphemeralBuilderManager, self).__init__(*args, **kwargs)
@ -153,7 +153,9 @@ class EphemeralBuilderManager(BaseManager):
if etcd_result is None:
return
if etcd_result.action == EtcdAction.EXPIRE:
if etcd_result.action != EtcdAction.EXPIRE:
return
# Handle the expiration
logger.debug('Builder expired, clean up the old build node')
job_metadata = json.loads(etcd_result._prev_node.value)
@ -215,8 +217,10 @@ class EphemeralBuilderManager(BaseManager):
# Create the build information block for the registered realm.
build_job = BuildJob(AttrDict(realm_spec['job_queue_item']))
execution_id = realm_spec['execution_id']
executor_name = realm_spec['executor_name']
# TODO(jschorr): Remove the back-compat lookups once we've finished the rollout.
execution_id = realm_spec.get('execution_id', realm_spec.get('builder_id', None))
executor_name = realm_spec.get('executor_name', 'EC2Executor')
build_info = BuildInfo(component=component, build_job=build_job, execution_id=execution_id,
executor_name=executor_name)
@ -433,6 +437,9 @@ class EphemeralBuilderManager(BaseManager):
'execution_id': execution_id,
'executor_name': started_with_executor.name,
'job_queue_item': build_job.job_item,
# TODO: remove this back-compat field once we finish the rollout.
'builder_id': execution_id,
})
try: