From 575b2f49e2e89800feccc799293afd52c4d6ec5d Mon Sep 17 00:00:00 2001 From: clime Date: Oct 27 2017 10:05:34 +0000 Subject: [frontend] fix of provisional queueing logic --- diff --git a/frontend/coprs_frontend/coprs/logic/builds_logic.py b/frontend/coprs_frontend/coprs/logic/builds_logic.py index 3c731c7..6f65de6 100644 --- a/frontend/coprs_frontend/coprs/logic/builds_logic.py +++ b/frontend/coprs_frontend/coprs/logic/builds_logic.py @@ -167,6 +167,12 @@ class BuildsLogic(object): return (lowest_prio_task.priority if lowest_prio_task else 0) @classmethod + def get_task_lowest_priority(cls, background=False): + prio1 = cls.get_build_task_lowest_priority(background) + prio2 = cls.get_srpm_build_task_lowest_priority(background) + return max(prio1, prio2) + + @classmethod def get_build_task(cls, task_id): try: build_id, chroot_name = task_id.split("-", 1) @@ -185,7 +191,7 @@ class BuildsLogic(object): build = cls.get(build_id).first() if not build: return None - build.priority = (BuildsLogic.get_srpm_build_task_lowest_priority()+1)%MAX_PRIO + build.priority = (BuildsLogic.get_task_lowest_priority(build.is_background)+1)%MAX_PRIO db.session.add(build) return build @@ -599,7 +605,7 @@ GROUP BY is_background=bool(background), batch=batch, srpm_url=srpm_url, - priority=(cls.get_srpm_build_task_lowest_priority()+1)%MAX_PRIO + priority=(cls.get_task_lowest_priority(bool(background))+1)%MAX_PRIO ) if timeout: @@ -614,7 +620,7 @@ GROUP BY if skip_import: status = StatusEnum("pending") - priority = (cls.get_build_task_lowest_priority()+1)%MAX_PRIO + priority = (cls.get_task_lowest_priority(bool(background))+1)%MAX_PRIO else: status = StatusEnum("importing") priority = 0 @@ -864,7 +870,7 @@ class BuildChrootsLogic(object): chroot = cls.get_by_build_id_and_name(build_id, name).first() if not chroot: return None - chroot.priority = (BuildsLogic.get_build_task_lowest_priority()+1)%MAX_PRIO + chroot.priority = (BuildsLogic.get_task_lowest_priority(chroot.build.is_background)+1)%MAX_PRIO db.session.add(chroot) return chroot 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 e15d93b..9267045 100644 --- a/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py +++ b/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py @@ -99,7 +99,7 @@ def dist_git_upload_completed(): for ch in build_chroots: if ch.status == helpers.StatusEnum("importing"): ch.status = helpers.StatusEnum("pending") - ch.priority = (BuildsLogic.get_build_task_lowest_priority()+1)%MAX_PRIO + ch.priority = (BuildsLogic.get_task_lowest_priority(build.is_background)+1)%MAX_PRIO ch.git_hash = git_hash # Failed?