#1626 build can wait for actual repo
Merged 2 years ago by tkopecek. Opened 2 years ago by tkopecek.
tkopecek/koji issue1619a  into  master

file modified
+3 -1
@@ -993,7 +993,9 @@ 

              # use of this option is governed by policy

              self.session.host.assertPolicy('build_from_repo_id', policy_data)

          if not repo_info:

-             repo_info = self.getRepo(build_tag)  #(subtask)

+             wait_builds = [koji.parse_NVR(nvr) for nvr in opts.get('wait_builds', [])]

+             repo_info = self.getRepo(build_tag, builds=wait_builds,

+                                      wait=opts.get('wait_repo'))  #(subtask)

              self.event_id = self.session.getLastEvent()['id']

          srpm = self.getSRPM(src, build_tag, repo_info['id'])

          h = self.readSRPMHeader(srpm)

file modified
+5 -1
@@ -474,6 +474,10 @@ 

                        help=_("Wait on the build, even if running in the background"))

      parser.add_option("--nowait", action="store_false", dest="wait",

                        help=_("Don't wait on build"))

+     parser.add_option("--wait-repo", action="store_true",

+                        help=_("Wait for the actual buildroot repo of given target"))

+     parser.add_option("--wait-build", metavar="NVR", action="append", dest="wait_builds",

+                        default=[], help=_("Wait for the given nvr to appear in buildroot repo"))

      parser.add_option("--quiet", action="store_true",

                        help=_("Do not print the task information"), default=options.quiet)

      parser.add_option("--arch-override", help=_("Override build arches"))
@@ -508,7 +512,7 @@ 

      opts = {}

      if build_opts.arch_override:

          opts['arch_override'] = koji.parse_arches(build_opts.arch_override)

-     for key in ('skip_tag', 'scratch', 'repo_id', 'fail_fast'):

+     for key in ('skip_tag', 'scratch', 'repo_id', 'fail_fast', 'wait_repo', 'wait_builds'):

          val = getattr(build_opts, key)

          if val is not None:

              opts[key] = val

file modified
+23 -9
@@ -544,21 +544,35 @@ 

                                     tag['name'],

                                     ', '.join(sorted(tag_arches))))

  

-     def getRepo(self, tag):

+     def getRepo(self, tag, builds=None, wait=False):

          """

          Get the active repo for the given tag.  If there is no repo available,

          wait for a repo to be created.

+ 

+         if wait is True - always wait for new repo

+         if builds are present, wait until repo doesn't contain these

          """

-         repo_info = self.session.getRepo(tag)

-         if not repo_info:

-             #make sure there is a target

+         if wait:

+             create_ts = time.time()

+         else:

+             create_ts = None

+             repo_info = self.session.getRepo(tag)

              taginfo = self.session.getTag(tag, strict=True)

-             targets = self.session.getBuildTargets(buildTagID=taginfo['id'])

-             if not targets:

-                 raise koji.BuildError('no repo (and no target) for tag %s' % taginfo['name'])

-             #wait for it

+             if not repo_info:

+                 #make sure there is a target

+                 targets = self.session.getBuildTargets(buildTagID=taginfo['id'])

+                 if not targets:

+                     raise koji.BuildError('no repo (and no target) for tag %s' % taginfo['name'])

+                 wait = True

+             elif builds:

+                 build_infos = [koji.parse_NVR(build) for build in builds]

+                 if not koji.util.checkForBuilds(self.session, taginfo['id'],

+                                                 build_infos, repo_info['create_event']):

+                     wait = True

+ 

+         if wait:

              task_id = self.session.host.subtask(method='waitrepo',

-                                                 arglist=[tag, None, None],

+                                                 arglist=[tag, create_ts, builds],

                                                  parent=self.id)

              repo_info = self.wait(task_id)[task_id]

          return repo_info

file modified
+12 -10
@@ -42,7 +42,7 @@ 

          source = 'srpm'

          task_id = 1

          args = [target, source]

-         opts = {}

+         opts = {'wait_builds': []}

          priority = None

  

          self.session.getBuildTarget.return_value = target_info
@@ -94,7 +94,7 @@ 

          source = 'http://scm'

          task_id = 1

          args = [target, source]

-         opts = {}

+         opts = {'wait_builds': []}

          priority = None

  

          self.session.getBuildTarget.return_value = target_info
@@ -201,6 +201,8 @@ 

    --scratch             Perform a scratch build

    --wait                Wait on the build, even if running in the background

    --nowait              Don't wait on build

+   --wait-repo           Wait for the actual buildroot repo of given target

+   --wait-build=NVR      Wait for the given nvr to appear in buildroot repo

    --quiet               Do not print the task information

    --arch-override=ARCH_OVERRIDE

                          Override build arches
@@ -295,7 +297,7 @@ 

          task_id = 1

          repo_id = 2

          args = ['--repo-id=' + str(repo_id), target, source]

-         opts = {'repo_id': repo_id, 'skip_tag': True}

+         opts = {'repo_id': repo_id, 'skip_tag': True, 'wait_builds': []}

          priority = None

  

          self.session.build.return_value = task_id
@@ -498,7 +500,7 @@ 

              '--scratch',

              target,

              source]

-         opts = {'arch_override': arch_override, 'scratch': True}

+         opts = {'arch_override': arch_override, 'scratch': True, 'wait_builds': []}

          priority = None

  

          self.session.getBuildTarget.return_value = target_info
@@ -549,7 +551,7 @@ 

          task_id = 1

          args = ['--background', target, source]

          priority = 5

-         opts = {}

+         opts = {'wait_builds': []}

  

          self.session.getBuildTarget.return_value = target_info

          self.session.getTag.return_value = dest_tag_info
@@ -597,7 +599,7 @@ 

          source = 'srpm'

          task_id = 1

          args = [target, source]

-         opts = {}

+         opts = {'wait_builds': []}

          priority = None

  

          self.session.getBuildTarget.return_value = target_info
@@ -648,7 +650,7 @@ 

          source = 'srpm'

          task_id = 1

          args = ['--noprogress', target, source]

-         opts = {}

+         opts = {'wait_builds': []}

          priority = None

  

          self.session.getBuildTarget.return_value = target_info
@@ -702,7 +704,7 @@ 

          task_id = 1

          quiet = True

          args = ['--quiet', target, source]

-         opts = {}

+         opts = {'wait_builds': []}

          priority = None

  

          self.session.getBuildTarget.return_value = target_info
@@ -752,7 +754,7 @@ 

          task_id = 1

          quiet = None

          args = ['--wait', target, source]

-         opts = {}

+         opts = {'wait_builds': []}

          priority = None

  

          self.session.getBuildTarget.return_value = target_info
@@ -805,7 +807,7 @@ 

          source = 'srpm'

          task_id = 1

          args = ['--nowait', target, source]

-         opts = {}

+         opts = {'wait_builds': []}

          priority = None

  

          self.session.getBuildTarget.return_value = target_info

New options --wait-for-build and --wait-for-repo for build command are
simplification of using wait-repo + build command succession. They have
same semantices as the original one.

Fixes: https://pagure.io/koji/issue/1619

It is builder-side alternative to PR #1624

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

IMO this PR duplicates already-existing feature - chain build already implements this functionality, it can spawn waitrepo task that will wait for build repo containing specified build(s) before build task is created. For example: https://koji.kjnet.xyz/koji/taskinfo?taskID=28567

It is very similar. I think, that major difference is waiting for 'actual' repo without specifying required build. But maybe, that chainbuild is better place to put this option.

rebased onto d036d3dd063e082e2debe60e19f43378d2a25f5f

2 years ago

rebased onto d4192ba53d5e631a8b9b73e3dfcc3c2e5cdd1ac8

2 years ago

rebased onto 743434b6ae8ed49cf5896cf4bd0c3cfdd9b916e6

2 years ago

rebased onto ba47053

2 years ago

Metadata Update from @tkopecek:
- Pull-request untagged with: testing-ready

2 years ago

@julian8628 @mizdebsk Do you think, it would be better to limit this one to --wait-repo only and leave --wait-builds behaviour for chainbuild?

@julian8628 @mizdebsk Do you think, it would be better to limit this one to --wait-repo only and leave --wait-builds behaviour for chainbuild?

I think both options are useful if users don't want to use the more complex chain-build.
And chain-build aims more to build all of the builds with deps. Not sure if just waiting for a build which is being built by other ones before building a build is a case here, But build --wait-builds can handle this as well.

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

Commit 062050c fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

2 years ago