Skip to content

Commit

Permalink
feature: 原子操作能力支持滚动执行 TencentBlueKing#446
Browse files Browse the repository at this point in the history
  • Loading branch information
hLinx committed Dec 21, 2021
2 parents a839054 + 8e324a5 commit 66e24d4
Show file tree
Hide file tree
Showing 65 changed files with 919 additions and 526 deletions.
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ assignees: ''

---

**版本/分支/tag**

**问题描述**

**如何复现**

**预期结果**
2 changes: 1 addition & 1 deletion .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
- name: build
run: |
export JOB_VERSION=3.latest
npm i && npm run build
npm i --legacy-peer-deps && npm run build
working-directory: src/frontend
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ out/
### application ###
**/*.log
support-files/dependJarLists/
**/*.DS_Store
**/*.DS_Store
.codecc
build.yml
5 changes: 4 additions & 1 deletion src/backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
build
release

**/bin
**/bin

.codecc
build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import io.micrometer.core.instrument.MeterRegistry;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
Expand Down Expand Up @@ -385,12 +386,12 @@ public NodeDTO getFileNode(String filePath) {
return nodeDTO;
}

public InputStream getFileInputStream(String filePath) throws ServiceException {
public Pair<InputStream, Long> getFileInputStream(String filePath) throws ServiceException {
List<String> pathList = parsePath(filePath);
return getFileInputStream(pathList.get(0), pathList.get(1), pathList.get(2));
}

public InputStream getFileInputStream(String projectId, String repoName, String filePath) throws ServiceException {
public Pair<InputStream, Long> getFileInputStream(String projectId, String repoName, String filePath) throws ServiceException {
DownloadGenericFileReq req = new DownloadGenericFileReq();
req.setProject(projectId);
req.setRepo(repoName);
Expand All @@ -400,7 +401,20 @@ public InputStream getFileInputStream(String projectId, String repoName, String
CloseableHttpResponse resp;
try {
resp = longHttpHelper.getRawResp(false, url, getJsonHeaders());
return resp.getEntity().getContent();
Header contentLengthHeader = resp.getFirstHeader("Content-Length");
Long contentLength = null;
if (contentLengthHeader != null && StringUtils.isNotBlank(contentLengthHeader.getValue())) {
contentLength = Long.parseLong(contentLengthHeader.getValue());
log.debug("Content-Length from header:{}", contentLengthHeader.getValue());
} else {
log.debug("Content-Length from header is null or blank");
}
if (resp.getStatusLine() != null && resp.getStatusLine().getStatusCode() == 200) {
return Pair.of(resp.getEntity().getContent(), contentLength);
} else {
log.info("resp.statusLine={},resp.entity={}", resp.getStatusLine(), resp.getEntity());
throw new InternalException(ErrorCode.FAIL_TO_REQUEST_THIRD_FILE_SOURCE_DOWNLOAD_GENERIC_FILE);
}
} catch (IOException e) {
log.error("Fail to getFileInputStream", e);
throw new InternalException(ErrorCode.FAIL_TO_REQUEST_THIRD_FILE_SOURCE_DOWNLOAD_GENERIC_FILE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,35 @@
1243013=默认通知策略未配置,请联系管理员
1243014=账号被引用,禁止删除
1243015=文件大小超过上限{0}
1243016=创建 Tag 失败
1243017=引用的脚本未上线或被删除
1243018=新建模版失败
1243019=更新模版失败
1243020=保存模版发生未知错误
1243021=标签已存在
1243022=错误的变量类型
1243023=新建执行方案失败
1243024=更新执行方案失败
1243025=保存执行方案发生未知错误
1243026=模版不存在
1243027=创建调试模版失败
1243028=同步执行方案失败
1243029=不支持的步骤类型
1243030=批量操作失败
1243031=不支持的任务类型
1243032=新建步骤失败
1243033=更新步骤失败
1243034=删除步骤失败
1243035=更新文件信息失败
1243036=脚本版本已存在
1243037=删除失败!存在关联的定时任务
1243038=删除失败!执行方案存在关联的定时任务
1243039=脚本版本Id已存在
1243040=作业模板名称已存在
1243041=更新模版失败!并发冲突,请不要多次点击保存
1243045=同步脚本失败
1243047=脚本版本不存在
1243048=凭证不存在

##业务错误-作业执行(job-execute)
1244001=主机为空
Expand All @@ -129,10 +158,17 @@
1244021=文件任务数量超过限制:{0}
1244022=脚本任务目标服务器数量超过限制:{0}
1244023=本地文件{0}在后台不存在

## 业务错误-定时任务(job-crontab)
1245006=定时任务执行时间已失效
1245007=定时任务结束时间或通知时间已失效
1245005=更新定时任务获取锁失败

##业务错误-日志服务(job-logsvr)
1246001=获取作业执行日志失败
1246002=保存作业执行日志失败
1246003=删除作业执行日志失败

##业务错误-文件网关服务(job-file-gateway)
1260001=文件源不存在:{0}
1260002=接入点响应异常:ListFileNode,详情:{0}
Expand All @@ -147,6 +183,7 @@
1260012=无法根据标识{0}找到文件源
1260013=文件源服务异常
1260014=通过[{0}]找不到file-worker

##业务错误-文件Worker服务(job-file-worker)
1262001=第三方文件源响应异常:ListBucket,详情:{0}
1262002=第三方文件源响应异常:ListObjects,详情:{0}
Expand All @@ -157,37 +194,8 @@

##业务错误-用户服务、登录服务
1247001=用户不存在或者未登录
1243016=创建 Tag 失败
1243017=引用的脚本未上线或被删除
1243018=新建模版失败
1243019=更新模版失败
1243020=保存模版发生未知错误
1243021=标签已存在
1243022=错误的变量类型
1243023=新建执行方案失败
1243024=更新执行方案失败
1243025=保存执行方案发生未知错误
1243026=模版不存在
1243027=创建调试模版失败
1243028=同步执行方案失败
1243029=不支持的步骤类型
1243030=批量操作失败
1243031=不支持的任务类型
1243032=新建步骤失败
1243033=更新步骤失败
1243034=删除步骤失败
1243035=更新文件信息失败
1243036=脚本版本已存在
1243037=删除失败!存在关联的定时任务
1243038=删除失败!执行方案存在关联的定时任务
1243039=脚本版本Id已存在
1243045=同步脚本失败
1243047=脚本版本不存在
1243048=凭证不存在
1245006=定时任务执行时间已失效
1245007=定时任务结束时间或通知时间已失效
1245005=更新定时任务获取锁失败
1243041=更新模版失败!并发冲突,请不要多次点击保存。



##业务错误-备份服务
1249001=从制品库获取节点信息失败
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,35 @@
1243013=Default notify policies not configed, please contact system administrator
1243014=Account is referenced and cannot be deleted
1243015=File size exceeds maximum {0}

1243016=Create tag failed
1243017=Script version not online or deleted
1243018=Create job template failed
1243019=Update job template failed
1243020=Unknown error while saving job template
1243021=Tag already exist
1243022=Wrong variable type
1243023=Create job plan failed
1243024=Update job plan failed
1243025=Unknown error while saving job plan
1243026=Job template not exist
1243027=Error while creating debug plan
1243028=Sync job plan failed
1243029=Unsupported step type
1243030=Batch insert failed
1243031=Unsupported task type
1243032=Create step failed
1243033=Update step failed
1243034=Delete step failed
1243035=Update file info failed
1243036=Script version already exist
1243037=Delete failed! Plan is using by cron job(s)
1243038=Delete failed! Some plan(s) is(are) using by cron job(s)
1243039=Script version id already exist
1243040=Job template name already exist
1243041=Update template acquire lock failed! Please do not click save multiple times!
1243045=Sync script failed
1243047=Script version does not exist
1243048=Credential not exist

## Business error - job-execute
1244001=Host is empty
Expand All @@ -130,10 +158,17 @@
1244021=The number of file tasks exceeds the limit:{0}
1244022=The number of script task target servers exceeds the limit: {0}
1244023=The local file {0} not exists in backend

## Business error - job-crontab
1245006=Cron job execution time already passed
1245007=Cron job end time or notify time already passed
1245005=Acquire lock failed while update cron job

## Business error - job-logsvr
1246001=Failed to get execution log
1246002=Failed to save execution log
1246003=Failed to delete execution log

## Business error (job-file-gateway)
1260001=FileSource does not exist:{0}
1260002=FileWorker response error:ListFileNode, Detail:{0}
Expand All @@ -148,6 +183,7 @@
1260012=Cannot find file source by code:{0}
1260013=File source service invalid
1260014=Cannot find file-worker by {0}

## Business error (job-file-worker)
1262001=Third file source response error:ListBucket, Detail:{0}
1262002=Third file source response error:ListObjects, Detail:{0}
Expand All @@ -158,37 +194,6 @@

## Business error - User/Login
1247001=User does not exist or is not logged in
1243016=Create tag failed
1243017=Script version not online or deleted
1243018=Create job template failed
1243019=Update job template failed
1243020=Unknown error while saving job template
1243021=Tag already exist
1243022=Wrong variable type
1243023=Create job plan failed
1243024=Update job plan failed
1243025=Unknown error while saving job plan
1243026=Job template not exist
1243027=Error while creating debug plan
1243028=Sync job plan failed
1243029=Unsupported step type
1243030=Batch insert failed
1243031=Unsupported task type
1243032=Create step failed
1243033=Update step failed
1243034=Delete step failed
1243035=Update file info failed
1243036=Script version already exist
1243037=Delete failed! Plan is using by cron job(s)
1243038=Delete failed! Some plan(s) is(are) using by cron job(s)
1243039=Script version id already exist
1243045=Sync script failed
1243047=Script version does not exist
1243048=Credential not exist
1245006=Cron job execution time already passed
1245007=Cron job end time or notify time already passed
1245005=Acquire lock failed while update cron job
1243041=Update template acquire lock failed! Please do not click save multiple times!

## Business error - Backup
1249001=Fail to get node info from artifactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,35 @@
1243013=Default notify policies not configed, please contact system administrator
1243014=Account is referenced and cannot be deleted
1243015=File size exceeds maximum {0}

1243016=Create tag failed
1243017=Script version not online or deleted
1243018=Create job template failed
1243019=Update job template failed
1243020=Unknown error while saving job template
1243021=Tag already exist
1243022=Wrong variable type
1243023=Create job plan failed
1243024=Update job plan failed
1243025=Unknown error while saving job plan
1243026=Job template not exist
1243027=Error while creating debug plan
1243028=Sync job plan failed
1243029=Unsupported step type
1243030=Batch insert failed
1243031=Unsupported task type
1243032=Create step failed
1243033=Update step failed
1243034=Delete step failed
1243035=Update file info failed
1243036=Script version already exist
1243037=Delete failed! Plan is using by cron job(s)
1243038=Delete failed! Some plan(s) is(are) using by cron job(s)
1243039=Script version id already exist
1243040=Job template name already exist
1243041=Update template acquire lock failed! Please do not click save multiple times!
1243045=Sync script failed
1243047=Script version does not exist
1243048=Credential not exist

## Business error - job-execute
1244001=Host is empty
Expand All @@ -130,10 +158,17 @@
1244021=The number of file tasks exceeds the limit:{0}
1244022=The number of script task target servers exceeds the limit: {0}
1244023=The local file {0} not exists in backend

## Business error - job-crontab
1245006=Cron job execution time already passed
1245007=Cron job end time or notify time already passed
1245005=Acquire lock failed while update cron job

## Business error - job-logsvr
1246001=Failed to get execution log
1246002=Failed to save execution log
1246003=Failed to delete execution log

## Business error (job-file-gateway)
1260001=FileSource does not exist:{0}
1260002=FileWorker response error:ListFileNode, Detail:{0}
Expand All @@ -148,6 +183,7 @@
1260012=Cannot find file source by code:{0}
1260013=File source service invalid
1260014=Cannot find file-worker by {0}

## Business error (job-file-worker)
1262001=Third file source response error:ListBucket, Detail:{0}
1262002=Third file source response error:ListObjects, Detail:{0}
Expand All @@ -158,37 +194,6 @@

## Business error - User/Login
1247001=User does not exist or is not logged in
1243016=Create tag failed
1243017=Script version not online or deleted
1243018=Create job template failed
1243019=Update job template failed
1243020=Unknown error while saving job template
1243021=Tag already exist
1243022=Wrong variable type
1243023=Create job plan failed
1243024=Update job plan failed
1243025=Unknown error while saving job plan
1243026=Job template not exist
1243027=Error while creating debug plan
1243028=Sync job plan failed
1243029=Unsupported step type
1243030=Batch insert failed
1243031=Unsupported task type
1243032=Create step failed
1243033=Update step failed
1243034=Delete step failed
1243035=Update file info failed
1243036=Script version already exist
1243037=Delete failed! Plan is using by cron job(s)
1243038=Delete failed! Some plan(s) is(are) using by cron job(s)
1243039=Script version id already exist
1243045=Sync script failed
1243047=Script version does not exist
1243048=Credential not exist
1245006=Cron job execution time already passed
1245007=Cron job end time or notify time already passed
1245005=Acquire lock failed while update cron job
1243041=Update template acquire lock failed! Please do not click save multiple times!

## Business error - Backup
1249001=Fail to get node info from artifactory
Expand Down
Loading

0 comments on commit 66e24d4

Please sign in to comment.