From e8d72b923d32916e6203eef97864df58e374d7d3 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: May 22 2023 15:41:51 +0000 Subject: [PATCH 1/3] kojira no_repo_effective_age setting --- diff --git a/docs/source/utils.rst b/docs/source/utils.rst index 8d3c3aa..f7f8c20 100644 --- a/docs/source/utils.rst +++ b/docs/source/utils.rst @@ -89,7 +89,7 @@ especially in relation to throttling in creating ``newRepo`` tasks. Note that you need to have your database set to use UTC, as otherwise you can end with weird behaviour. For details see https://pagure.io/koji/issue/2159 - + ``queue_file = None`` Writable path could be set here. In such case, kojira will write a list of currently monitored tags there with simple statistics in @@ -97,6 +97,12 @@ especially in relation to throttling in creating ``newRepo`` tasks. tags are expired and what is the computed score for them. This can be used to debug and check in realtime the actual performance. +``no_repo_effective_age = 2 days (172800)`` + When prioritizing repo regens, the age of the expired repo is the primary + factor. This value (measured in seconds) is used when there is no expired + repo (e.g. for a new build tag). + + Garbage Collector ----------------- diff --git a/util/kojira b/util/kojira index aeb4078..2b6cd3b 100755 --- a/util/kojira +++ b/util/kojira @@ -953,13 +953,15 @@ class RepoManager(object): # how expired are we? ts = 0 for repo in tag_repos.get(tag_id, []): + if repo.problem: + continue if repo.expire_ts: if repo.expire_ts > ts: ts = repo.expire_ts else: self.logger.warning("No expire timestamp for repo: %s", repo.repo_id) if ts == 0: - ts = time.time() + ts = time.time() - self.options.no_repo_effective_age entry = { 'taginfo': taginfo, @@ -1273,6 +1275,7 @@ def get_options(): 'deleted_repo_lifetime': 7 * 24 * 3600, # XXX should really be called expired_repo_lifetime 'dist_repo_lifetime': 7 * 24 * 3600, + 'no_repo_effective_age': 2 * 24 * 3600, 'check_external_repos': False, 'sleeptime': 15, 'cert': None, @@ -1284,7 +1287,7 @@ def get_options(): int_opts = ('deleted_repo_lifetime', 'max_repo_tasks', 'repo_tasks_limit', 'retry_interval', 'max_retries', 'offline_retry_interval', 'max_delete_processes', 'max_repo_tasks_maven', 'dist_repo_lifetime', - 'sleeptime') + 'sleeptime', 'no_repo_effective_age') str_opts = ('topdir', 'server', 'user', 'password', 'logfile', 'principal', 'keytab', 'cert', 'serverca', 'debuginfo_tags', 'queue_file', 'source_tags', 'separate_source_tags', 'ignore_tags') From 10110b845d2a56ab2a5cda3f2dce2bc43be025f8 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: May 22 2023 15:49:33 +0000 Subject: [PATCH 2/3] unit test --- diff --git a/tests/test_kojira/test_repo_manager.py b/tests/test_kojira/test_repo_manager.py index 475bcff..2c8cf51 100644 --- a/tests/test_kojira/test_repo_manager.py +++ b/tests/test_kojira/test_repo_manager.py @@ -131,6 +131,7 @@ class RepoManagerTest(unittest.TestCase): raise Exception('score should have increased') def test_check_needed(self): + self.options.no_repo_effective_age = 999 self.session.getBuildTargets.return_value = [ {'build_tag': 1, 'build_tag_name': 'tag 1'}, {'build_tag': 2, 'build_tag_name': 'tag 2'}, @@ -159,7 +160,7 @@ class RepoManagerTest(unittest.TestCase): # only the third tag should show up as needed expected = {3: - {'expire_ts': 1000, + {'expire_ts': 1, # time minus effective age 'needed_since': 1100, 'taginfo': { 'id': 3, From 10ac5e30ab28a329022cc85ec7242f091e61996a Mon Sep 17 00:00:00 2001 From: Mike McLean Date: May 23 2023 13:11:54 +0000 Subject: [PATCH 3/3] typo --- diff --git a/util/kojira b/util/kojira index 2b6cd3b..3032bea 100755 --- a/util/kojira +++ b/util/kojira @@ -953,7 +953,7 @@ class RepoManager(object): # how expired are we? ts = 0 for repo in tag_repos.get(tag_id, []): - if repo.problem: + if repo.problem(): continue if repo.expire_ts: if repo.expire_ts > ts: