diff --git a/buildman/manager/ephemeral.py b/buildman/manager/ephemeral.py index 58b72fb13..392c5889d 100644 --- a/buildman/manager/ephemeral.py +++ b/buildman/manager/ephemeral.py @@ -490,11 +490,7 @@ class EphemeralBuilderManager(BaseManager): logger.error('Could not start ephemeral worker for build %s', build_uuid) # Delete the associated build job record. - try: - yield From(self._etcd_client.delete(job_key)) - except (KeyError, etcd.EtcdKeyError): - logger.warning('Could not delete job key %s', job_key) - + yield From(self.delete_etcd_key(job_key)) raise Return(False, self._ephemeral_api_timeout) # Job was started! @@ -731,4 +727,12 @@ class EphemeralBuilderManager(BaseManager): raise Return(False) got_lock = yield From(self._take_etcd_atomic_lock('job-cancelled', build_uuid, build_info.execution_id)) if got_lock: + yield From(self.delete_etcd_key(os.path.join(self._etcd_job_prefix, build_uuid))) yield From(self.kill_builder_executor(build_uuid)) + + @coroutine + def delete_etcd_key(self, job_key): + try: + yield From(self._etcd_client.delete(job_key)) + except (KeyError, etcd.EtcdKeyError): + logger.warning('Could not delete job key %s', job_key)