Removing realm key from etcd.

This commit is contained in:
Charlton Austin 2016-12-02 11:13:17 -05:00
parent 376578115f
commit 0c7a2e4645
2 changed files with 6 additions and 4 deletions

View file

@ -727,12 +727,14 @@ 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(self._etcd_realm_key(build_info.component.builder_realm)))
yield From(self.delete_etcd_key(self._etcd_metric_key(build_info.component.builder_realm)))
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):
def delete_etcd_key(self, etcd_key):
try:
yield From(self._etcd_client.delete(job_key))
yield From(self._etcd_client.delete(etcd_key))
except (KeyError, etcd.EtcdKeyError):
logger.warning('Could not delete job key %s', job_key)
logger.warning('Could not delete etcd key %s', etcd_key)

View file

@ -30,7 +30,7 @@ class EtcdCanceller(object):
""" Writes etcd message to cancel build_uuid. """
logger.info("Cancelling build %s".format(build_uuid))
try:
self._etcd_client.write("{}{}".format(self._cancel_prefix, build_uuid), build_uuid)
self._etcd_client.write("{}{}".format(self._cancel_prefix, build_uuid), build_uuid, ttl=0)
return True
except etcd.EtcdException:
logger.exception("Failed to write to etcd client %s", build_uuid)