kojira: avoid race condition that causes "unknown task" errors
This commit is contained in:
parent
f71804d039
commit
fea969e91b
1 changed files with 14 additions and 0 deletions
14
util/kojira
14
util/kojira
|
|
@ -201,6 +201,7 @@ class RepoManager(object):
|
|||
self._local.session = session
|
||||
self.repos = {}
|
||||
self.tasks = {}
|
||||
self.recent_tasks = {}
|
||||
self.other_tasks = {}
|
||||
self.needed_tags = {}
|
||||
self.tag_use_stats = {}
|
||||
|
|
@ -533,6 +534,13 @@ class RepoManager(object):
|
|||
- check for other newRepo tasks (not generated by us)
|
||||
"""
|
||||
|
||||
# prune recent tasks
|
||||
now = time.time()
|
||||
for task_id in self.recent_tasks:
|
||||
if now - self.recent_tasks[task_id] > 600:
|
||||
del self.recent_tasks[task_id]
|
||||
|
||||
# check on current tasks
|
||||
task_ids = list(self.tasks)
|
||||
self.session.multicall = True
|
||||
for task_id in task_ids:
|
||||
|
|
@ -542,9 +550,11 @@ class RepoManager(object):
|
|||
tag_id = self.tasks[task_id]['tag_id']
|
||||
if tstate == 'CLOSED':
|
||||
self.logger.info("Finished: newRepo task %s for tag %s" % (task_id, tag_id))
|
||||
self.recent_tasks[task_id] = time.time()
|
||||
del self.tasks[task_id]
|
||||
elif tstate in ('CANCELED', 'FAILED'):
|
||||
self.logger.info("Problem: newRepo task %s for tag %s is %s" % (task_id, tag_id, tstate))
|
||||
self.recent_tasks[task_id] = time.time()
|
||||
del self.tasks[task_id]
|
||||
else:
|
||||
self.tasks[task_id]['taskinfo'] = tinfo
|
||||
|
|
@ -676,10 +686,14 @@ class RepoManager(object):
|
|||
if task_id in self.tasks:
|
||||
# we already have a task
|
||||
continue
|
||||
elif task_id in self.recent_tasks:
|
||||
# avoiding a race, see https://pagure.io/koji/issue/942
|
||||
continue
|
||||
else:
|
||||
# should not happen
|
||||
logger.warning('Needed tag refers to unknown task. '
|
||||
'%s -> %i', tagname, task_id)
|
||||
# we'll advance and create a new task
|
||||
taskopts = {}
|
||||
if koji.util.multi_fnmatch(tagname, debuginfo_pat):
|
||||
taskopts['debuginfo'] = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue