osbs: Fresh koji session for getting metadata

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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-06-11 10:27:39 +02:00
parent 004ef31917
commit fa92e54c22

View File

@ -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'],