#3758 kojira: prioritize awaited repos
Closed 2 years ago by tkopecek. Opened 2 years ago by tkopecek.
tkopecek/koji issue3757  into  master

file modified
+20 -2
@@ -795,14 +795,32 @@ 

          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

+         awaited = self.session.listTasks(opts={'method': ['waitrepo'],

+                                                'state': [koji.TASK_STATES['FREE'],

+                                                          koji.TASK_STATES['ASSIGNED'],

+                                                          koji.TASK_STATES['OPEN']]})

+         awaited = set()

+         for task in awaited:

+             try:

+                 awaited.add(koji.parse_task_params('waitrepo', task['request'])['tag'])

+             except Exception:

+                 # ignore malformed tasks

+                 self.logger.debug(f"Malformed task: {task}")

+                 pass

+ 

+         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):

@mikem Do you think it is a reasonable idea? And what about multiplication factor?

Overall the the idea is fine. It will only really help a very narrow range of cases. Most issues we have with stale repos don't involve a waitrepo task.

The code that examines the tasks should catch errors so that a malformed task doesn't break kojira.

The adjustment needs to allow for the case where score_adjust is not set.

The factor could probably go higher, maybe 2?

1 new commit added

  • error handling
2 years ago

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

There's a bug. This call needs decode=True

awaited = self.session.listTasks(opts={'method': ['waitrepo'],
                                       'state': [koji.TASK_STATES['FREE'],
                                                 koji.TASK_STATES['ASSIGNED'],
                                                 koji.TASK_STATES['OPEN']]})

Also, we should probably allow for the possibility that the tag arg for the task is specified differently, e.g. by name.

Metadata Update from @mikem:
- Pull-request untagged with: testing-ready

2 years ago

Pull-Request has been closed by tkopecek

2 years ago
Metadata