Beispiel #1
0
    def _perform_tag_actions(self):
        for i, batches in enumerate([(self.add_tags_sync, self.move_tags_sync),
                                     (self.add_tags_async,
                                      self.move_tags_async)]):
            add, move = batches
            if i == 0:
                self.koji.multicall = False
            else:
                self.koji.multicall = True
            for action in add:
                tag, build = action
                self.log.info("Adding tag %s to %s" % (tag, build))
                self.koji.tagBuild(tag, build, force=True)
            for action in move:
                from_tag, to_tag, build = action
                self.log.info('Moving %s from %s to %s' %
                              (build, from_tag, to_tag))
                self.koji.moveBuild(from_tag, to_tag, build, force=True)

            if i != 0:
                results = self.koji.multiCall()
                failed_tasks = buildsys.wait_for_tasks(
                    [task[0] for task in results], self.koji, sleep=15)
                if failed_tasks:
                    raise Exception("Failed to move builds: %s" % failed_tasks)
Beispiel #2
0
 def _perform_tag_actions(self):
     self.koji.multicall = True
     for action in self.add_tags:
         tag, build = action
         self.log.info("Adding tag %s to %s" % (tag, build))
         self.koji.tagBuild(tag, build, force=True)
     for action in self.move_tags:
         from_tag, to_tag, build = action
         self.log.info("Moving %s from %s to %s" % (build, from_tag, to_tag))
         self.koji.moveBuild(from_tag, to_tag, build, force=True)
     results = self.koji.multiCall()
     failed_tasks = buildsys.wait_for_tasks([task[0] for task in results], self.koji, sleep=15)
     if failed_tasks:
         raise Exception("Failed to move builds: %s" % failed_tasks)
Beispiel #3
0
 def _perform_tag_actions(self):
     self.koji.multicall = True
     for action in self.add_tags:
         tag, build = action
         self.log.info("Adding tag %s to %s" % (tag, build))
         self.koji.tagBuild(tag, build, force=True)
     for action in self.move_tags:
         from_tag, to_tag, build = action
         self.log.info('Moving %s from %s to %s' %
                       (build, from_tag, to_tag))
         self.koji.moveBuild(from_tag, to_tag, build, force=True)
     results = self.koji.multiCall()
     failed_tasks = buildsys.wait_for_tasks([task[0] for task in results],
                                            self.koji,
                                            sleep=15)
     if failed_tasks:
         raise Exception("Failed to move builds: %s" % failed_tasks)
Beispiel #4
0
    def move_builds(self):
        """
        Move all builds associated with our batch of updates to the proper tag.
        This is determined based on the request of the update, and it's
        current state.
        """
        t0 = time.time()
        self.success = False
        self.moving = True
        log.debug("Setting up koji multicall for moving builds")
        self.koji.multicall = True
        for update in sort_updates(self.updates):
            if update.request == 'stable':
                self.tag = update.release.stable_tag
                # [No Frozen Rawhide] Move stable builds going to a pending
                # release to the Release.dist-tag
                if update.release.locked:
                    self.tag = update.release.dist_tag
            elif update.request == 'testing':
                self.tag = update.release.testing_tag
            elif update.request == 'obsolete':
                self.tag = update.release.candidate_tag
            current_tag = update.get_build_tag()
            for build in update.builds:
                if build.inherited:
                    log.debug("Adding tag %s to %s" % (self.tag, build.nvr))
                    self.koji.tagBuild(self.tag, build.nvr, force=True)
                elif update.release.locked and update.request == 'stable':
                    log.debug("Adding tag %s to %s" % (self.tag, build.nvr))
                    self.koji.tagBuild(self.tag, build.nvr, force=True)
                else:
                    log.debug("Moving %s from %s to %s" %
                              (build.nvr, current_tag, self.tag))
                    self.koji.moveBuild(current_tag,
                                        self.tag,
                                        build.nvr,
                                        force=True)
                self.actions.append((build.nvr, current_tag, self.tag))

        results = self.koji.multiCall()
        if not buildsys.wait_for_tasks([task[0] for task in results]):
            self.success = True
        self.moving = False
        log.debug("Moved builds in %s seconds" % (time.time() - t0))
        if not self.success:
            raise MashTaskException("Failed to move builds")
Beispiel #5
0
    def move_builds(self):
        """
        Move all builds associated with our batch of updates to the proper tag.
        This is determined based on the request of the update, and it's
        current state.
        """
        t0 = time.time()
        self.success = False
        self.moving = True
        log.debug("Setting up koji multicall for moving builds")
        self.koji.multicall = True
        for update in sort_updates(self.updates):
            if update.request == 'stable':
                self.tag = update.release.stable_tag
                # [No Frozen Rawhide] Move stable builds going to a pending
                # release to the Release.dist-tag
                if update.release.locked:
                    self.tag = update.release.dist_tag
            elif update.request == 'testing':
                self.tag = update.release.testing_tag
            elif update.request == 'obsolete':
                self.tag = update.release.candidate_tag
            current_tag = update.get_build_tag()
            for build in update.builds:
                if build.inherited:
                    log.debug("Adding tag %s to %s" % (self.tag, build.nvr))
                    self.koji.tagBuild(self.tag, build.nvr, force=True)
                elif update.release.locked and update.request == 'stable':
                    log.debug("Adding tag %s to %s" % (self.tag, build.nvr))
                    self.koji.tagBuild(self.tag, build.nvr, force=True)
                else:
                    log.debug("Moving %s from %s to %s" % (build.nvr,
                                                           current_tag,
                                                           self.tag))
                    self.koji.moveBuild(current_tag, self.tag, build.nvr, force=True)
                self.actions.append((build.nvr, current_tag, self.tag))

        results = self.koji.multiCall()
        if not buildsys.wait_for_tasks([task[0] for task in results]):
            self.success = True
        self.moving = False
        log.debug("Moved builds in %s seconds" % (time.time() - t0))
        if not self.success:
            raise MashTaskException("Failed to move builds")
Beispiel #6
0
    def _perform_tag_actions(self):
        for i, batches in enumerate([(self.add_tags_sync, self.move_tags_sync),
                                     (self.add_tags_async, self.move_tags_async)]):
            add, move = batches
            if i == 0:
                self.koji.multicall = False
            else:
                self.koji.multicall = True
            for action in add:
                tag, build = action
                self.log.info("Adding tag %s to %s" % (tag, build))
                self.koji.tagBuild(tag, build, force=True)
            for action in move:
                from_tag, to_tag, build = action
                self.log.info('Moving %s from %s to %s' % (
                              build, from_tag, to_tag))
                self.koji.moveBuild(from_tag, to_tag, build, force=True)

            if i != 0:
                results = self.koji.multiCall()
                failed_tasks = buildsys.wait_for_tasks([task[0] for task in results],
                                                       self.koji, sleep=15)
                if failed_tasks:
                    raise Exception("Failed to move builds: %s" % failed_tasks)
Beispiel #7
0
def main():
    load_config()
    __connection__ = hub = PackageHub("bodhi")
    koji = get_session()
    tasks = []
    broke = set()

    # Clean up any stray pending tags
    for release in Release.select():
        print "Finding all pending-testing builds..."
        if release.name.startswith('EL'):
            continue

        tag = release.pending_testing_tag
        tagged = [build['nvr'] for build in koji.listTagged(tag)]
        for nvr in tagged:
            try:
                build = PackageBuild.byNvr(nvr)
                for update in build.updates:
                    if update.status in ('testing', 'stable', 'obsolete'):
                        print "%s %s" % (nvr, update.status)
                        if '--fix' in sys.argv:
                            print "Untagging %s" % nvr
                            koji.untagBuild(tag, nvr, force=True)
            except SQLObjectNotFound:
                print "Can't find build for %s" % nvr
                if '--fix' in sys.argv:
                    print "Untagging %s" % nvr
                    koji.untagBuild(tag, nvr, force=True)

        tag = release.pending_stable_tag
        tagged = [build['nvr'] for build in koji.listTagged(tag)]
        for nvr in tagged:
            try:
                build = PackageBuild.byNvr(nvr)
                for update in build.updates:
                    if update.status in ('pending', 'obsolete'):
                        print "%s %s" % (nvr, update.status)
                        if '--fix' in sys.argv:
                            print "Untagging %s" % nvr
                            koji.untagBuild(tag, nvr, force=True)
            except SQLObjectNotFound:
                print "Can't find build for %s" % nvr
                if '--fix' in sys.argv:
                    print "Untagging %s" % nvr
                    koji.untagBuild(tag, nvr, force=True)

    # Check for testing updates that aren't tagged properly
    for update in PackageUpdate.select(PackageUpdate.q.status=='testing'):
        dest_tag = update.release.testing_tag
        for build in update.builds:
            tags = [tag['name'] for tag in koji.listTags(build=build.nvr)]
            if dest_tag not in tags:
                print "%s marked as testing, but tagged with %s" % (build.nvr,
                                                                    tags)
                if '--fix' in sys.argv:
                    broke.add((tags[0], dest_tag, build.nvr))

    # Check all candidate updates to see if they are in a different bodhi state
    for release in Release.select():
        tag = release.candidate_tag
        tagged = [build['nvr'] for build in koji.listTagged(tag, latest=True)]
        for nvr in tagged:
            try:
                build = PackageBuild.byNvr(nvr)
                for update in build.updates:
                    if update.status in ('testing', 'stable'):
                        print "%s %s but tagged as %s" % (nvr,
                                                          update.status,
                                                          tag)
                        if '--fix' in sys.argv:
                            dest = release.testing_tag
                            if update.status == 'stable':
                                dest = release.stable_tag
                            elif update.status == 'obsolete':
                                dest = release.candidate_tag
                            broke.add((tag, dest, nvr))
            except SQLObjectNotFound:
                pass

    # Make sure that all builds in koji tagged as an update exist
    # in bodhi, and are in the expect state.
    for release in Release.select():
        for tag in (release.testing_tag, release.stable_tag):
            tagged = [build['nvr'] for build in koji.listTagged(tag, latest=True)]
            for nvr in tagged:
                try:
                    build = PackageBuild.byNvr(nvr)
                except SQLObjectNotFound:
                    print "PackageUpdate(%s) not found!" % nvr
                    continue
                if not len(build.updates):
                    print "PackageBuild(%s) has no updates" % (build.nvr)
                status = 'testing' in tag and 'testing' or 'stable'
                for update in build.updates:
                    if update.status != status:
                        print "%s is %s in bodhi but tagged as %s in koji" % (
                                update.title, update.status, tag)
                        if '--fix' in sys.argv:
                            dest = release.testing_tag
                            if update.status == 'stable':
                                dest = release.stable_tag
                            elif update.status == 'obsolete':
                                dest = release.candidate_tag
                            for b in update.builds:
                                broke.add((tag, dest, b.nvr))

    if broke:
        print " ** Fixing broken tags! **"
        koji.multicall = True
        for tag, dest, build in broke:
            print "Moving %s from %s to %s" % (build, tag, dest)
            koji.moveBuild(tag, dest, build, force=True)
        print "Running koji.multiCall()"
        results = koji.multiCall()
        success = False
        print "Waiting for tasks"
        bad_tasks = wait_for_tasks([task[0] for task in results])
        if bad_tasks == 0:
            success = True
        if success:
            print "Tags successfully moved!"
        else:
            print "Error moving tags!"
            print "bad_tasks = %r" % bad_tasks
Beispiel #8
0
def main():
    load_config()
    __connection__ = hub = PackageHub("bodhi")
    koji = get_session()
    tasks = []
    broke = set()

    # Clean up any stray pending tags
    for release in Release.select():
        print "Finding all pending-testing builds..."
        if release.name.startswith('EL'):
            continue

        tag = release.pending_testing_tag
        tagged = [build['nvr'] for build in koji.listTagged(tag)]
        for nvr in tagged:
            try:
                build = PackageBuild.byNvr(nvr)
                for update in build.updates:
                    if update.status in ('testing', 'stable', 'obsolete'):
                        print "%s %s" % (nvr, update.status)
                        if '--fix' in sys.argv:
                            print "Untagging %s" % nvr
                            koji.untagBuild(tag, nvr, force=True)
            except SQLObjectNotFound:
                print "Can't find build for %s" % nvr
                if '--fix' in sys.argv:
                    print "Untagging %s" % nvr
                    koji.untagBuild(tag, nvr, force=True)

        tag = release.pending_stable_tag
        tagged = [build['nvr'] for build in koji.listTagged(tag)]
        for nvr in tagged:
            try:
                build = PackageBuild.byNvr(nvr)
                for update in build.updates:
                    if update.status in ('pending', 'obsolete', 'stable'):
                        print "%s %s" % (nvr, update.status)
                        if '--fix' in sys.argv:
                            print "Untagging %s" % nvr
                            koji.untagBuild(tag, nvr, force=True)
            except SQLObjectNotFound:
                print "Can't find build for %s" % nvr
                if '--fix' in sys.argv:
                    print "Untagging %s" % nvr
                    koji.untagBuild(tag, nvr, force=True)

    # Check for testing updates that aren't tagged properly
    for update in PackageUpdate.select(PackageUpdate.q.status == 'testing'):
        dest_tag = update.release.testing_tag
        for build in update.builds:
            tags = [tag['name'] for tag in koji.listTags(build=build.nvr)]
            if dest_tag not in tags:
                print "%s marked as testing, but tagged with %s" % (build.nvr,
                                                                    tags)
                if '--fix' in sys.argv:
                    broke.add((tags[0], dest_tag, build.nvr))

    # Check all candidate updates to see if they are in a different bodhi state
    for release in Release.select():
        tag = release.candidate_tag
        tagged = [build['nvr'] for build in koji.listTagged(tag, latest=True)]
        for nvr in tagged:
            try:
                build = PackageBuild.byNvr(nvr)
                for update in build.updates:
                    if update.status in ('testing', 'stable'):
                        print "%s %s but tagged as %s" % (nvr, update.status,
                                                          tag)
                        if '--fix' in sys.argv:
                            dest = release.testing_tag
                            if update.status == 'stable':
                                dest = release.stable_tag
                            elif update.status == 'obsolete':
                                dest = release.candidate_tag
                            broke.add((tag, dest, nvr))
            except SQLObjectNotFound:
                pass

    # Make sure that all builds in koji tagged as an update exist
    # in bodhi, and are in the expect state.
    for release in Release.select():
        for tag in (release.testing_tag, release.stable_tag):
            tagged = [
                build['nvr'] for build in koji.listTagged(tag, latest=True)
            ]
            for nvr in tagged:
                try:
                    build = PackageBuild.byNvr(nvr)
                except SQLObjectNotFound:
                    print "PackageUpdate(%s) not found!" % nvr
                    continue
                if not len(build.updates):
                    print "PackageBuild(%s) has no updates" % (build.nvr)
                status = 'testing' in tag and 'testing' or 'stable'
                for update in build.updates:
                    if update.status != status:
                        print "%s is %s in bodhi but tagged as %s in koji" % (
                            update.title, update.status, tag)
                        if '--fix' in sys.argv:
                            dest = release.testing_tag
                            if update.status == 'stable':
                                dest = release.stable_tag
                            elif update.status == 'obsolete':
                                dest = release.candidate_tag
                            for b in update.builds:
                                broke.add((tag, dest, b.nvr))

    if broke:
        print " ** Fixing broken tags! **"
        koji.multicall = True
        for tag, dest, build in broke:
            print "Moving %s from %s to %s" % (build, tag, dest)
            koji.moveBuild(tag, dest, build, force=True)
        print "Running koji.multiCall()"
        results = koji.multiCall()
        success = False
        print "Waiting for tasks"
        bad_tasks = wait_for_tasks([task[0] for task in results])
        if bad_tasks == 0:
            success = True
        if success:
            print "Tags successfully moved!"
        else:
            print "Error moving tags!"
            print "bad_tasks = %r" % bad_tasks