Fix cross-manager handling of realm components

This commit is contained in:
Joseph Schorr 2016-07-21 15:47:25 -04:00
parent cf630838f0
commit 68baa51d55

View file

@ -196,12 +196,16 @@ class EphemeralBuilderManager(BaseManager):
build_job = BuildJob(AttrDict(realm_spec['job_queue_item']))
build_uuid = build_job.build_uuid
logger.debug('Realm key expired for build %s', build_uuid)
build_info = self._build_uuid_to_info.pop(build_uuid, None)
if build_info is not None:
# We were not the manager which the worker connected to, remove the bookkeeping for it
logger.debug('Unregistering unused component for build %s', build_uuid)
self._component_to_job.pop(build_info.component, None)
self.unregister_component(build_info.component)
# Pop the component off. If we find one, then the build has not connected to this manager,
# so we can safely unregister its component.
component = self._component_to_job.pop(build_info.component, None)
if component is not None:
# We were not the manager which the worker connected to, remove the bookkeeping for it
logger.debug('Unregistering unused component for build %s', build_uuid)
self.unregister_component(build_info.component)
else:
logger.warning('Unexpected action (%s) on realm key: %s', etcd_result.action, etcd_result.key)