fix situation were error happened before lock was released

This commit is contained in:
Ryan Petrello
2019-12-05 11:30:12 -05:00
parent 55d81cf74d
commit b5724adae5

View File

@@ -2246,6 +2246,8 @@ class RunProjectUpdate(BaseTask):
copy_tree(project_path, destination_folder) copy_tree(project_path, destination_folder)
def post_run_hook(self, instance, status): def post_run_hook(self, instance, status):
# To avoid hangs, very important to release lock even if errors happen here
try:
if self.job_private_data_dir: if self.job_private_data_dir:
# copy project folder before resetting to default branch # copy project folder before resetting to default branch
# because some git-tree-specific resources (like submodules) might matter # because some git-tree-specific resources (like submodules) might matter
@@ -2261,6 +2263,7 @@ class RunProjectUpdate(BaseTask):
except Exception: except Exception:
# this could have failed due to dirty tree, but difficult to predict all cases # this could have failed due to dirty tree, but difficult to predict all cases
logger.exception('Failed to restore project repo to prior state after {}'.format(instance.log_format)) logger.exception('Failed to restore project repo to prior state after {}'.format(instance.log_format))
finally:
self.release_lock(instance) self.release_lock(instance)
p = instance.project p = instance.project
if self.playbook_new_revision: if self.playbook_new_revision: