From 68baa51d550acb9003a084c056e94e9f46bfe2e7 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 21 Jul 2016 15:47:25 -0400 Subject: [PATCH] Fix cross-manager handling of realm components --- buildman/manager/ephemeral.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/buildman/manager/ephemeral.py b/buildman/manager/ephemeral.py index a2e178d17..2c7bbc1df 100644 --- a/buildman/manager/ephemeral.py +++ b/buildman/manager/ephemeral.py @@ -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)