[copr] master: new queue for backend (6595634)
by asamalik@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 6595634f0eb8979b0bd28de7699fde0cd2e63ee9
Author: Adam Samalik <asamalik(a)redhat.com>
Date: Mon Jul 28 16:20:04 2014 +0200
new queue for backend
>---------------------------------------------------------------
.../coprs/views/backend_ns/backend_general.py | 36 +++++++++----------
.../test_backend_ns/test_backend_general.py | 2 +-
2 files changed, 18 insertions(+), 20 deletions(-)
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 3c1b723..ba5ed04 100644
--- a/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py
+++ b/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py
@@ -24,25 +24,23 @@ def waiting():
for action in actions_logic.ActionsLogic.get_waiting()
]
- # models.Builds
- builds_list = []
-
- for build in builds_logic.BuildsLogic.get_waiting():
- build_dict = build.to_dict(
- options={"copr": {"owner": {},
- "__columns_only__": ["id", "name"],
- "__included_ids__": False
- },
- "__included_ids__": False})
-
- # return separate build for each chroot this build
- # is assigned with
- for chroot in build.chroots:
- build_dict_copy = build_dict.copy()
- build_dict_copy["chroot"] = chroot.name
- build_dict_copy[
- "buildroot_pkgs"] = build.copr.buildroot_pkgs(chroot)
- builds_list.append(build_dict_copy)
+ # tasks represented by models.BuildChroot with some other stuff
+ builds_list = [
+ {
+ "task_id": str(task.build.id)+"-"+task.mock_chroot.name,
+ "build_id": task.build.id,
+ "project_owner": task.build.copr.owner.name,
+ "project_name": task.build.copr.name,
+ "submitter": task.build.user.name,
+ "pkgs": task.build.pkgs,
+ "chroot": task.mock_chroot.name,
+ "buildroot_pkgs": task.build.copr.buildroot_pkgs(task.mock_chroot),
+ "repos": task.build.repos,
+ "memory_reqs": task.build.memory_reqs,
+ "timeout": task.build.timeout
+ }
+ for task in builds_logic.BuildsLogic.get_build_task_queue()
+ ]
return flask.jsonify({"actions": actions_list, "builds": builds_list})
diff --git a/frontend/coprs_frontend/tests/test_views/test_backend_ns/test_backend_general.py b/frontend/coprs_frontend/tests/test_views/test_backend_ns/test_backend_general.py
index c46d5b3..ec15ddb 100644
--- a/frontend/coprs_frontend/tests/test_views/test_backend_ns/test_backend_general.py
+++ b/frontend/coprs_frontend/tests/test_views/test_backend_ns/test_backend_general.py
@@ -14,7 +14,7 @@ class TestWaitingBuilds(CoprsTestCase):
self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
r = self.tc.get("/backend/waiting/", headers=self.auth_header)
- assert len(json.loads(r.data)["builds"]) == 4
+ assert len(json.loads(r.data)["builds"]) == 5
# status = 0 # failure
9 years, 9 months
[copr] master: [frontend] new waiting queue (0aabda9)
by asamalik@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 0aabda983c7d0d3fac17714d2ba308abe2db2355
Author: Adam Samalik <asamalik(a)redhat.com>
Date: Mon Jul 28 15:39:05 2014 +0200
[frontend] new waiting queue
>---------------------------------------------------------------
.../coprs_frontend/coprs/logic/builds_logic.py | 20 ++++++++++++++++++++
.../coprs/views/status_ns/status_general.py | 4 +---
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/logic/builds_logic.py b/frontend/coprs_frontend/coprs/logic/builds_logic.py
index 9fb04e1..fbed18f 100644
--- a/frontend/coprs_frontend/coprs/logic/builds_logic.py
+++ b/frontend/coprs_frontend/coprs/logic/builds_logic.py
@@ -1,4 +1,6 @@
import time
+from sqlalchemy import or_
+from sqlalchemy import and_
from coprs import db
from coprs import exceptions
@@ -24,6 +26,24 @@ class BuildsLogic(object):
return query
@classmethod
+ def get_build_task_queue(cls):
+ """
+ Returns BuildChroots which are - waiting to be built or
+ - older than 2 hours and unfinished
+ """
+ query = models.BuildChroot.query.join(models.Build).filter(or_(
+ models.BuildChroot.status == helpers.StatusEnum("pending"),
+ models.BuildChroot.status == helpers.StatusEnum("starting"),
+ and_(
+ models.BuildChroot.status == helpers.StatusEnum("running"),
+ models.Build.started_on < int(time.time() - 7200),
+ models.Build.ended_on == None
+ )
+ ))
+ query.order_by(models.BuildChroot.build_id.desc())
+ return query
+
+ @classmethod
def get_multiple(cls, user, **kwargs):
copr = kwargs.get("copr", None)
username = kwargs.get("username", None)
diff --git a/frontend/coprs_frontend/coprs/views/status_ns/status_general.py b/frontend/coprs_frontend/coprs/views/status_ns/status_general.py
index 2608420..eb0e103 100644
--- a/frontend/coprs_frontend/coprs/views/status_ns/status_general.py
+++ b/frontend/coprs_frontend/coprs/views/status_ns/status_general.py
@@ -8,9 +8,7 @@ from coprs import helpers
@status_ns.route("/")
@status_ns.route("/waiting/")
def waiting():
- tasks = []
- for build in builds_logic.BuildsLogic.get_waiting():
- tasks += build.build_chroots
+ tasks = builds_logic.BuildsLogic.get_build_task_queue()
return flask.render_template("status/waiting.html",
number=len(list(tasks)),
tasks=tasks)
9 years, 9 months