[Doc] Add example and notice about task type Conditions (#9945)
(cherry picked from commit 12a4b01268)
This commit is contained in:
parent
346767c97d
commit
c8f62adfc0
|
|
@ -4,15 +4,8 @@ Condition is a conditional node, that determines which downstream task should ru
|
|||
|
||||
## Create Task
|
||||
|
||||
Drag from the toolbar <img src="/img/conditions.png" width="20"/> task node to canvas to create a new Conditions task, as shown in the figure below:
|
||||
|
||||
<p align="center">
|
||||
<img src="/img/condition_dag_en.png" width="80%" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="/img/condition_task_en.png" width="80%" />
|
||||
</p>
|
||||
- Click `Project -> Management-Project -> Name-Workflow Definition`, and click the "Create Workflow" button to enter the DAG editing page.
|
||||
- Drag from the toolbar <img src="/img/conditions.png" width="20"/> task node to canvas.
|
||||
|
||||
## Parameter
|
||||
|
||||
|
|
@ -24,7 +17,7 @@ Drag from the toolbar <img src="/img/conditions.png" width="20"/> task node to c
|
|||
- Times of failed retry attempts: The number of times the task failed to resubmit. You can select from drop-down or fill-in a number.
|
||||
- Failed retry interval: The time interval for resubmitting the task after a failed task. You can select from drop-down or fill-in a number.
|
||||
- Timeout alarm: Check the timeout alarm and timeout failure. When the task runs exceed the "timeout", an alarm email will send and the task execution will fail.
|
||||
- Downstream tasks selection: supports two branches success and failure.
|
||||
- Downstream tasks selection: Depending on the status of the predecessor task, you can jump to the corresponding branch, currently two branches are supported: success, failure
|
||||
- Success: When the upstream task runs successfully, run the success branch.
|
||||
- Failure: When the upstream task runs failed, run the failure branch.
|
||||
- Upstream condition selection: can select one or more upstream tasks for conditions.
|
||||
|
|
@ -34,3 +27,34 @@ Drag from the toolbar <img src="/img/conditions.png" width="20"/> task node to c
|
|||
## Related Task
|
||||
|
||||
[switch](switch.md): Conditions task mainly executes the corresponding branch based on the execution status (success, failure) of the upstream nodes. The [Switch](switch.md) task node mainly executes the corresponding branch based on the value of the [global parameter](../parameter/global.md) and the result of user written expression.
|
||||
|
||||
## Example
|
||||
|
||||
This sample demonstrates the operation of the Condition task by using the [Shell](shell.md) task.
|
||||
|
||||
### 1. Create workflow
|
||||
|
||||
Go to the workflow definition page, and then create the following task nodes:
|
||||
|
||||
- Node_A: Shell task, prints out "hello world", its main function is the upstream branch of Condition, and triggers the corresponding branch node according to whether its execution is successful or not.
|
||||
- Condition: The Conditions task executes the corresponding branch according to the execution status of the upstream task.
|
||||
- Node_Success: Shell task, print out "success", Node_A executes the successful branch.
|
||||
- Node_False: Shell task, print out "false", Node_A executes the failed branch.
|
||||
|
||||

|
||||
|
||||
### 2. View the execution result
|
||||
|
||||
After you finish creating the workflow, you can run the workflow online. You can view the execution status of each task on the workflow instance page. As shown below:
|
||||
|
||||

|
||||
|
||||
In the above figure, the task status marked with a green check mark is the successfully executed task node.
|
||||
|
||||
## Notice
|
||||
|
||||
- The Conditions task supports multiple upstream tasks, but only two downstream tasks.
|
||||
- The Conditions task and the workflow that contain it do not support copy operations.
|
||||
- The predecessor task of Conditions cannot connect to its branch nodes, which will cause logical confusion and does not conform to DAG scheduling. The situation shown below is **wrong**.
|
||||
|
||||

|
||||
|
|
|
|||
|
|
@ -1,36 +1,60 @@
|
|||
# Conditions
|
||||
# Conditions 节点
|
||||
|
||||
Conditions是一个条件节点,根据上游任务运行状态,判断应该运行哪个下游任务。截止目前Conditions支持多个上游任务,但只支持两个下游任务。当上游任务数超过一个时,可以通过`且`以及`或`操作符实现复杂上游依赖
|
||||
Conditions 是一个条件节点,根据上游任务运行状态,判断应该运行哪个下游任务。截止目前 Conditions 支持多个上游任务,但只支持两个下游任务。当上游任务数超过一个时,可以通过`且`以及`或`操作符实现复杂上游依赖
|
||||
|
||||
## 创建任务
|
||||
|
||||
拖动工具栏中的<img src="/img/conditions.png" width="20"/>任务节点到画板中即能完成任务创建,如下图所示:
|
||||
|
||||
<p align="center">
|
||||
<img src="/img/condition_dag_en.png" width="80%" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="/img/condition_task_zh.png" width="80%" />
|
||||
</p>
|
||||
- 点击项目管理-项目名称-工作流定义,点击“创建工作流”按钮,进入 DAG 编辑页面;
|
||||
- 拖动工具栏中的<img src="/img/conditions.png" width="20"/>任务节点到画板中。
|
||||
|
||||
## 任务参数
|
||||
|
||||
- 节点名称:一个工作流定义中的节点名称是唯一的。
|
||||
- 节点名称:设置任务的名称,一个工作流定义中的节点名称是唯一的。
|
||||
- 运行标志:标识这个节点是否能正常调度,如果不需要执行,可以打开禁止执行开关。
|
||||
- 描述信息:描述该节点的功能。
|
||||
- 任务优先级:worker线程数不足时,根据优先级从高到低依次执行,优先级一样时根据先进先出原则执行。
|
||||
- Worker分组:任务分配给worker组的机器机执行,选择Default,会随机选择一台worker机执行。
|
||||
- 任务优先级:worker 线程数不足时,根据优先级从高到低依次执行,优先级一样时根据先进先出原则执行。
|
||||
- Worker 分组:任务分配给 worker 组的机器机执行,选择 Default,会随机选择一台 worker 机执行。
|
||||
- 失败重试次数:任务失败重新提交的次数,支持下拉和手填。
|
||||
- 失败重试间隔:任务失败重新提交任务的时间间隔,支持下拉和手填。
|
||||
- 超时告警:勾选超时告警、超时失败,当任务超过"超时时长"后,会发送告警邮件并且任务执行失败.
|
||||
- 下游任务选择:目前支持两个分支,成功、失败
|
||||
- 下游任务选择:根据前置任务的状态来跳转到对应的分支,目前支持两个分支:成功、失败
|
||||
- 成功:当上游运行成功时,运行成功选择的分支
|
||||
- 失败:当上游运行失败时,运行失败选择的分支
|
||||
- 上游条件选择:可以为conditions选择一个或多个上游任务
|
||||
- 增加上游依赖:通过选择第一个参数选择对应的任务名称,通过第二个参数选择触发的conditions任务的状态
|
||||
- 上游条件选择:可以为 Conditions 任务选择一个或多个上游任务
|
||||
- 增加上游依赖:通过选择第一个参数选择对应的任务名称,通过第二个参数选择触发的 Conditions 任务的状态
|
||||
- 上游任务关系选择:当有多个上游任务时,可以通过`且`以及`或`操作符实现任务的复杂关系。
|
||||
|
||||
## 相关任务
|
||||
|
||||
[switch](switch.md):Condition节点主要依据上游节点的执行状态(成功、失败)执行对应分支。[Switch](switch.md)节点主要依据全局变量的值和用户所编写的表达式判断结果执行对应分支
|
||||
[switch](switch.md):Condition节点主要依据上游节点的执行状态(成功、失败)执行对应分支。[Switch](switch.md)节点主要依据全局变量的值和用户所编写的表达式判断结果执行对应分支
|
||||
|
||||
## 任务样例
|
||||
|
||||
该样例通过使用 [Shell](shell.md) 任务来演示 Condition 任务的操作流程。
|
||||
|
||||
### 1、创建工作流
|
||||
|
||||
进入工作流定义页面,然后分别创建如下任务节点:
|
||||
|
||||
- Node_A:Shell 任务,打印输出 ”hello world“,其主要作用是 Condition 的上游分支,根据其执行是否成功来触发对应的分支节点。
|
||||
- Condition:Conditions 任务,根据上游任务的执行状态,来执行对应的分支。
|
||||
- Node_Success:Shell 任务,打印输出 “success”,Node_A 执行成功的分支。
|
||||
- Node_False:Shell 任务,打印输出 ”false“,Node_A 执行失败的分支。
|
||||
|
||||

|
||||
|
||||
### 2、查看执行结果
|
||||
|
||||
当完成创建工作流之后,可以上线运行该工作流。在工作流实例页面可以查看到各个任务的执行状态。如下图所示:
|
||||
|
||||

|
||||
|
||||
上图中,任务状态标记为绿色对号的,即为成功执行的任务节点。
|
||||
|
||||
## 注意事项
|
||||
|
||||
- Conditions 任务支持多个上游任务,但只支持两个下游任务。
|
||||
- Conditions 任务以及包含该任务的工作流不支持复制操作。
|
||||
- Conditions 的前置任务不能连接其分支节点,会造成逻辑混乱,不符合 DAG 调度。如下图所示的情况是**错误**的。
|
||||
|
||||

|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 119 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 127 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 125 KiB |
Loading…
Reference in New Issue