|
49 | 49 |
|
50 | 50 |
|
51 | 51 | @shared_task |
52 | | -def retry_node(root_id: str, node_id: str, retry_times: int) -> Union[EngineAPIResult, Any]: |
| 52 | +def retry_node(root_id: str, flow_node: FlowNode, retry_times: int) -> Union[EngineAPIResult, Any]: |
53 | 53 | """重试flow任务节点""" |
54 | 54 |
|
55 | 55 | def send_flow_state(state, _root_id, _node_id, _version_id): |
56 | 56 | post_set_state.send( |
57 | 57 | sender=None, |
58 | | - node_id=node_id, |
| 58 | + node_id=flow_node.node_id, |
59 | 59 | to_state=state, |
60 | 60 | version=flow_node.version_id, |
61 | 61 | root_id=flow_node.root_id, |
62 | 62 | parent_id=None, |
63 | 63 | loop=None, |
64 | 64 | ) |
65 | 65 |
|
66 | | - flow_node = FlowNode.objects.get(root_id=root_id, node_id=node_id) |
67 | | - |
68 | 66 | # 实例化一个Service实例用于捕获日志到日志平台 |
69 | 67 | service = BaseService() |
70 | | - service.setup_runtime_attrs(root_pipeline_id=root_id, id=node_id, version=flow_node.version_id) |
| 68 | + service.setup_runtime_attrs(root_pipeline_id=root_id, id=flow_node.node_id, version=flow_node.version_id) |
71 | 69 |
|
72 | 70 | # 限制最大重试次数 |
73 | 71 | if retry_times > MAX_AUTO_RETRY_TIMES: |
@@ -99,14 +97,14 @@ def send_flow_state(state, _root_id, _node_id, _version_id): |
99 | 97 | if retry_times == 1: |
100 | 98 | send_flow_state(StateType.RUNNING, root_id, flow_node.node_id, flow_node.version_id) |
101 | 99 |
|
102 | | - retry_node.apply_async((root_id, node_id, retry_times + 1), countdown=RETRY_INTERVAL) |
| 100 | + retry_node.apply_async((root_id, flow_node, retry_times + 1), countdown=RETRY_INTERVAL) |
103 | 101 | return EngineAPIResult(result=False, message=_("存在执行互斥将自动进行重试...")) |
104 | 102 | except (Ticket.DoesNotExist, ValueError): |
105 | 103 | # 如果单据不存在,则忽略校验 |
106 | 104 | pass |
107 | 105 |
|
108 | 106 | # 进行重试操作 |
109 | | - result = BambooEngine(root_id=root_id).retry_node(node_id=node_id) |
| 107 | + result = BambooEngine(root_id=root_id).retry_node(node_id=flow_node.node_id) |
110 | 108 | if not result.result: |
111 | 109 | raise RetryNodeException(str(result.exc.args)) |
112 | 110 |
|
|
0 commit comments