update_manager: don't allow repo init waiters to return success on a failure

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-05-09 12:47:33 -04:00
parent e69ac489c7
commit f339aa7454
1 changed files with 9 additions and 1 deletions

View File

@ -847,6 +847,7 @@ class GitRepo:
"""
self.init_condition = None
self.initialized = False
self.git_operation_lock = Lock()
self.fetch_timeout_handle = None
self.fetch_input_recd = False
@ -855,7 +856,9 @@ class GitRepo:
if self.init_condition is not None:
# No need to initialize multiple requests
await self.init_condition.wait()
return
if self.initialized:
return
self.initialized = False
self.init_condition = Condition()
self.git_messages.clear()
try:
@ -936,6 +939,8 @@ class GitRepo:
except Exception:
logging.exception(f"Git Repo {self.alias}: Initialization failure")
raise
else:
self.initialized = True
finally:
self.init_condition.notify_all()
self.init_condition = None
@ -943,6 +948,9 @@ class GitRepo:
async def wait_for_init(self):
if self.init_condition is not None:
await self.init_condition.wait()
if not self.initialized:
raise self.server.error(
f"Git Repo {self.alias}: Initialization failure")
async def update_repo_status(self):
async with self.git_operation_lock: