Feat: add logs and workflow operation doc (#1040)

* Feat: add logs and workflow operation doc

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* add sidebar

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* add en ver

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* fix tip

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* fix lik

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* add slug

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* fix restart

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
This commit is contained in:
Tianxin Dong 2022-11-01 20:37:18 +08:00 committed by GitHub
parent 9e6efb5c2c
commit 7b265b5ec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 233 additions and 61 deletions

View File

@ -0,0 +1,79 @@
---
title: Workflow Operations
---
This section introduces how to use the `vela` CLI to operate workflow.
## Suspend Workflow
If you have an executing workflow, you can use the `suspend` command to suspend the workflow.
```bash
vela workflow suspend <name>
```
:::tip
Nothing will happen if you suspend an application that has a completed workflow, which is in `running` status.
Please refer to [Suspend and Resume](./suspend) for more examples.
:::
## Resume Workflow
Once the workflow is suspended, you can use the `vela workflow resume` command to manually resume the workflow.
```bash
vela workflow resume <name>
```
:::tip
Please refer to [Suspend and Resume](./suspend) for more examples.
:::
## Terminate Workflow
You can use `vela workflow terminate` to terminate an executing workflow.
```bash
vela workflow terminate <name>
```
:::tip
Different from suspend, the terminated workflow can't be resumed, you can only restart the workflow. This means restart the workflow will execute the workflow steps from scratch while resume workflow only continue the unfinished steps.
:::
:::caution
Once application workflow is terminated, KubeVela controller won't reconcile the application resources. It can also be used in some cases when you want to manually operate the underlying resources, please caution the configuration drift.
:::
## Restart Workflow
You can use `vela workflow restart` to restart an executing workflow.
```bash
vela workflow restart my-app
```
## Check the logs of the workflow
You can use `vela workflow logs` to check the logs of the workflow.
:::tip
Note that only the steps with [op.#Log](../../platform-engineers/workflow/cue-actions#log) in its definition will output logs.
:::
```bash
vela workflow logs <name>
```
## Debug Workflow
You can use `vela workflow debug` to debug the workflow.
```bash
vela workflow debug <name>
```
:::tip
Please checkout the [Debug doc](../../platform-engineers/debug/debug#applications-with-workflow) for more examples.
:::

View File

@ -33,17 +33,19 @@ If you do not explicitly declare the execution mode, by default steps are execut
## State of Application and Workflow
| Application | Workflow | Description |
| :----------------: | :--------: | :-----------------------------------------------------------------------------------------------------: |
| runningWorkflow | executing | When the workflow is executing, the status of the application is runningWorkflow |
| workflowSuspending | suspending | When the workflow is suspended, the status of the application is workflowSuspending |
| workflowTerminated | terminated | When a step in the workflow fails or is terminated, the status of the application is workflowTerminated |
| running | succeeded | When all steps in the workflow are executed successfully, the status of the application is running |
| Application | Workflow | Description |
| :----------------: | :--------: | :--------------------------------------------------------------------------------------------------------------: |
| runningWorkflow | executing | When the workflow is executing, the status of the application is runningWorkflow |
| workflowSuspending | suspending | When the workflow is suspended, the status of the application is workflowSuspending |
| workflowTerminated | terminated | When the workflow is terminated, the status of the application is workflowTerminated |
| workflowFailed | failed | When a step in the workflow fails and the workflow is completed, the status of the application is workflowFailed |
| running | succeeded | When all steps in the workflow are executed successfully, the status of the application is running |
## Core features
Workflow has powerful process control capabilities, including:
- View [Workflow Operations](./operations) to learn how to operate the workflow.
- View [Suspend and Resume Workflow](./suspend) to learn how to suspend and resume a workflow.
- View [Sub Steps](./step-group) to learn how to use sub-steps in the workflow.
- View [Dependency](./dependency) to learn how to specify dependencies for workflow steps.

View File

@ -173,32 +173,6 @@ Services:
As you can see, the workflow has continued to execute.
### Terminate Manually
If you want to terminate a workflow while it is suspended, you can use the `vela workflow terminate` command to terminate the workflow.
* Terminate the application workflow
```bash
vela workflow terminate my-app
```
:::tip
Different from suspend, the terminated application workflow can't be resumed, you can only restart the workflow. This means restart the workflow will execute the workflow steps from scratch while resume workflow only continue the unfinished steps.
:::
* Restart the application workflow
```bash
vela workflow restart my-app
```
:::caution
Once application is terminated, KubeVela controller won't reconcile the application resources. It can also be used in some cases when you want to manually operate the underlying resources, please caution the configuration drift.
:::
Once application come into `running` status, it can't be terminated or restarted.
### Resume the Workflow Automatically
If you want the workflow to be continued automatically after a period of time has passed. Then, you can add a `duration` parameter to the `suspend` step. When the `duration` time elapses, the workflow will automatically continue execution.

View File

@ -1,5 +1,6 @@
---
title: Debug in the environment
slug: /platform-engineers/debug/debug
---
> This feature is available in KubeVela v1.4.

View File

@ -319,6 +319,9 @@
"sidebar.docs.category.Declarative Workflow": {
"message": "声明式工作流"
},
"sidebar.docs.category.Application Workflow": {
"message": "应用工作流"
},
"sidebar.docs.category.Multi Cluster Delivery": {
"message": "多集群交付"
},

View File

@ -0,0 +1,78 @@
---
title: 工作流操作
---
本节将介绍如何使用 `vela` CLI 来进行操作工作流。
## 暂停工作流
如果你有一个正在执行中的工作流,那么,你可以用 `suspend` 命令来暂停这个工作流。
```bash
vela workflow suspend <name>
```
:::tip
如果工作流已经执行完毕,对应用使用 `vela workflow suspend` 命令不会产生任何效果。
请查看 [工作流的暂停和继续](./suspend) 来获得更多例子。
:::
## 继续工作流
当工作流进入暂停状态后,你可以使用 `vela workflow resume` 命令来手动继续工作流。workflow resume 命令会把工作流从暂停状态恢复到执行状态。
```bash
vela workflow resume <name>
```
:::tip
请查看 [工作流的暂停和继续](./suspend) 来获得更多例子。
:::
## 终止工作流
当工作流正在执行时,如果你想终止它,你可以使用 `vela workflow terminate` 命令来终止工作流。
```bash
vela workflow terminate <name>
```
:::tip
区别于暂停,终止的工作流不能继续执行,只能重新运行工作流。重新运行意味着工作流会重新开始执行所有工作流步骤,而继续工作流则是从暂停的步骤后面继续执行。
:::
:::caution
一旦应用被终止KubeVela 控制器不会再对资源做状态维持,你可以对底层资源做手动修改但请注意防止配置漂移。
:::
## 重新运行工作流
如果你希望重新运行工作流,那么你可以使用 `vale workflow restart` 命令来重新运行工作流。
```bash
vela workflow restart my-app
```
## 查看工作流日志
如果你想查看工作流的日志,你可以使用 `vela workflow logs` 命令来查看工作流的日志。
:::tip
只有配置了 [op.#Log](../../platform-engineers/workflow/cue-actions#log) 的步骤才会有日志输出。
:::
```bash
vela workflow logs <name>
```
## 调试工作流
如果你想在环境中调试工作流,你可以使用 `vela workflow debug` 命令来调试工作流。
```bash
vela workflow debug <name>
```
:::tip
请查看 [Debug 文档](../../platform-engineers/debug/debug#使用工作流的应用) 来获得更多例子。
:::

View File

@ -16,7 +16,7 @@ title: 总览
在工作流中,所有的步骤将顺序执行,下一个步骤将在上一个步骤成功后执行。如果一个步骤的类型为步骤组,那么它可以包含一系列子步骤,在执行这个步骤组时,所有子步骤都会一起执行。
> 在 KubeVela 未来的版本1.5+中,你可以显示地指定步骤的执行方式来控制并发或者单步执行,如:
> 在 KubeVela v1.5+ 中,你可以显示地指定步骤的执行方式来控制并发或者单步执行,如:
> ```yaml
> workflow:
> mode:
@ -33,13 +33,15 @@ title: 总览
| :-------: | :----: | :-----------------------------------: |
| runningWorkflow | executing | 当工作流正在执行时,应用的状态为 runningWorkflow |
| workflowSuspending | suspending | 当工作流暂停时,应用的状态为 workflowSuspending |
| workflowTerminated | terminated | 当工作流中有步骤失败或者被终止时,应用的状态为 workflowTerminated |
| workflowTerminated | terminated | 当工作流被终止时,应用的状态为 workflowTerminated |
| workflowFailed | failed | 当工作流执行完成,且有步骤失败时,应用的状态为 workflowFailed |
| running | succeeded | 当工作流中所有步骤都成功执行后,应用的状态为 running |
## 核心功能
工作流拥有丰富的流程控制能力,包括:
- 查看 [操作工作流](./operations),了解如何在 CLI 命令行中操作工作流。
- 查看 [暂停和继续工作流](./suspend),了解如何在工作流中使用暂停步骤完成人工审核,自动继续等功能。
- 查看 [子步骤](./step-group),了解如何在工作流中使用子步骤完成一组步骤的执行。
- 查看 [依赖关系](./dependency),了解如何指定工作流步骤间的依赖关系。

View File

@ -173,32 +173,6 @@ Services:
可以看到,工作流已经继续执行完毕。
### 手动终止工作流
当工作流处于暂停状态时,如果你想终止它,你可以使用 `vela workflow terminate` 命令来终止工作流。
* 终止工作流
```bash
vela workflow terminate my-app
```
:::tip
区别于暂停,终止的工作流不能继续执行,只能重新运行工作流。重新运行意味着工作流会重新开始执行所有工作流步骤,而继续工作流则是从暂停的步骤后面继续执行。
:::
* 重新运行工作流
```bash
vela workflow restart my-app
```
:::caution
一旦应用被终止KubeVela 控制器不会再对资源做状态维持,你可以对底层资源做手动修改但请注意防止配置漂移。
:::
工作流执行完毕进入正常运行状态的应用无法被终止或重新运行。
### 自动继续工作流
如果你希望经过了一段时间后,工作流能够自动被继续。那么,你可以在 `suspend` 步骤中加上 `duration` 参数。当 `duration` 时间超过后,工作流将自动继续执行。

View File

@ -1,5 +1,6 @@
---
title: 在环境中调试
slug: /platform-engineers/debug/debug
---
> 该功能需要安装至少 KubeVela v1.4 及以上版本.

View File

@ -66,6 +66,53 @@ fail: op.#Fail & {
}
```
## 数据控制
### Log
在该步骤中输出日志,或者配置该步骤的日志来源。如果某个步骤定义中使用了 `op.#Log`,那么你可以使用 `vela workflow logs <name>` 来查看该步骤的日志。
**参数定义**
```
#Log: {
// +usage=The data to print in the controller logs
data?: {...} | string
// +usage=The log level of the data
level: *3 | int
// +usage=The log source of this step. You can specify it from a url or resources. Note that if you set source in multiple op.#Log, only the latest one will work
source?: close({
// +usage=Specify the log source url of this step
url: string
}) | close({
// +usage=Specify the log resources of this step
resources?: [...{
// +usage=Specify the name of the resource
name?: string
// +usage=Specify the cluster of the resource
cluster?: string
// +usage=Specify the namespace of the resource
namespace?: string
// +usage=Specify the label selector of the resource
labelSelector?: {...}
}]
})
}
```
**用法示例**
```
import "vela/op"
myLog: op.#Log & {
data: "my custom log"
resources: [{
labelsSelector: {"test-key": "test-value"}
}]
}
```
### Message
往该工作流步骤状态的 Message 中写入信息。
@ -79,6 +126,16 @@ fail: op.#Fail & {
}
```
**用法示例**
```
import "vela/op"
msg: op.#Message & {
message: "custom message"
}
```
### DoVar
用来在 workflow 的上下文中保存或者读取用户定义的数据

View File

@ -159,13 +159,14 @@ module.exports = {
'end-user/workflow/component-dependency-parameter',
{
type: 'category',
label: 'Declarative Workflow',
label: 'Application Workflow',
collapsed: true,
link: {
type: "doc",
id: 'end-user/workflow/overview',
},
items: [
'end-user/workflow/operations',
'end-user/workflow/suspend',
'end-user/workflow/step-group',
'end-user/workflow/dependency',