From 539e0242577bef29d84fe01ce71fd53d90d5656c Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Apr 22 2020 11:53:08 +0000 Subject: [PATCH 1/2] kojira: queue status file Fixes: https://pagure.io/koji/issue/2023 --- diff --git a/util/kojira b/util/kojira index d3a4226..7a60bbb 100755 --- a/util/kojira +++ b/util/kojira @@ -668,6 +668,14 @@ class RepoManager(object): self.updateTagScores() + if self.options.queue_file: + with open(self.options.queue_file, "wt") as f: + fmt = "%-40s %7s %5s\n" + f.write(fmt % ("Tag", "Expired", "Score")) + for tag in sorted(self.needed_tags.values(), key=lambda t: t['score'], reverse=True): + time_expired = time.time() - tag['expire_ts'] + f.write(fmt % (tag['taginfo']['name'], int(time_expired), int(tag['score']))) + # trigger deletes n_deletes = 0 for repo in to_list(self.repos.values()): @@ -993,6 +1001,8 @@ def get_options(): parser.add_option("-s", "--server", help="URL of XMLRPC server") parser.add_option("--topdir", help="Specify topdir") parser.add_option("--logfile", help="Specify logfile") + parser.add_option("--queue-file", + help="If specified, queue is dumped to separate status file each cycle") (options, args) = parser.parse_args() config = koji.read_config_files(options.configFile) @@ -1036,6 +1046,7 @@ def get_options(): 'cert': None, 'ca': '', # FIXME: unused, remove in next major release 'serverca': None, + 'queue_file': None, } if config.has_section(section): int_opts = ('deleted_repo_lifetime', 'max_repo_tasks', 'repo_tasks_limit', @@ -1044,7 +1055,7 @@ def get_options(): 'delete_batch_size', 'dist_repo_lifetime', 'sleeptime', 'recent_tasks_lifetime') str_opts = ('topdir', 'server', 'user', 'password', 'logfile', 'principal', 'keytab', - 'krbservice', 'cert', 'ca', 'serverca', 'debuginfo_tags', + 'krbservice', 'cert', 'ca', 'serverca', 'debuginfo_tags', 'queue_file', 'source_tags', 'separate_source_tags', 'ignore_tags') # FIXME: remove ca here bool_opts = ('verbose', 'debug', 'ignore_stray_repos', 'offline_retry', 'krb_rdns', 'krb_canon_host', 'no_ssl_verify', 'check_external_repos') From b4c1169da83e6fe5f1ffcd54e33e78ffbad0ee82 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Apr 22 2020 11:53:47 +0000 Subject: [PATCH 2/2] kojira: queue_file docs --- diff --git a/docs/source/utils.rst b/docs/source/utils.rst index 58e5a25..f1e5e16 100644 --- a/docs/source/utils.rst +++ b/docs/source/utils.rst @@ -91,6 +91,13 @@ 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 + every cycle. File would contain information about how long these + tags are expired and what is the computed score for them. This can + be used to debug and check in realtime the actual performance. Garbage Collector -----------------