From fa92e54c228ffd1eee8361016df310e8ccceeb4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 11 Jun 2018 10:27:39 +0200 Subject: [PATCH] osbs: Fresh koji session for getting metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The task can take a while to finish, and it's possible for the authenticated session to expire in the mean time. Watching the task will work, because that happens by spawning `koji watch-task` as subprocess. We can work around this by creating a fresh unauthenticated session for getting the task results. Signed-off-by: Lubomír Sedlář --- pungi/phases/osbs.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pungi/phases/osbs.py b/pungi/phases/osbs.py index 85007e46..14db0561 100644 --- a/pungi/phases/osbs.py +++ b/pungi/phases/osbs.py @@ -73,18 +73,23 @@ class OSBSThread(WorkerThread): % (task_id, log_file)) scratch = config.get('scratch', False) - self._add_metadata(koji.koji_proxy, variant, task_id, compose, scratch) + self._add_metadata(variant, task_id, compose, scratch) self.pool.log_info('[DONE ] %s' % msg) - def _add_metadata(self, koji_proxy, variant, task_id, compose, is_scratch): + def _add_metadata(self, variant, task_id, compose, is_scratch): + # Create new Koji session. The task could take so long to finish that + # our session will expire. This second session does not need to be + # authenticated since it will only do reading operations. + koji = kojiwrapper.KojiWrapper(compose.conf['koji_profile']) + # Create metadata metadata = { 'compose_id': compose.compose_id, 'koji_task': task_id, } - result = koji_proxy.getTaskResult(task_id) + result = koji.koji_proxy.getTaskResult(task_id) if is_scratch: metadata.update({ 'repositories': result['repositories'], @@ -95,8 +100,8 @@ class OSBSThread(WorkerThread): variant.uid, {}).setdefault('scratch', []).append(metadata) else: build_id = int(result['koji_builds'][0]) - buildinfo = koji_proxy.getBuild(build_id) - archives = koji_proxy.listArchives(build_id) + buildinfo = koji.koji_proxy.getBuild(build_id) + archives = koji.koji_proxy.listArchives(build_id) metadata.update({ 'name': buildinfo['name'],