Skip to content

Commit

Permalink
feature: Job 支持容器执行 - 脚本任务 TencentBlueKing#2631
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Dec 28, 2023
2 parents 24253b1 + b49029f commit 2673e30
Show file tree
Hide file tree
Showing 166 changed files with 5,060 additions and 1,377 deletions.
31 changes: 20 additions & 11 deletions docs/apidoc/bk-api-gateway/v3/zh/batch_get_job_instance_ip_log.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@
},
"dest_path": "/tmp/1.log",
"status": 4,
"log_content": "[2021-06-28 11:32:16] FileName: /tmp/1.log FileSize: 9.0 Bytes State: dest agent success download file Speed: 1 KB/s Progress: 100% StatusDesc: dest agent success download file Detail: success"
"log_content": "[2021-06-28 11:32:16] FileName: /tmp/1.log FileSize: 9.0 Bytes State: dest agent success download file Speed: 1 KB/s Progress: 100% StatusDesc: dest agent success download file Detail: success",
"size": "1.0 Bytes",
"speed": "0 KB/s",
"process": "100%"
}
]
},
Expand All @@ -127,7 +130,10 @@
},
"src_path": "/data/1.log",
"status": 4,
"log_content": "[2021-06-28 11:32:16] FileName: /data/1.log FileSize: 9.0 Bytes State: source agent success upload file Speed: 1 KB/s Progress: 100% StatusDesc: source agent success upload file Detail: success upload"
"log_content": "[2021-06-28 11:32:16] FileName: /data/1.log FileSize: 9.0 Bytes State: source agent success upload file Speed: 1 KB/s Progress: 100% StatusDesc: source agent success upload file Detail: success upload",
"size": "1.0 Bytes",
"speed": "0 KB/s",
"process": "100%"
}
]
}
Expand Down Expand Up @@ -173,15 +179,18 @@

##### file_log

| 字段 | 类型 | 描述 |
|-----------|-----------|-----------|
| mode | 分发模式 | 0:上传;1:下载|
| src_ip | object |文件源主机IP。定义见ip |
| src_path | string | 源文件路径 |
| dest_ip | object | 分发目标主机IP,mode=1时有值。定义见ip |
| dest_path | string | 目标路径,mode=1时有值 |
| status | int | 任务状态。1-等待开始;2-上传中;3-下载中;4-成功;5-失败 |
| log_content | string | 文件分发日志内容 |
| 字段 | 类型 | 描述 |
|--------------|-----------|-----------|
| mode | 分发模式 | 0:上传;1:下载|
| src_ip | object |文件源主机IP。定义见ip |
| src_path | string | 源文件路径 |
| dest_ip | object | 分发目标主机IP,mode=1时有值。定义见ip |
| dest_path | string | 目标路径,mode=1时有值 |
| status | int | 任务状态。1-等待开始;2-上传中;3-下载中;4-成功;5-失败 |
| log_content | string | 文件分发日志内容 |
| size | string | 文件大小 |
| speed | string | 文件传输速率 |
| process | string | 文件传输进度 |

##### ip

Expand Down
136 changes: 83 additions & 53 deletions docs/apidoc/bk-api-gateway/v3/zh/get_step_instance_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,52 @@
"start_time": 1605064271000,
"end_time": 1605064272000,
"total_time": 1000,
"step_host_result_list": [
"step_result_group_list": [
{
"bk_host_id": 101,
"ip": "127.0.0.1",
"ipv6": null,
"bk_cloud_id": 0,
"status": 9,
"status_desc": "执行成功",
"result_type": 9,
"result_type_desc": "执行成功",
"tag": "tag1",
"group_key": "9_tag1",
"exit_code": 0,
"start_time": 1605064271000,
"end_time": 1605064272000,
"total_time": 1000
"host_size": 2,
"host_result_list": [
{
"bk_host_id": 101,
"ip": "127.0.0.1",
"ipv6": null,
"bk_agent_id": null,
"bk_cloud_id": 0,
"bk_cloud_name": "Default Area",
"status": 9,
"status_desc": "执行成功",
"tag": "tag1",
"exit_code": 0,
"start_time": 1605064271000,
"end_time": 1605064272000,
"total_time": 1000
}
]
},
{
"bk_host_id": 102,
"ip": "127.0.0.2",
"ipv6": null,
"bk_cloud_id": 0,
"status": 9,
"status_desc": "执行成功",
"result_type": 9,
"result_type_desc": "执行成功",
"tag": "tag2",
"group_key": "9_tag2",
"exit_code": 0,
"start_time": 1605064271000,
"end_time": 1605064272000,
"total_time": 1000
"host_size": 2,
"host_result_list": [
{
"bk_host_id": 102,
"ip": "127.0.0.2",
"ipv6": null,
"bk_agent_id": null,
"bk_cloud_id": 0,
"bk_cloud_name": "Default Area",
"status": 9,
"status_desc": "执行成功",
"tag": "tag2",
"exit_code": 0,
"start_time": 1605064271000,
"end_time": 1605064272000,
"total_time": 1000
}
]
}
]
}
Expand All @@ -99,33 +117,45 @@

##### data

| 字段 | 类型 | 是否一定存在 | 描述 |
|-----------------------|--------------------------|------------|-----------|
| step_instance_id | long || 作业步骤实例ID |
| execute_count | int || 步骤重试次数 |
| name | string || 步骤名称 |
| type | int || 步骤类型:1-脚本步骤;2-文件步骤;4-SQL步骤 |
| status | int || 作业步骤状态码: 1-未执行,2-正在执行,3-执行成功,4-执行失败,5-跳过,6-忽略错误,7-等待用户,8-手动结束,9-状态异常,10-步骤强制终止中,11-步骤强制终止成功,12-步骤强制终止失败 |
| create_time | long || 作业步骤实例创建时间,Unix时间戳,单位毫秒 |
| start_time | long || 开始执行时间,Unix时间戳,单位毫秒 |
| end_time | long || 执行结束时间,Unix时间戳,单位毫秒 |
| total_time | int || 总耗时,单位毫秒 |
| step_host_result_list | list<step_host_result> || 每个主机的任务执行结果,定义见step_host_result |


##### step_host_result

| 字段 | 类型 | 是否一定存在 | 描述 |
|-------------|-----------|------------|-----------|
| bk_host_id | long || 主机ID |
| ip | string || IP |
| ipv6 | string || IPv6 |
| bk_cloud_id | long || 管控区域ID |
| status | int || 任务状态:0-未知错误,1-Agent异常,2-无效主机,3-上次已成功,5-等待执行,7-正在执行,9-执行成功,11-执行失败,12-任务下发失败,13-任务超时,15-任务日志错误,16-GSE脚本日志超时,17-GSE文件日志超时,101-脚本执行失败,102-脚本执行超时,103-脚本执行被终止,104-脚本返回码非零,202-文件传输失败,203-源文件不存在,301-文件任务系统错误-未分类的,303-文件任务超时,310-Agent异常,311-用户名不存在,312-用户密码错误,320-文件获取失败,321-文件超出限制,329-文件传输错误,399-任务执行出错,403-任务强制终止成功,404-任务强制终止失败,500-未知状态 |
| status_desc | string || 任务状态描述 |
| tag | string || 用户通过job_success/job_fail函数模板自定义输出的结果。仅脚本任务存在该参数 |
| group_key | string || 基于status与tag字段的分组键,仅用于调用方验证分组内数据数量是否正确,请勿强依赖该字段 |
| exit_code | int || 脚本任务exit code |
| start_time | long || 开始执行时间,Unix时间戳,单位毫秒 |
| end_time | long || 执行结束时间,Unix时间戳,单位毫秒 |
| total_time | int || 总耗时,单位毫秒 |
| 字段 | 类型 | 是否一定存在 | 描述 |
|------------------------|--------------------------|------------|-----------|
| step_instance_id | long || 作业步骤实例ID |
| execute_count | int || 步骤重试次数 |
| name | string || 步骤名称 |
| type | int || 步骤类型:1-脚本步骤;2-文件步骤;4-SQL步骤 |
| status | int || 作业步骤状态码: 1-未执行,2-正在执行,3-执行成功,4-执行失败,5-跳过,6-忽略错误,7-等待用户,8-手动结束,9-状态异常,10-步骤强制终止中,11-步骤强制终止成功,12-步骤强制终止失败 |
| create_time | long || 作业步骤实例创建时间,Unix时间戳,单位毫秒 |
| start_time | long || 开始执行时间,Unix时间戳,单位毫秒 |
| end_time | long || 执行结束时间,Unix时间戳,单位毫秒 |
| total_time | int || 总耗时,单位毫秒 |
| step_result_group_list | list<step_result_group> || 任务执行结果分组列表,元素定义见step_result_group |


##### step_result_group

| 字段 | 类型 | 是否一定存在 | 描述 |
|--------------------|--------------------|------------|-------------|
| result_type | int || 分组类型 |
| result_type_desc | string || 分组类型描述 |
| tag | string || 分组标签 |
| host_size | int || 分组内主机总量 |
| host_result_list | list<host_result> || 每个分组内的主机任务执行结果列表,元素定义见host_result |


##### host_result

| 字段 | 类型 | 是否一定存在 | 描述 |
|--------------------|-----------|------------|-----------|
| bk_host_id | long || 主机ID |
| ip | string || IP |
| ipv6 | string || IPv6 |
| bk_agent_id | string || AgentId |
| bk_cloud_id | long || 管控区域ID |
| bk_cloud_name | string || 管控区域名称 |
| status | int || 任务状态:0-未知错误,1-Agent异常,2-无效主机,3-上次已成功,5-等待执行,7-正在执行,9-执行成功,11-执行失败,12-任务下发失败,13-任务超时,15-任务日志错误,16-GSE脚本日志超时,17-GSE文件日志超时,101-脚本执行失败,102-脚本执行超时,103-脚本执行被终止,104-脚本返回码非零,202-文件传输失败,203-源文件不存在,301-文件任务系统错误-未分类的,303-文件任务超时,310-Agent异常,311-用户名不存在,312-用户密码错误,320-文件获取失败,321-文件超出限制,329-文件传输错误,399-任务执行出错,403-任务强制终止成功,404-任务强制终止失败,500-未知状态 |
| status_desc | string || 任务状态描述 |
| tag | string || 用户通过job_success/job_fail函数模板自定义输出的结果。仅脚本任务存在该参数 |
| exit_code | int || 脚本任务exit code |
| start_time | long || 开始执行时间,Unix时间戳,单位毫秒 |
| end_time | long || 执行结束时间,Unix时间戳,单位毫秒 |
| total_time | int || 总耗时,单位毫秒 |
88 changes: 88 additions & 0 deletions docs/apidoc/bk-api-gateway/v3/zh/query_agent_info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
### 功能描述

查询主机Agent在作业平台中的信息(可执行状态、版本等)

### 请求参数说明

{{ bkapi_authorization_description }}

#### Header参数

| 字段 | 类型 | 必选 | 描述 |
|-----------|------------|--------|------------|
| X-Bkapi-Authorization | string || 认证信息。详情参考[调用网关 API](https://github.com/TencentBlueKing/BKDocs/blob/master/ZH/7.0/APIGateway/apigateway/use-api/use-apigw-api.md) |
| Accept | string || 固定值。application/json|
| Content-Type | string || 固定值。application/json|

#### Body参数

| 字段 | 类型 | 必选 | 描述 |
|------------------------|--------------|-------|------------|
| bk_scope_type | string || 资源范围类型。可选值: biz - 业务,biz_set - 业务集 |
| bk_scope_id | string || 资源范围ID,与bk_scope_type对应, 表示业务ID或者业务集ID |
| host_id_list | list<long> || 主机ID数组,单次查询主机数量不可超过5000 |


### 请求参数示例

- POST
```json
{
"bk_scope_type": "biz",
"bk_scope_id": "1",
"host_id_list": [1,2,3]
}
```

### 返回结果示例

```json
{
"result": true,
"code": 0,
"message": "",
"data": {
"agent_info_list": [
{
"bk_host_id": 1,
"status": 0,
"version": "2.1.4"
},
{
"bk_host_id": 2,
"status": 1,
"version": "2.1.5"
},
{
"bk_host_id": 3,
"status": 1,
"version": "2.1.6"
}
]
}
}
```
### 返回结果说明

| 字段 | 类型 | 描述 |
|-----------|-----------|-----------|
| result | bool | 请求成功与否。true:请求成功;false请求失败 |
| code | int | 错误编码。 0表示success,>0表示失败错误 |
| message | string | 请求失败返回的错误信息|
| data | object | 请求返回的数据|
| permission | object | 权限信息|

##### data

| 字段 | 类型 | 描述 |
|-----------------------|----------------|-----------|
| agent_info_list | list<object> | 元素为Agent信息,详情见agent_info对象定义,若传入的host_id在返回结果的列表中不存在,则表示未查询到该主机的agent信息 |


##### agent_info

| 字段 | 类型 | 描述 |
|-----------------|------------------|-----------|
| bk_host_id | long | 主机ID |
| status | int | Agent状态:0-异常,1-正常 |
| version | string | Agent的版本 |
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ Bulk query of job execution logs by host list
},
"dest_path": "/tmp/1.log",
"status": 4,
"log_content": "[2021-06-28 11:32:16] FileName: /tmp/1.log FileSize: 9.0 Bytes State: dest agent success download file Speed: 1 KB/s Progress: 100% StatusDesc: dest agent success download file Detail: success"
"log_content": "[2021-06-28 11:32:16] FileName: /tmp/1.log FileSize: 9.0 Bytes State: dest agent success download file Speed: 1 KB/s Progress: 100% StatusDesc: dest agent success download file Detail: success",
"size": "1.0 Bytes",
"speed": "0 KB/s",
"process": "100%"
}
]
},
Expand All @@ -120,7 +123,10 @@ Bulk query of job execution logs by host list
},
"src_path": "/data/1.log",
"status": 4,
"log_content": "[2021-06-28 11:32:16] FileName: /data/1.log FileSize: 9.0 Bytes State: source agent success upload file Speed: 1 KB/s Progress: 100% StatusDesc: source agent success upload file Detail: success upload"
"log_content": "[2021-06-28 11:32:16] FileName: /data/1.log FileSize: 9.0 Bytes State: source agent success upload file Speed: 1 KB/s Progress: 100% StatusDesc: source agent success upload file Detail: success upload",
"size": "1.0 Bytes",
"speed": "0 KB/s",
"process": "100%"
}
]
}
Expand Down Expand Up @@ -176,15 +182,18 @@ Bulk query of job execution logs by host list

#### file_log

| Fields | Type | Description |
|-----------|-----------|-----------|
| mode | int | Distribution mode. 0: Upload; 1: Download |
| src_ip | object |File source host IP. see ip for definition |
| src_path | string | Source file paths |
| dest_ip | object | Distribute the target host IP, with value for mode=1. See ip for definition. |
| dest_path | string | Target path, with value for mode=1 |
| status | int | Task status. 1-Waiting; 2-Uploading; 3-Downloading; 4- Success; 5- Failure |
| Fields | Type | Description |
|-------------|-----------|-----------|
| mode | int | Distribution mode. 0: Upload; 1: Download |
| src_ip | object |File source host IP. see ip for definition |
| src_path | string | Source file paths |
| dest_ip | object | Distribute the target host IP, with value for mode=1. See ip for definition. |
| dest_path | string | Target path, with value for mode=1 |
| status | int | Task status. 1-Waiting; 2-Uploading; 3-Downloading; 4- Success; 5- Failure |
| log_content | string | File distribution log contents |
| size | string | File size |
| speed | string | File transfer speed |
| process | string | File transfer process |

#### ip

Expand Down
Loading

0 comments on commit 2673e30

Please sign in to comment.