mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 21:07:39 -02:30
fix situation were error happened before lock was released
This commit is contained in:
@@ -2246,22 +2246,25 @@ 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):
|
||||||
if self.job_private_data_dir:
|
# To avoid hangs, very important to release lock even if errors happen here
|
||||||
# copy project folder before resetting to default branch
|
try:
|
||||||
# because some git-tree-specific resources (like submodules) might matter
|
if self.job_private_data_dir:
|
||||||
self.make_local_copy(
|
# copy project folder before resetting to default branch
|
||||||
instance.get_project_path(check_if_exists=False), os.path.join(self.job_private_data_dir, 'project'),
|
# because some git-tree-specific resources (like submodules) might matter
|
||||||
instance.scm_type, self.playbook_new_revision
|
self.make_local_copy(
|
||||||
)
|
instance.get_project_path(check_if_exists=False), os.path.join(self.job_private_data_dir, 'project'),
|
||||||
if self.original_branch:
|
instance.scm_type, self.playbook_new_revision
|
||||||
# for git project syncs, non-default branches can be problems
|
)
|
||||||
# restore to branch the repo was on before this run
|
if self.original_branch:
|
||||||
try:
|
# for git project syncs, non-default branches can be problems
|
||||||
self.original_branch.checkout()
|
# restore to branch the repo was on before this run
|
||||||
except Exception:
|
try:
|
||||||
# this could have failed due to dirty tree, but difficult to predict all cases
|
self.original_branch.checkout()
|
||||||
logger.exception('Failed to restore project repo to prior state after {}'.format(instance.log_format))
|
except Exception:
|
||||||
self.release_lock(instance)
|
# 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))
|
||||||
|
finally:
|
||||||
|
self.release_lock(instance)
|
||||||
p = instance.project
|
p = instance.project
|
||||||
if self.playbook_new_revision:
|
if self.playbook_new_revision:
|
||||||
instance.scm_revision = self.playbook_new_revision
|
instance.scm_revision = self.playbook_new_revision
|
||||||
|
|||||||
Reference in New Issue
Block a user