diff --git a/frontend/coprs_frontend/coprs/logic/complex_logic.py b/frontend/coprs_frontend/coprs/logic/complex_logic.py index 4c1007298..72ab6c4ea 100644 --- a/frontend/coprs_frontend/coprs/logic/complex_logic.py +++ b/frontend/coprs_frontend/coprs/logic/complex_logic.py @@ -1,5 +1,4 @@ # coding: utf-8 - import os import datetime import time @@ -126,7 +125,6 @@ def delete_expired_projects(cls): print(e) print("project {} postponed".format(copr.full_name)) - @classmethod def fork_copr(cls, copr, user, dstname, dstgroup=None): cls.raise_if_cant_fork(user, copr) 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 59a11c877..87fe14dde 100755 --- a/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py +++ b/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py @@ -1,5 +1,5 @@ import flask -from copr_common.enums import StatusEnum +from copr_common.enums import StatusEnum, ActionTypeEnum, ActionObjectTypeEnum from coprs import db, app from coprs import models from coprs.logic import actions_logic @@ -287,8 +287,27 @@ def build_task_canceled(task_id): @backend_ns.route("/pending-actions/") def pending_actions(): 'get the list of actions backand should take care of' + waiting_actions = actions_logic.ActionsLogic.get_waiting() + busy_namespaces = set() + for action in waiting_actions: + if ( + action.object_type == ActionObjectTypeEnum.COPR + and action.action_type == ActionTypeEnum("delete") + ): + busy_namespaces.add(action.copr.full_name) + data = [] - for action in actions_logic.ActionsLogic.get_waiting(): + for action in waiting_actions: + if ( + action.copr.full_name in busy_namespaces + and action.action_type != ActionTypeEnum("delete") + ): + # e.g. copr delete _ && copr fork _; will cause race condition + # so don't process new action with the same namespace until delete + # action is processed + # https://github.com/fedora-copr/copr/issues/2698 + continue + data.append({ 'id': action.id, 'priority': action.priority or action.default_priority, @@ -296,7 +315,6 @@ def pending_actions(): return flask.json.dumps(data) - @backend_ns.route("/action//") def get_action(action_id): action = actions_logic.ActionsLogic.get(action_id).one()