Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def manual_patch_info(self, info, info_index, cluster, nodes):
if info.get("read_only_new_slave"):
info.pop("read_only_new_slave")

# test
def post_callback(self):
# 通过资源池获取到的节点
nodes = self.ticket_data.pop("nodes", [])
Expand Down
8 changes: 7 additions & 1 deletion dbm-ui/backend/ticket/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class TodoStatus(StrStructuredEnum):
TODO = EnumField("TODO", _("待处理"))
DONE_SUCCESS = EnumField("DONE_SUCCESS", _("已处理"))
DONE_FAILED = EnumField("DONE_FAILED", _("已终止"))
LACK_FIELD = EnumField("LACK_FIELD", _("资源不足"))


class ResourceApplyErrCode(IntStructuredEnum):
Expand Down Expand Up @@ -724,7 +725,12 @@ class FlowType(StrStructuredEnum):


# 任务流程类型合集
FLOW_TASK_TYPES = [FlowType.INNER_FLOW, FlowType.HOST_RECYCLE, FlowType.RESOURCE_HCM_REPLENISH]
FLOW_TASK_TYPES = [
FlowType.INNER_FLOW,
FlowType.HOST_RECYCLE,
FlowType.RESOURCE_HCM_REPLENISH,
FlowType.RESOURCE_APPLY,
]


class FlowContext(StrStructuredEnum):
Expand Down
9 changes: 2 additions & 7 deletions dbm-ui/backend/ticket/flow_manager/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ def _summary(self) -> str:
status_display=constants.TicketFlowStatus.get_choice_label(self.status)
)

@property
def status(self) -> str:
# 覆写base的状态判断,资源池申请节点的状态判断逻辑不同
return self._status

def update_flow_status(self, status):
self.flow_obj.update_status(status)
return status
Expand All @@ -87,8 +82,8 @@ def _status(self) -> str:
# 如果是其他情况引起的错误,则直接返回fail
if not self.flow_obj.todo_of_flow.exists():
return self.update_flow_status(constants.TicketFlowStatus.FAILED)
# 如果是资源申请的todo状态,则判断todo是否完成
if self.ticket.todo_of_ticket.exist_unfinished():
# 如果是资源申请的todo状态,则判断todo是否完成并且是否资源不足
if self.ticket.todo_of_ticket.exist_lack_unfinished():
return self.update_flow_status(constants.TicketFlowStatus.RUNNING)
else:
return self.flow_obj.status
Expand Down
3 changes: 3 additions & 0 deletions dbm-ui/backend/ticket/models/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class TodoManager(models.Manager):
def exist_unfinished(self):
return self.filter(status__in=TODO_RUNNING_STATUS).exists()

def exist_lack_unfinished(self):
return self.filter(status__in=TODO_RUNNING_STATUS, name__icontains=TodoStatus.LACK_FIELD).exists()

def get_operators(self, todo_type, flow, ticket, operators):
# 获得提单人,dba,协助人.
creator = [ticket.creator]
Expand Down
Loading