Merge pull request #2203 from charltonaustin/fix_build_component_cleanup
Adding in a cancel method to the build component so we can properly c…
This commit is contained in:
commit
0aa6e6cd58
3 changed files with 11 additions and 2 deletions
|
@ -490,3 +490,9 @@ class BuildComponent(BaseComponent):
|
|||
|
||||
# Remove the job reference.
|
||||
self._current_job = None
|
||||
|
||||
@trollius.coroutine
|
||||
def cancel_build(self):
|
||||
self.parent_manager.build_component_disposed(self, True)
|
||||
self._current_job = None
|
||||
yield From(self._set_status(ComponentStatus.RUNNING))
|
||||
|
|
|
@ -727,10 +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.kill_builder_executor(build_uuid))
|
||||
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))
|
||||
# This is outside the lock so we can un-register the component wherever it is registered to.
|
||||
yield From(build_info.component.cancel_build())
|
||||
|
||||
@coroutine
|
||||
def delete_etcd_key(self, etcd_key):
|
||||
|
|
|
@ -747,7 +747,8 @@ class BUILD_PHASE(object):
|
|||
def is_terminal_phase(cls, phase):
|
||||
return (phase == cls.COMPLETE or
|
||||
phase == cls.ERROR or
|
||||
phase == cls.INTERNAL_ERROR)
|
||||
phase == cls.INTERNAL_ERROR or
|
||||
phase == cls.CANCELLED)
|
||||
|
||||
|
||||
class QueueItem(BaseModel):
|
||||
|
|
Reference in a new issue