Esempio n. 1
0
def get_binary_rpms(srpms):
    rpm_names = set()
    builds = koji_util.itercall(ks, list(srpms), lambda ks, srpm: ks.getBuild(parse_nvra(srpm)))
    rpms_gen = koji_util.itercall(ks, list(builds), lambda ks, build: ks.listRPMs(build['id'], arches=('noarch', 'x86_64')))
    for rpms in rpms_gen:
        rpm_names.update([rpm['name'] for rpm in rpms if not rpm['name'].endswith('-debuginfo') and not rpm['name'].endswith('-debugsource')])
    return rpm_names
Esempio n. 2
0
def resolve_refs(srpms):
    def get_ref(build):
        scm_url = build['extra']['source']['original_url']
        match = re.search(r'#([0-9a-f]{7})[0-9a-f]*$', scm_url)
        assert match
        return match.group(1)
    builds = koji_util.itercall(ks, list(srpms), lambda ks, srpm: ks.getBuild(parse_nvra(srpm)))
    return {srpm: get_ref(build) for srpm, build in zip(srpms, builds)}
Esempio n. 3
0
def sync_tasks(session, collection, builds, real=False):
    """
    Synchronizes task and subtask data from Koji.
    Sets properties on build objects passed in and return KojiTask objects.
    Uses koji_session passed as argument.
    Returns map of build to list of tasks
    """
    if not builds:
        return
    koji_session = (session.secondary_koji_for(collection)
                    if real else session.koji('primary'))
    call = itercall(koji_session, builds,
                    lambda k, b: k.getTaskInfo(b.task_id))
    valid_builds = []
    for build, task_info in zip(builds, call):
        if not task_info:
            continue
        build.started = datetime.fromtimestamp(task_info['create_ts'])
        if task_info.get('completion_ts'):
            build.finished = datetime.fromtimestamp(task_info['completion_ts'])
        elif build.state != Build.RUNNING:
            # When fedmsg delivery is fast, the time is not set yet
            build.finished = datetime.now()
        valid_builds.append(build)
    call = itercall(koji_session, valid_builds,
                    lambda k, b: k.getTaskChildren(b.task_id, request=True))
    build_tasks = {}
    for build, subtasks in zip(valid_builds, call):
        tasks = []
        build_arch_tasks = [
            task for task in subtasks if task['method'] == 'buildArch'
        ]
        for task in build_arch_tasks:
            set_build_repo_id(session, build, task, collection.secondary_mode)
            db_task = KojiTask(task_id=task['id'])
            db_task.build_id = build.id
            db_task.state = task['state']
            db_task.arch = task['arch']
            db_task.started = datetime.fromtimestamp(task['create_ts'])
            if task.get('completion_ts'):
                db_task.finished = datetime.fromtimestamp(
                    task['completion_ts'])
            tasks.append(db_task)
        build_tasks[build] = tasks
    return build_tasks
Esempio n. 4
0
def sync_tasks(session, collection, builds, real=False):
    """
    Synchronizes task and subtask data from Koji.
    Sets properties on build objects passed in and return KojiTask objects.
    Uses koji_session passed as argument.
    Returns map of build to list of tasks
    """
    if not builds:
        return
    koji_session = (session.secondary_koji_for(collection) if real
                    else session.koji('primary'))
    call = itercall(koji_session, builds, lambda k, b: k.getTaskInfo(b.task_id))
    valid_builds = []
    for build, task_info in zip(builds, call):
        if not task_info:
            continue
        build.started = datetime.fromtimestamp(task_info['create_ts'])
        if task_info.get('completion_ts'):
            build.finished = datetime.fromtimestamp(task_info['completion_ts'])
        elif build.state != Build.RUNNING:
            # When fedmsg delivery is fast, the time is not set yet
            build.finished = datetime.now()
        valid_builds.append(build)
    call = itercall(koji_session, valid_builds,
                    lambda k, b: k.getTaskChildren(b.task_id, request=True))
    build_tasks = {}
    for build, subtasks in zip(valid_builds, call):
        tasks = []
        build_arch_tasks = [task for task in subtasks
                            if task['method'] == 'buildArch']
        for task in build_arch_tasks:
            set_build_repo_id(session, build, task, collection.secondary_mode)
            db_task = KojiTask(task_id=task['id'])
            db_task.build_id = build.id
            db_task.state = task['state']
            db_task.arch = task['arch']
            db_task.started = datetime.fromtimestamp(task['create_ts'])
            if task.get('completion_ts'):
                db_task.finished = datetime.fromtimestamp(task['completion_ts'])
            tasks.append(db_task)
        build_tasks[build] = tasks
    return build_tasks
Esempio n. 5
0
 def set_descriptor_tags(self, descriptors):
     def koji_call(koji_session, desc):
         koji_session.repoInfo(desc.repo_id)
     result_gen = itercall(self.koji_sessions['secondary'],
                           descriptors, koji_call)
     for desc, repo_info in izip(descriptors, result_gen):
         if repo_info['state'] in (koji.REPO_STATES['READY'],
                                   koji.REPO_STATES['EXPIRED']):
             desc.build_tag = repo_info['tag_name']
         else:
             self.log.debug('Repo {} is dead, skipping'.format(desc.repo_id))
Esempio n. 6
0
    def set_descriptor_tags(self, descriptors):
        def koji_call(koji_session, desc):
            koji_session.repoInfo(desc.repo_id)

        result_gen = itercall(self.koji_sessions['secondary'], descriptors,
                              koji_call)
        for desc, repo_info in izip(descriptors, result_gen):
            if repo_info['state'] in (koji.REPO_STATES['READY'],
                                      koji.REPO_STATES['EXPIRED']):
                desc.build_tag = repo_info['tag_name']
            else:
                self.log.debug('Repo {} is dead, skipping'.format(
                    desc.repo_id))
Esempio n. 7
0
    def poll_builds(self):
        self.log.info('Polling running Koji tasks...')
        running_builds = self.db.query(Build)\
                                .filter_by(state=Build.RUNNING)

        infos = itercall(self.session.koji('primary'), running_builds,
                         lambda k, b: k.getTaskInfo(b.task_id))

        for task_info, build in zip(infos, running_builds):
            try:
                name = build.package.name
                self.log.info(
                    'Polling task {id} ({name}): task_info={info}'.format(
                        id=build.task_id, name=name, info=task_info))
                state = koji.TASK_STATES[task_info['state']]
                backend.update_build_state(self.session, build, state)
            except (StaleDataError, ObjectDeletedError):
                # build was deleted concurrently
                self.db.rollback()
                continue