コード例 #1
0
 def __init__(self, runtime, brew_session, brew_event, base_target):
     self.runtime = runtime
     self.brew_session = brew_session
     self.brew_event = brew_event
     self.base_target = base_target
     self.state = runtime.state[runtime.command] = dict(state.TEMPLATE_IMAGE)
     self.bs_detector = build_status_detector.BuildStatusDetector(brew_session, runtime.logger)
コード例 #2
0
def detect_embargoes_in_tags(runtime: Runtime, kind: str,
                             included_tags: List[str],
                             excluded_tags: List[str],
                             event_id: Optional[int]):
    """ Finds embargoes in builds with given tags
    :param runtime: the runtime
    :param included_tags: list of koji tags that the returned builds must have
    :param excluded_tags: list of koji tags that the returned builds must not have
    :return: list of Brew build dicts that have embargoed fixes
    """
    brew_session = runtime.build_retrying_koji_client()
    runtime.logger.info(f"Fetching builds from Brew tags {included_tags}...")
    build_type = None if kind == "all" else kind
    latest_build_lists = brew.get_latest_builds([(tag, None)
                                                 for tag in included_tags],
                                                build_type, event_id,
                                                brew_session)
    included_builds = [
        b for builds in latest_build_lists if builds for b in builds
    ]  # flatten latest_build_lists
    runtime.logger.info(
        f"Found {len(included_builds)} builds from Brew tags {included_tags}.")
    if included_builds and excluded_tags:  # if we have tags to exclude, get all builds with excluded_tags then exclude them
        runtime.logger.info(
            f"Fetching builds from Brew tags {excluded_tags}...")
        excluded_build_lists = brew.get_tagged_builds(
            [(tag, None) for tag in excluded_tags], build_type, event_id,
            brew_session)
        excluded_build_ids = {
            b["id"]
            for builds in excluded_build_lists if builds for b in builds
        }
        builds = [
            b for b in included_builds if b["id"] not in excluded_build_ids
        ]
        runtime.logger.info(
            f"Excluded {len(included_builds) - len(builds)} builds that are also tagged into {excluded_tags}."
        )
        included_builds = builds

    # Builds may have duplicate entries if we query from multiple tags. Don't worry, BuildStatusDetector is smart.
    runtime.logger.info(
        f"Detecting embargoes for {len(included_builds)} builds...")
    detector = bs_detector.BuildStatusDetector(runtime, runtime.logger)
    embargoed_build_ids = detector.find_embargoed_builds(
        included_builds, runtime.get_candidate_brew_tags())
    embargoed_builds = [
        b for b in included_builds if b["id"] in embargoed_build_ids
    ]
    return embargoed_builds
コード例 #3
0
def detect_embargoes_in_nvrs(runtime: Runtime, nvrs: List[str]):
    """ Finds embargoes in given NVRs
    :param runtime: the runtime
    :param nvrs: list of build NVRs
    :return: list of Brew build dicts that have embargoed fixes
    """
    runtime.logger.info(f"Fetching {len(nvrs)} builds from Brew...")
    brew_session = runtime.build_retrying_koji_client()
    builds = brew.get_build_objects(nvrs, brew_session)
    for i, b in enumerate(builds):
        if not b:
            raise DoozerFatalError(f"Unable to get {nvrs[i]} from Brew.")
    runtime.logger.info(f"Detecting embargoes for {len(nvrs)} builds...")
    detector = bs_detector.BuildStatusDetector(brew_session, runtime.logger)
    embargoed_build_ids = detector.find_embargoed_builds(builds)
    embargoed_builds = [b for b in builds if b["id"] in embargoed_build_ids]
    return embargoed_builds