diff --git a/0006-add-background-option-for-container-build-which-allo.patch b/0006-add-background-option-for-container-build-which-allo.patch new file mode 100644 index 0000000..03452bc --- /dev/null +++ b/0006-add-background-option-for-container-build-which-allo.patch @@ -0,0 +1,152 @@ +From 9efda7d562d072acbe183ea9f164fe974356fd60 Mon Sep 17 00:00:00 2001 +From: Robert Cerven +Date: Thu, 7 Apr 2022 20:43:36 +0200 +Subject: [PATCH] add --background option for container-build which allows to + create build with lower priority + +* CLOUDBLD-9358 + +Signed-off-by: Robert Cerven +--- + pyrpkg/__init__.py | 7 ++++++- + pyrpkg/cli.py | 7 +++++++ + tests/test_cli.py | 38 ++++++++++++++++++++++++++++++++++++++ + 3 files changed, 51 insertions(+), 1 deletion(-) + +diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py +index 331c354..5b1e001 100644 +--- a/pyrpkg/__init__.py ++++ b/pyrpkg/__init__.py +@@ -3358,6 +3358,7 @@ class Commands(object): + build_client=None, + koji_task_watcher=None, + nowait=False, ++ background=False, + flatpak=False): + + # check if repo is dirty and all commits are pushed +@@ -3405,7 +3406,11 @@ class Commands(object): + if flatpak: + task_opts['flatpak'] = True + +- priority = opts.get("priority", None) ++ priority = None ++ if background: ++ # relative to koji.PRIO_DEFAULT ++ priority = 5 ++ + task_id = self.kojisession.buildContainer(source, + container_target, + task_opts, +diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py +index c253bb5..e7b6e26 100644 +--- a/pyrpkg/cli.py ++++ b/pyrpkg/cli.py +@@ -1665,6 +1665,12 @@ class cliClient(object): + default=False, + help="Don't wait on build") + ++ parser.add_argument( ++ '--background', ++ action='store_true', ++ default=False, ++ help="Run the build at a lower priority") ++ + parser.add_argument( + '--build-release', + default=None, +@@ -2252,6 +2258,7 @@ class cliClient(object): + build_client=build_client, + koji_task_watcher=koji_cli.lib.watch_tasks, + nowait=self.args.nowait, ++ background=self.args.background, + flatpak=flatpak) + return rv + +diff --git a/tests/test_cli.py b/tests/test_cli.py +index 94aaaff..054e950 100644 +--- a/tests/test_cli.py ++++ b/tests/test_cli.py +@@ -161,6 +161,39 @@ class TestContainerBuildWithKoji(CliTestCase): + build_client=utils.build_client, + koji_task_watcher=koji_cli.lib.watch_tasks, + nowait=False, ++ background=False, ++ flatpak=False ++ ) ++ ++ def test_using_kojiprofile_background(self): ++ cli_cmd = ['rpkg', '--path', self.cloned_repo_path, ++ 'container-build', '--background'] ++ ++ with patch('sys.argv', new=cli_cmd): ++ cli = self.new_cli() ++ cli.container_build_koji() ++ ++ self.mock_container_build_koji.assert_called_once_with( ++ False, ++ opts={ ++ 'scratch': False, ++ 'quiet': False, ++ 'release': None, ++ 'isolated': False, ++ 'koji_parent_build': None, ++ 'yum_repourls': None, ++ 'dependency_replacements': None, ++ 'git_branch': 'eng-rhel-7', ++ 'arches': None, ++ 'signing_intent': None, ++ 'compose_ids': None, ++ 'skip_build': False ++ }, ++ kojiprofile='koji', ++ build_client=utils.build_client, ++ koji_task_watcher=koji_cli.lib.watch_tasks, ++ nowait=False, ++ background=True, + flatpak=False + ) + +@@ -193,6 +226,7 @@ class TestContainerBuildWithKoji(CliTestCase): + build_client=utils.build_client, + koji_task_watcher=koji_cli.lib.watch_tasks, + nowait=False, ++ background=False, + flatpak=False + ) + +@@ -226,6 +260,7 @@ class TestContainerBuildWithKoji(CliTestCase): + build_client=utils.build_client, + koji_task_watcher=koji_cli.lib.watch_tasks, + nowait=False, ++ background=False, + flatpak=False + ) + +@@ -258,6 +293,7 @@ class TestContainerBuildWithKoji(CliTestCase): + build_client=utils.build_client, + koji_task_watcher=koji_cli.lib.watch_tasks, + nowait=False, ++ background=False, + flatpak=False + ) + +@@ -289,6 +325,7 @@ class TestContainerBuildWithKoji(CliTestCase): + build_client=utils.build_client, + koji_task_watcher=koji_cli.lib.watch_tasks, + nowait=False, ++ background=False, + flatpak=False + ) + +@@ -346,6 +383,7 @@ class TestContainerBuildWithKoji(CliTestCase): + build_client=utils.build_client, + koji_task_watcher=koji_cli.lib.watch_tasks, + nowait=False, ++ background=False, + flatpak=True + ) + +-- +2.35.1 + diff --git a/rpkg.spec b/rpkg.spec index 0213cb5..bd36ab1 100644 --- a/rpkg.spec +++ b/rpkg.spec @@ -1,6 +1,6 @@ Name: rpkg Version: 1.64 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Python library for interacting with rpm+git License: GPLv2+ and LGPLv2 @@ -39,6 +39,7 @@ Patch3: 0003-Remove-Environment-Markers-syntax.patch %endif Patch4: 0004-Add-custom-user-metadata-to-build-command.patch Patch5: 0005-Better-exit-code-for-connection-error.patch +Patch6: 0006-add-background-option-for-container-build-which-allo.patch %description Python library for interacting with rpm+git @@ -251,6 +252,10 @@ example_cli_dir=$RPM_BUILD_ROOT%{_datadir}/%{name}/examples/cli %changelog +* Mon Apr 18 2022 Ondřej Nosek - 1.64-5 +- Patch: add --background option for container-build which allows + to create build + * Tue Apr 05 2022 Ondřej Nosek - 1.64-4 - Patch: Better exit code for connection error