From bfbdf314b387db42486ea19c569711bf15093794 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Apr 09 2019 19:36:42 +0000 Subject: PR#1363: Use createrepo_update even for first repo run Merges #1363 https://pagure.io/koji/pull-request/1363 Fixes: #1354 https://pagure.io/koji/issue/1354 [RFE] use createrepo_c --update on new repos (when possible) --- diff --git a/builder/kojid b/builder/kojid index 08584a7..75f8a7d 100755 --- a/builder/kojid +++ b/builder/kojid @@ -2135,7 +2135,7 @@ class ChainMavenTask(MultiPlatformTask): del todo[package] try: results = self.wait(to_list(running.keys())) - except (six.moves.xmlrpc_client.Fault, koji.GenericError) as e: + except (six.moves.xmlrpc_client.Fault, koji.GenericError): # One task has failed, wait for the rest to complete before the # chainmaven task fails. self.wait(all=True) should thrown an exception. self.wait(all=True) @@ -5026,9 +5026,21 @@ class NewRepoTask(BaseTaskHandler): #only shadowbuild tags should start with SHADOWBUILD, their repos are auto #expired. so lets get the most recent expired tag for newRepo shadowbuild tasks. if tinfo['name'].startswith('SHADOWBUILD'): - oldrepo = self.session.getRepo(tinfo['id'], state=koji.REPO_EXPIRED) + oldrepo_state = koji.REPO_EXPIRED else: - oldrepo = self.session.getRepo(tinfo['id'], state=koji.REPO_READY) + oldrepo_state = koji.REPO_READY + oldrepo = self.session.getRepo(tinfo['id'], state=oldrepo_state) + # If there is no old repo, try to find first usable repo in + # inheritance chain and use it as a source. oldrepo is not used if + # createrepo_update is not set, so don't waste call in such case. + if not oldrepo and self.options.createrepo_update: + tags = self.session.getFullInheritance(tinfo['id']) + # we care about best candidate which should be (not necessarily) + # something on higher levels. Sort tags according to depth. + for tag in sorted(tags, key=lambda x: x['currdepth']): + oldrepo = self.session.getRepo(tag['parent_id'], state=oldrepo_state) + if oldrepo: + break subtasks = {} for arch in arches: arglist = [repo_id, arch, oldrepo] @@ -5106,7 +5118,10 @@ class CreaterepoTask(BaseTaskHandler): cmd.extend(['-g', groupdata]) #attempt to recycle repodata from last repo if pkglist and oldrepo and self.options.createrepo_update: - oldpath = self.pathinfo.repo(oldrepo['id'], rinfo['tag_name']) + # old repo could be from inherited tag, so path needs to be + # composed from that tag, not rinfo['tag_name'] + oldrepo = self.session.repoInfo(oldrepo['id'], strict=True) + oldpath = self.pathinfo.repo(oldrepo['id'], oldrepo['tag_name']) olddatadir = '%s/%s/repodata' % (oldpath, arch) if not os.path.isdir(olddatadir): self.logger.warn("old repodata is missing: %s" % olddatadir)