From 50f0a60ec1853f566dbc42db914323518238ffa7 Mon Sep 17 00:00:00 2001 From: mprahl Date: Fri, 28 Jun 2019 16:59:46 -0400 Subject: [PATCH] Allow configuring the number of parallel submissions to Koji When NUM_CONCURRENT_BUILDS is 0, then multi-threading is disabled when submitting builds to Koji. This is not acceptable, so this commit makes the number of threads configurable. --- module_build_service/config.py | 15 ++++++++++++++- module_build_service/utils/batches.py | 4 +--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/module_build_service/config.py b/module_build_service/config.py index 73b51897..35d7c450 100644 --- a/module_build_service/config.py +++ b/module_build_service/config.py @@ -653,7 +653,13 @@ class Config(object): "x, y, and z (represents the version). The third value is an optional template " "string that represent the Product Pages release for major releases " "(e.g. 8.0.0). After the first match, the rest will be ignored." - } + }, + "num_threads_for_build_submissions": { + "type": int, + "default": 5, + "desc": "The number of threads when submitting component builds to an external build " + "system.", + }, } def __init__(self, conf_section_obj): @@ -907,3 +913,10 @@ class Config(object): ) self._product_pages_module_streams = d + + def _setifok_num_threads_for_build_submissions(self, i): + if not isinstance(i, int): + raise TypeError("NUM_THREADS_FOR_BUILD_SUBMISSIONS needs to be an int") + if i < 1: + raise ValueError("NUM_THREADS_FOR_BUILD_SUBMISSIONS must be >= 1") + self._num_threads_for_build_submissions = i diff --git a/module_build_service/utils/batches.py b/module_build_service/utils/batches.py index b2e3ca55..fa06c7ff 100644 --- a/module_build_service/utils/batches.py +++ b/module_build_service/utils/batches.py @@ -150,9 +150,7 @@ def continue_batch_build(config, module, session, builder, components=None): components_to_build.append(c) # Start build of components in this batch. - max_workers = 1 - if config.num_concurrent_builds > 0: - max_workers = config.num_concurrent_builds + max_workers = config.num_threads_for_build_submissions with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor: futures = { executor.submit(start_build_component, builder, c): c for c in components_to_build