def test_get_orchestrator_platforms(inputs, results): class MockWorkflow(object): def __init__(self, inputs): self.buildstep_plugins_conf = inputs workflow = MockWorkflow(inputs) if results: assert sorted(get_orchestrator_platforms(workflow)) == sorted(results) else: assert get_orchestrator_platforms(workflow) == results
def run(self): """ run the plugin """ if self.koji_target: koji_session = get_koji_session(self.workflow, NO_FALLBACK) self.log.info("Checking koji target for platforms") event_id = koji_session.getLastEvent()['id'] target_info = koji_session.getBuildTarget(self.koji_target, event=event_id) build_tag = target_info['build_tag'] koji_build_conf = koji_session.getBuildConfig(build_tag, event=event_id) koji_platforms = koji_build_conf['arches'] if not koji_platforms: self.log.info("No platforms found in koji target") return None platforms = koji_platforms.split() self.log.info("Koji platforms are %s", sorted(platforms)) if is_scratch_build() or is_isolated_build(): override_platforms = get_orchestrator_platforms(self.workflow) if override_platforms and set(override_platforms) != set( platforms): sort_platforms = sorted(override_platforms) self.log.info("Received user specified platforms %s", sort_platforms) self.log.info("Using them instead of koji platforms") # platforms from user params do not match platforms from koji target # that almost certainly means they were overridden and should be used return set(override_platforms) else: platforms = get_orchestrator_platforms(self.workflow) self.log.info("No koji platforms. User specified platforms are %s", sorted(platforms)) if not platforms: raise RuntimeError( "Cannot determine platforms; no koji target or platform list") # Filter platforms based on clusters enabled_platforms = [] for p in platforms: if self.reactor_config.get_enabled_clusters_for_platform(p): enabled_platforms.append(p) else: self.log.warning( "No cluster found for platform '%s' in reactor config map, skipping", p) final_platforms = get_platforms_in_limits(self.workflow, enabled_platforms) self.log.info("platforms in limits : %s", final_platforms) return final_platforms
def run(self): """ run the plugin """ if self.koji_target: koji_session = get_koji_session(self.workflow, NO_FALLBACK) self.log.info("Checking koji target for platforms") event_id = koji_session.getLastEvent()['id'] target_info = koji_session.getBuildTarget(self.koji_target, event=event_id) build_tag = target_info['build_tag'] koji_build_conf = koji_session.getBuildConfig(build_tag, event=event_id) koji_platforms = koji_build_conf['arches'] if not koji_platforms: self.log.info("No platforms found in koji target") return None platforms = koji_platforms.split() self.log.info("Koji platforms are %s", sorted(platforms)) if is_scratch_build() or is_isolated_build(): override_platforms = get_orchestrator_platforms(self.workflow) if override_platforms and set(override_platforms) != set(platforms): sort_platforms = sorted(override_platforms) self.log.info("Received user specified platforms %s", sort_platforms) self.log.info("Using them instead of koji platforms") # platforms from user params do not match platforms from koji target # that almost certainly means they were overridden and should be used return set(override_platforms) else: platforms = get_orchestrator_platforms(self.workflow) self.log.info("No koji platforms. User specified platforms are %s", sorted(platforms)) if not platforms: raise RuntimeError("Cannot determine platforms; no koji target or platform list") # Filter platforms based on clusters enabled_platforms = [] for p in platforms: if self.reactor_config.get_enabled_clusters_for_platform(p): enabled_platforms.append(p) else: self.log.warning( "No cluster found for platform '%s' in reactor config map, skipping", p) final_platforms = get_platforms_in_limits(self.workflow, enabled_platforms) self.log.info("platforms in limits : %s", final_platforms) return final_platforms
def _get_expected_platforms(self): """retrieve expected platforms configured for this build""" platforms = self.workflow.prebuild_results.get( PLUGIN_CHECK_AND_SET_PLATFORMS_KEY) if platforms: return platforms return get_orchestrator_platforms(self.workflow)
def run(self): """ run the plugin """ koji_session = get_koji_session(self.workflow, NO_FALLBACK) self.log.info("Checking koji target for platforms") event_id = koji_session.getLastEvent()['id'] target_info = koji_session.getBuildTarget(self.koji_target, event=event_id) build_tag = target_info['build_tag'] koji_build_conf = koji_session.getBuildConfig(build_tag, event=event_id) koji_platforms = koji_build_conf['arches'] if not koji_platforms: self.log.info("No platforms found in koji target") return None platforms = koji_platforms.split() if is_scratch_build() or is_isolated_build(): override_platforms = get_orchestrator_platforms(self.workflow) if override_platforms and set(override_platforms) != koji_platforms: # platforms from user params do not match platforms from koji target # that almost certainly means they were overridden and should be used return set(override_platforms) return get_platforms_in_limits(self.workflow, platforms)
def run(self) -> Optional[List[str]]: """ run the plugin """ if self.koji_target: koji_session = get_koji_session(self.workflow.conf) self.log.info("Checking koji target for platforms") event_id = koji_session.getLastEvent()['id'] target_info = koji_session.getBuildTarget(self.koji_target, event=event_id) build_tag = target_info['build_tag'] koji_build_conf = koji_session.getBuildConfig(build_tag, event=event_id) koji_platforms = koji_build_conf['arches'] if not koji_platforms: self.log.info("No platforms found in koji target") return None platforms = koji_platforms.split() self.log.info("Koji platforms are %s", sorted(platforms)) if is_scratch_build(self.workflow) or is_isolated_build(self.workflow): override_platforms = set(get_orchestrator_platforms(self.workflow) or []) if override_platforms and override_platforms != set(platforms): sorted_platforms = sorted(override_platforms) self.log.info("Received user specified platforms %s", sorted_platforms) self.log.info("Using them instead of koji platforms") # platforms from user params do not match platforms from koji target # that almost certainly means they were overridden and should be used return sorted_platforms else: platforms = get_orchestrator_platforms(self.workflow) user_platforms = sorted(platforms) if platforms else None self.log.info("No koji platforms. User specified platforms are %s", user_platforms) if not platforms: raise RuntimeError("Cannot determine platforms; no koji target or platform list") # Filter platforms based on configured remote hosts remote_host_pools = self.workflow.conf.remote_hosts.get("pools", {}) enabled_platforms = [] defined_but_disabled = [] def has_enabled_hosts(platform: str) -> bool: platform_hosts = remote_host_pools.get(platform, {}) return any(host_info["enabled"] for host_info in platform_hosts.values()) for p in platforms: if has_enabled_hosts(p): enabled_platforms.append(p) elif p in remote_host_pools: defined_but_disabled.append(p) else: self.log.warning("No remote hosts found for platform '%s' in " "reactor config map, skipping", p) if defined_but_disabled: msg = 'Platforms specified in config map, but have all remote hosts disabled' \ ' {}'.format(defined_but_disabled) raise RuntimeError(msg) final_platforms = self._limit_platforms(enabled_platforms) self.log.info("platforms in limits : %s", final_platforms) if not final_platforms: self.log.error("platforms in limits are empty") raise RuntimeError("No platforms to build for") self.workflow.build_dir.init_build_dirs(final_platforms, self.workflow.source) return final_platforms