| |
@@ -795,14 +795,41 @@
|
| |
if age < 0:
|
| |
self.logger.warning("Needed tag has future expire_ts: %r", entry)
|
| |
age = 0
|
| |
- entry['score'] = age * adj
|
| |
+ entry['score'] = age * adj * entry.get('score_adjust', 1)
|
| |
self.logger.debug("Needed tag %s got score %.2f",
|
| |
entry['taginfo']['name'], entry['score'])
|
| |
# so a day old unused repo gets about the regen same score as a
|
| |
# 2.4-hour-old, very popular repo
|
| |
|
| |
def updateTagScores(self):
|
| |
- for entry in list(self.needed_tags.values()):
|
| |
+ # call listTasks waitrepo
|
| |
+ tasks = self.session.listTasks(opts={'method': ['waitrepo'],
|
| |
+ 'decode': True,
|
| |
+ 'state': [koji.TASK_STATES['FREE'],
|
| |
+ koji.TASK_STATES['ASSIGNED'],
|
| |
+ koji.TASK_STATES['OPEN']]})
|
| |
+ awaited = set()
|
| |
+ if tasks:
|
| |
+ logger.debug("Checking %s active waitrepo tasks", len(tasks))
|
| |
+ for task in tasks:
|
| |
+ try:
|
| |
+ tag_param = koji.parse_task_params('waitrepo', task['request'])['tag']
|
| |
+ taginfo = getTag(self.session, tag_param)
|
| |
+ except Exception:
|
| |
+ # ignore malformed tasks
|
| |
+ self.logger.debug(f"Malformed task: {task}")
|
| |
+ continue
|
| |
+ if taginfo:
|
| |
+ awaited.add(taginfo['id'])
|
| |
+ else:
|
| |
+ self.logger.debug("Found waitrepo task %i with bad tag arg: %r",
|
| |
+ task['id'], tag_param)
|
| |
+
|
| |
+ for tag_id, entry in self.needed_tags.items():
|
| |
+ if tag_id in awaited:
|
| |
+ # score multiplication factor, prioritize tags which are being awaited for
|
| |
+ # not needed on every setTagScore call (initial point will not account it for)
|
| |
+ entry['score_adjust'] = 2
|
| |
self.setTagScore(entry)
|
| |
|
| |
def _delete_needed_tag(self, tag_id):
|
| |
This PR replaces #3758
Fixes: https://pagure.io/koji/issue/3757