From 5284f682c93ac5256e968bc7e2145fe9fb6d24d9 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Jun 15 2020 16:00:18 +0000 Subject: frontend: hot-fix pending-jobs route again The route was made too slow again by ddb706f92838dd16, and we did not notice the fact until now (when there's 6k+ pending tasks). Since the backend had troubles to fill the build queue due to this bug (_most_ of the time we got 504 error) this was breaking other stuff like VM allocation mechanism (VMs were not re-used, because getting new tasks took too long to fit the reuse_opportunity_time resalloc limit), etc. The trick here in the fix is to move the code throwing another SQL query (for each task in the queue!) behind the 'if short' condition. For the purpose of build scheduling the additional info isn't needed (that's the purpose of short argument anyway). Fixes: #1409 Merges: #1410 --- diff --git a/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py b/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py index 0691a3b..d94a0dd 100644 --- a/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py +++ b/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py @@ -92,7 +92,6 @@ def get_build_record(task, short=False): build_record = None try: - copr_chroot = CoprChrootsLogic.get_by_name_safe(task.build.copr, task.mock_chroot.name) build_record = { "task_id": task.task_id, "build_id": task.build.id, @@ -117,9 +116,6 @@ def get_build_record(task, short=False): "uses_devel_repo": task.build.copr.devel_mode, } - if copr_chroot.module_toggle_array: - array = [{'enable': m} for m in copr_chroot.module_toggle_array] - build_record["modules"] = {'toggle': array} if task.build.is_background: build_record['background'] = True @@ -127,6 +123,11 @@ def get_build_record(task, short=False): if short: return build_record + copr_chroot = CoprChrootsLogic.get_by_name_safe(task.build.copr, task.mock_chroot.name) + if copr_chroot.module_toggle_array: + array = [{'enable': m} for m in copr_chroot.module_toggle_array] + build_record["modules"] = {'toggle': array} + build_config = BuildConfigLogic.generate_build_config(task.build.copr, task.mock_chroot.name) build_record["repos"] = build_config.get("repos") build_record["buildroot_pkgs"] = build_config.get("additional_packages")