Skip to content

Commit d2ce6e5

Browse files
teng00123iSecloud
authored andcommitted
feat(backend): 解决资源申请flow失败终止不了bug #15429
1 parent 592b0b5 commit d2ce6e5

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

dbm-ui/backend/ticket/constants.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,11 @@ class FlowType(StrStructuredEnum):
724724

725725

726726
# 任务流程类型合集
727-
FLOW_TASK_TYPES = [FlowType.INNER_FLOW, FlowType.HOST_RECYCLE, FlowType.RESOURCE_HCM_REPLENISH]
727+
FLOW_TASK_TYPES = [
728+
FlowType.INNER_FLOW,
729+
FlowType.HOST_RECYCLE,
730+
FlowType.RESOURCE_HCM_REPLENISH,
731+
]
728732

729733

730734
class FlowContext(StrStructuredEnum):

dbm-ui/backend/ticket/flow_manager/resource.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,8 @@ def _status(self) -> str:
8484
return self.update_flow_status(constants.TicketFlowStatus.SUCCEEDED)
8585

8686
if self.flow_obj.err_msg:
87-
# 如果是其他情况引起的错误,则直接返回fail
88-
if not self.flow_obj.todo_of_flow.exists():
89-
return self.update_flow_status(constants.TicketFlowStatus.FAILED)
90-
# 如果是资源申请的todo状态,则判断todo是否完成
91-
if self.ticket.todo_of_ticket.exist_unfinished():
87+
# 如果是资源申请的todo状态,则判断todo是否完成并且是否资源不足
88+
if self.ticket.todo_of_ticket.exist_lack_unfinished():
9289
return self.update_flow_status(constants.TicketFlowStatus.RUNNING)
9390
else:
9491
return self.flow_obj.status

dbm-ui/backend/ticket/models/todo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class TodoManager(models.Manager):
2727
def exist_unfinished(self):
2828
return self.filter(status__in=TODO_RUNNING_STATUS).exists()
2929

30+
def exist_lack_unfinished(self):
31+
return self.filter(status__in=TODO_RUNNING_STATUS, type=TodoType.RESOURCE_REPLENISH).exists()
32+
3033
def get_operators(self, todo_type, flow, ticket, operators):
3134
# 获得提单人,dba,协助人.
3235
creator = [ticket.creator]

0 commit comments

Comments
 (0)