status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
case RESOURCE_FILE_NAME: List<Resource> ownResources = resourceMapper.listAuthorizedResource(userId, needChecks); addAuthorizedResources(ownResources, userId); Set<String> authorizedResources = ownResources.stream().map(Resource::getFullName).collect(toSet()); originResSet.removeAll(authorizedResources); break; case DATASOURCE: Set<Integer> authorizedDatasources = dataSourceMapper.listAuthorizedDataSource(userId, needChecks) .stream().map(DataSource::getId).collect(toSet()); originResSet.removeAll(authorizedDatasources); break; case UDF: Set<Integer> authorizedUdfs = udfFuncMapper.listAuthorizedUdfFunc(userId, needChecks).stream() .map(UdfFunc::getId).collect(toSet()); originResSet.removeAll(authorizedUdfs); break; default: break; } resultList.addAll(originResSet); } return resultList; } /** * get user by user id * * @param userId user id * @return User */ @Override
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
public User getUserById(int userId) { return userMapper.selectById(userId); } /** * get resource by resource id * * @param resourceId resource id * @return Resource */ @Override public Resource getResourceById(int resourceId) { return resourceMapper.selectById(resourceId); } /** * list resources by ids * * @param resIds resIds * @return resource list */ @Override public List<Resource> listResourceByIds(Integer[] resIds) { return resourceMapper.listResourceByIds(resIds); } /** * format task app id in task instance */ @Override public String formatTaskAppId(TaskInstance taskInstance) { ProcessInstance processInstance = findProcessInstanceById(taskInstance.getProcessInstanceId()); if (processInstance == null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
return ""; } ProcessDefinition definition = findProcessDefinition(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); if (definition == null) { return ""; } return String.format("%s_%s_%s", definition.getId(), processInstance.getId(), taskInstance.getId()); } /** * switch process definition version to process definition log version */ @Override public int switchVersion(ProcessDefinition processDefinition, ProcessDefinitionLog processDefinitionLog) { if (null == processDefinition || null == processDefinitionLog) { return Constants.DEFINITION_FAILURE; } processDefinitionLog.setId(processDefinition.getId()); processDefinitionLog.setReleaseState(ReleaseState.OFFLINE); processDefinitionLog.setFlag(Flag.YES); int result = processDefineMapper.updateById(processDefinitionLog); if (result > 0) { result = switchProcessTaskRelationVersion(processDefinitionLog); if (result <= 0) { return Constants.EXIT_CODE_FAILURE; } } return result; } @Override
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
public int switchProcessTaskRelationVersion(ProcessDefinition processDefinition) { List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper .queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()); if (!processTaskRelationList.isEmpty()) { processTaskRelationMapper.deleteByCode(processDefinition.getProjectCode(), processDefinition.getCode()); } List<ProcessTaskRelation> processTaskRelationListFromLog = processTaskRelationLogMapper .queryByProcessCodeAndVersion(processDefinition.getCode(), processDefinition.getVersion()).stream() .map(ProcessTaskRelation::new).collect(Collectors.toList()); int batchInsert = processTaskRelationMapper.batchInsert(processTaskRelationListFromLog); if (batchInsert == 0) { return Constants.EXIT_CODE_FAILURE; } else { int result = 0; for (ProcessTaskRelation taskRelation : processTaskRelationListFromLog) { int switchResult = switchTaskDefinitionVersion(taskRelation.getPostTaskCode(), taskRelation.getPostTaskVersion()); if (switchResult != Constants.EXIT_CODE_FAILURE) { result++; } } return result; } } @Override public int switchTaskDefinitionVersion(long taskCode, int taskVersion) { TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); if (taskDefinition == null) { return Constants.EXIT_CODE_FAILURE; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
if (taskDefinition.getVersion() == taskVersion) { return Constants.EXIT_CODE_SUCCESS; } TaskDefinitionLog taskDefinitionUpdate = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, taskVersion); if (taskDefinitionUpdate == null) { return Constants.EXIT_CODE_FAILURE; } taskDefinitionUpdate.setUpdateTime(new Date()); taskDefinitionUpdate.setId(taskDefinition.getId()); return taskDefinitionMapper.updateById(taskDefinitionUpdate); } /** * get resource ids * * @param taskDefinition taskDefinition * @return resource ids */ @Override public String getResourceIds(TaskDefinition taskDefinition) { Set<Integer> resourceIds = null; AbstractParameters params = taskPluginManager.getParameters(ParametersNode.builder() .taskType(taskDefinition.getTaskType()).taskParams(taskDefinition.getTaskParams()).build()); if (params != null && CollectionUtils.isNotEmpty(params.getResourceFilesList())) { resourceIds = params.getResourceFilesList().stream() .filter(t -> t.getId() != null) .map(ResourceInfo::getId) .collect(toSet()); } if (CollectionUtils.isEmpty(resourceIds)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
return ""; } return Joiner.on(",").join(resourceIds); } @Override public int saveTaskDefine(User operator, long projectCode, List<TaskDefinitionLog> taskDefinitionLogs, Boolean syncDefine) { Date now = new Date(); List<TaskDefinitionLog> newTaskDefinitionLogs = new ArrayList<>(); List<TaskDefinitionLog> updateTaskDefinitionLogs = new ArrayList<>(); for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { taskDefinitionLog.setProjectCode(projectCode); taskDefinitionLog.setUpdateTime(now); taskDefinitionLog.setOperateTime(now); taskDefinitionLog.setOperator(operator.getId()); taskDefinitionLog.setResourceIds(getResourceIds(taskDefinitionLog)); if (taskDefinitionLog.getCode() == 0) { taskDefinitionLog.setCode(CodeGenerateUtils.getInstance().genCode()); } if (taskDefinitionLog.getVersion() == 0) { taskDefinitionLog.setVersion(Constants.VERSION_FIRST); } TaskDefinitionLog definitionCodeAndVersion = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion( taskDefinitionLog.getCode(), taskDefinitionLog.getVersion()); if (definitionCodeAndVersion == null) { taskDefinitionLog.setUserId(operator.getId()); taskDefinitionLog.setCreateTime(now); newTaskDefinitionLogs.add(taskDefinitionLog); continue;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
} if (taskDefinitionLog.equals(definitionCodeAndVersion)) { continue; } taskDefinitionLog.setUserId(definitionCodeAndVersion.getUserId()); Integer version = taskDefinitionLogMapper.queryMaxVersionForDefinition(taskDefinitionLog.getCode()); taskDefinitionLog.setVersion(version + 1); taskDefinitionLog.setCreateTime(definitionCodeAndVersion.getCreateTime()); updateTaskDefinitionLogs.add(taskDefinitionLog); } if (CollectionUtils.isNotEmpty(updateTaskDefinitionLogs)) { List<Long> taskDefinitionCodes = updateTaskDefinitionLogs .stream() .map(TaskDefinition::getCode) .distinct() .collect(Collectors.toList()); Map<Long, TaskDefinition> taskDefinitionMap = taskDefinitionMapper.queryByCodeList(taskDefinitionCodes) .stream() .collect(Collectors.toMap(TaskDefinition::getCode, Function.identity())); for (TaskDefinitionLog taskDefinitionToUpdate : updateTaskDefinitionLogs) { TaskDefinition task = taskDefinitionMap.get(taskDefinitionToUpdate.getCode()); if (task == null) { newTaskDefinitionLogs.add(taskDefinitionToUpdate); } } } int updateResult = 0;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
int insertResult = 0; if (CollectionUtils.isNotEmpty(newTaskDefinitionLogs)) { insertResult += taskDefinitionLogMapper.batchInsert(newTaskDefinitionLogs); } if (CollectionUtils.isNotEmpty(updateTaskDefinitionLogs)) { insertResult += taskDefinitionLogMapper.batchInsert(updateTaskDefinitionLogs); } if (CollectionUtils.isNotEmpty(newTaskDefinitionLogs) && Boolean.TRUE.equals(syncDefine)) { updateResult += taskDefinitionMapper.batchInsert(newTaskDefinitionLogs); } if (CollectionUtils.isNotEmpty(updateTaskDefinitionLogs) && Boolean.TRUE.equals(syncDefine)) { for (TaskDefinitionLog taskDefinitionLog : updateTaskDefinitionLogs) { updateResult += taskDefinitionMapper.updateById(taskDefinitionLog); } } return (insertResult & updateResult) > 0 ? 1 : Constants.EXIT_CODE_SUCCESS; } /** * save processDefinition (including create or update processDefinition) */ @Override public int saveProcessDefine(User operator, ProcessDefinition processDefinition, Boolean syncDefine, Boolean isFromProcessDefine) { ProcessDefinitionLog processDefinitionLog = new ProcessDefinitionLog(processDefinition); Integer version = processDefineLogMapper.queryMaxVersionForDefinition(processDefinition.getCode()); int insertVersion = version == null || version == 0 ? Constants.VERSION_FIRST : version + 1; processDefinitionLog.setVersion(insertVersion); processDefinitionLog .setReleaseState(!isFromProcessDefine || processDefinitionLog.getReleaseState() == ReleaseState.ONLINE ? ReleaseState.ONLINE
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
: ReleaseState.OFFLINE); processDefinitionLog.setOperator(operator.getId()); processDefinitionLog.setOperateTime(processDefinition.getUpdateTime()); processDefinitionLog.setId(null); int insertLog = processDefineLogMapper.insert(processDefinitionLog); int result = 1; if (Boolean.TRUE.equals(syncDefine)) { if (processDefinition.getId() == null) { result = processDefineMapper.insert(processDefinitionLog); } else { processDefinitionLog.setId(processDefinition.getId()); result = processDefineMapper.updateById(processDefinitionLog); } } return (insertLog & result) > 0 ? insertVersion : 0; } /** * save task relations */ @Override public int saveTaskRelation(User operator, long projectCode, long processDefinitionCode, int processDefinitionVersion, List<ProcessTaskRelationLog> taskRelationList, List<TaskDefinitionLog> taskDefinitionLogs, Boolean syncDefine) { if (taskRelationList.isEmpty()) { return Constants.EXIT_CODE_SUCCESS; } Map<Long, TaskDefinitionLog> taskDefinitionLogMap = null; if (CollectionUtils.isNotEmpty(taskDefinitionLogs)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
taskDefinitionLogMap = taskDefinitionLogs .stream() .collect(Collectors.toMap(TaskDefinition::getCode, taskDefinitionLog -> taskDefinitionLog)); } Date now = new Date(); for (ProcessTaskRelationLog processTaskRelationLog : taskRelationList) { processTaskRelationLog.setProjectCode(projectCode); processTaskRelationLog.setProcessDefinitionCode(processDefinitionCode); processTaskRelationLog.setProcessDefinitionVersion(processDefinitionVersion); if (taskDefinitionLogMap != null) { TaskDefinitionLog preTaskDefinitionLog = taskDefinitionLogMap.get(processTaskRelationLog.getPreTaskCode()); if (preTaskDefinitionLog != null) { processTaskRelationLog.setPreTaskVersion(preTaskDefinitionLog.getVersion()); } TaskDefinitionLog postTaskDefinitionLog = taskDefinitionLogMap.get(processTaskRelationLog.getPostTaskCode()); if (postTaskDefinitionLog != null) { processTaskRelationLog.setPostTaskVersion(postTaskDefinitionLog.getVersion()); } } processTaskRelationLog.setCreateTime(now); processTaskRelationLog.setUpdateTime(now); processTaskRelationLog.setOperator(operator.getId()); processTaskRelationLog.setOperateTime(now); } int insert = taskRelationList.size(); if (Boolean.TRUE.equals(syncDefine)) { List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
if (!processTaskRelationList.isEmpty()) { Set<Integer> processTaskRelationSet = processTaskRelationList.stream().map(ProcessTaskRelation::hashCode).collect(toSet()); Set<Integer> taskRelationSet = taskRelationList.stream().map(ProcessTaskRelationLog::hashCode).collect(toSet()); boolean result = CollectionUtils.isEqualCollection(processTaskRelationSet, taskRelationSet); if (result) { return Constants.EXIT_CODE_SUCCESS; } processTaskRelationMapper.deleteByCode(projectCode, processDefinitionCode); } List<ProcessTaskRelation> processTaskRelations = taskRelationList.stream().map(ProcessTaskRelation::new).collect(Collectors.toList()); insert = processTaskRelationMapper.batchInsert(processTaskRelations); } int resultLog = processTaskRelationLogMapper.batchInsert(taskRelationList); return (insert & resultLog) > 0 ? Constants.EXIT_CODE_SUCCESS : Constants.EXIT_CODE_FAILURE; } @Override public boolean isTaskOnline(long taskCode) { List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByTaskCode(taskCode); if (!processTaskRelationList.isEmpty()) { Set<Long> processDefinitionCodes = processTaskRelationList .stream() .map(ProcessTaskRelation::getProcessDefinitionCode) .collect(toSet()); List<ProcessDefinition> processDefinitionList = processDefineMapper.queryByCodes(processDefinitionCodes); for (ProcessDefinition processDefinition : processDefinitionList) { if (processDefinition.getReleaseState() == ReleaseState.ONLINE) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
return true; } } } return false; } /** * Generate the DAG Graph based on the process definition id * Use temporarily before refactoring taskNode * * @param processDefinition process definition * @return dag graph */ @Override public DAG<String, TaskNode, TaskNodeRelation> genDagGraph(ProcessDefinition processDefinition) { List<ProcessTaskRelation> taskRelations = this.findRelationByCode(processDefinition.getCode(), processDefinition.getVersion()); List<TaskNode> taskNodeList = transformTask(taskRelations, Lists.newArrayList()); ProcessDag processDag = DagHelper.getProcessDag(taskNodeList, new ArrayList<>(taskRelations)); return DagHelper.buildDagGraph(processDag); } /** * generate DagData */ @Override public DagData genDagData(ProcessDefinition processDefinition) { List<ProcessTaskRelation> taskRelations = this.findRelationByCode(processDefinition.getCode(), processDefinition.getVersion()); List<TaskDefinitionLog> taskDefinitionLogList = genTaskDefineList(taskRelations);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
List<TaskDefinition> taskDefinitions = taskDefinitionLogList.stream().map(t -> (TaskDefinition) t).collect(Collectors.toList()); return new DagData(processDefinition, taskRelations, taskDefinitions); } @Override public List<TaskDefinitionLog> genTaskDefineList(List<ProcessTaskRelation> processTaskRelations) { Set<TaskDefinition> taskDefinitionSet = new HashSet<>(); for (ProcessTaskRelation processTaskRelation : processTaskRelations) { if (processTaskRelation.getPreTaskCode() > 0) { taskDefinitionSet.add(new TaskDefinition(processTaskRelation.getPreTaskCode(), processTaskRelation.getPreTaskVersion())); } if (processTaskRelation.getPostTaskCode() > 0) { taskDefinitionSet.add(new TaskDefinition(processTaskRelation.getPostTaskCode(), processTaskRelation.getPostTaskVersion())); } } if (taskDefinitionSet.isEmpty()) { return Lists.newArrayList(); } return taskDefinitionLogMapper.queryByTaskDefinitions(taskDefinitionSet); } @Override public List<TaskDefinitionLog> getTaskDefineLogListByRelation(List<ProcessTaskRelation> processTaskRelations) { List<TaskDefinitionLog> taskDefinitionLogs = new ArrayList<>(); Map<Long, Integer> taskCodeVersionMap = new HashMap<>(); for (ProcessTaskRelation processTaskRelation : processTaskRelations) { if (processTaskRelation.getPreTaskCode() > 0) { taskCodeVersionMap.put(processTaskRelation.getPreTaskCode(), processTaskRelation.getPreTaskVersion()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
if (processTaskRelation.getPostTaskCode() > 0) { taskCodeVersionMap.put(processTaskRelation.getPostTaskCode(), processTaskRelation.getPostTaskVersion()); } } taskCodeVersionMap.forEach((code, version) -> { taskDefinitionLogs.add((TaskDefinitionLog) this.findTaskDefinition(code, version)); }); return taskDefinitionLogs; } /** * find task definition by code and version */ @Override public TaskDefinition findTaskDefinition(long taskCode, int taskDefinitionVersion) { return taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, taskDefinitionVersion); } /** * find process task relation list by process */ @Override public List<ProcessTaskRelation> findRelationByCode(long processDefinitionCode, int processDefinitionVersion) { List<ProcessTaskRelationLog> processTaskRelationLogList = processTaskRelationLogMapper .queryByProcessCodeAndVersion(processDefinitionCode, processDefinitionVersion); return processTaskRelationLogList.stream().map(r -> (ProcessTaskRelation) r).collect(Collectors.toList()); } /** * add authorized resources * * @param ownResources own resources * @param userId userId
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
*/ private void addAuthorizedResources(List<Resource> ownResources, int userId) { List<Integer> relationResourceIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, 7); List<Resource> relationResources = CollectionUtils.isNotEmpty(relationResourceIds) ? resourceMapper.queryResourceListById(relationResourceIds) : new ArrayList<>(); ownResources.addAll(relationResources); } /** * Use temporarily before refactoring taskNode */ @Override public List<TaskNode> transformTask(List<ProcessTaskRelation> taskRelationList, List<TaskDefinitionLog> taskDefinitionLogs) { Map<Long, List<Long>> taskCodeMap = new HashMap<>(); for (ProcessTaskRelation processTaskRelation : taskRelationList) { taskCodeMap.compute(processTaskRelation.getPostTaskCode(), (k, v) -> { if (v == null) { v = new ArrayList<>(); } if (processTaskRelation.getPreTaskCode() != 0L) { v.add(processTaskRelation.getPreTaskCode()); } return v; }); } if (CollectionUtils.isEmpty(taskDefinitionLogs)) { taskDefinitionLogs = genTaskDefineList(taskRelationList); } Map<Long, TaskDefinitionLog> taskDefinitionLogMap = taskDefinitionLogs.stream()
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
.collect(Collectors.toMap(TaskDefinitionLog::getCode, taskDefinitionLog -> taskDefinitionLog)); List<TaskNode> taskNodeList = new ArrayList<>(); for (Entry<Long, List<Long>> code : taskCodeMap.entrySet()) { TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMap.get(code.getKey()); if (taskDefinitionLog != null) { TaskNode taskNode = new TaskNode(); taskNode.setCode(taskDefinitionLog.getCode()); taskNode.setVersion(taskDefinitionLog.getVersion()); taskNode.setName(taskDefinitionLog.getName()); taskNode.setDesc(taskDefinitionLog.getDescription()); taskNode.setType(taskDefinitionLog.getTaskType().toUpperCase()); taskNode.setRunFlag(taskDefinitionLog.getFlag() == Flag.YES ? Constants.FLOWNODE_RUN_FLAG_NORMAL : Constants.FLOWNODE_RUN_FLAG_FORBIDDEN); taskNode.setMaxRetryTimes(taskDefinitionLog.getFailRetryTimes()); taskNode.setRetryInterval(taskDefinitionLog.getFailRetryInterval()); Map<String, Object> taskParamsMap = taskNode.taskParamsToJsonObj(taskDefinitionLog.getTaskParams()); taskNode.setConditionResult(JSONUtils.toJsonString(taskParamsMap.get(Constants.CONDITION_RESULT))); taskNode.setSwitchResult(JSONUtils.toJsonString(taskParamsMap.get(Constants.SWITCH_RESULT))); taskNode.setDependence(JSONUtils.toJsonString(taskParamsMap.get(Constants.DEPENDENCE))); taskParamsMap.remove(Constants.CONDITION_RESULT); taskParamsMap.remove(Constants.DEPENDENCE); taskNode.setParams(JSONUtils.toJsonString(taskParamsMap)); taskNode.setTaskInstancePriority(taskDefinitionLog.getTaskPriority()); taskNode.setWorkerGroup(taskDefinitionLog.getWorkerGroup()); taskNode.setEnvironmentCode(taskDefinitionLog.getEnvironmentCode()); taskNode.setTimeout(JSONUtils .toJsonString(new TaskTimeoutParameter(taskDefinitionLog.getTimeoutFlag() == TimeoutFlag.OPEN, taskDefinitionLog.getTimeoutNotifyStrategy(), taskDefinitionLog.getTimeout()))); taskNode.setDelayTime(taskDefinitionLog.getDelayTime());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
taskNode.setPreTasks(JSONUtils.toJsonString(code.getValue().stream().map(taskDefinitionLogMap::get) .map(TaskDefinition::getCode).collect(Collectors.toList()))); taskNode.setTaskGroupId(taskDefinitionLog.getTaskGroupId()); taskNode.setTaskGroupPriority(taskDefinitionLog.getTaskGroupPriority()); taskNode.setCpuQuota(taskDefinitionLog.getCpuQuota()); taskNode.setMemoryMax(taskDefinitionLog.getMemoryMax()); taskNode.setTaskExecuteType(taskDefinitionLog.getTaskExecuteType()); taskNodeList.add(taskNode); } } return taskNodeList; } @Override public Map<ProcessInstance, TaskInstance> notifyProcessList(int processId) { HashMap<ProcessInstance, TaskInstance> processTaskMap = new HashMap<>(); ProcessInstanceMap processInstanceMap = processInstanceMapMapper.queryBySubProcessId(processId); if (processInstanceMap == null) { return processTaskMap; } ProcessInstance fatherProcess = this.findProcessInstanceById(processInstanceMap.getParentProcessInstanceId()); TaskInstance fatherTask = this.findTaskInstanceById(processInstanceMap.getParentTaskInstanceId()); if (fatherProcess != null) { processTaskMap.put(fatherProcess, fatherTask); } return processTaskMap; } @Override public DqExecuteResult getDqExecuteResultByTaskInstanceId(int taskInstanceId) { return dqExecuteResultMapper.getExecuteResultById(taskInstanceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
} @Override public int updateDqExecuteResultUserId(int taskInstanceId) { DqExecuteResult dqExecuteResult = dqExecuteResultMapper .selectOne(new QueryWrapper<DqExecuteResult>().eq(TASK_INSTANCE_ID, taskInstanceId)); if (dqExecuteResult == null) { return -1; } ProcessInstance processInstance = processInstanceMapper.selectById(dqExecuteResult.getProcessInstanceId()); if (processInstance == null) { return -1; } ProcessDefinition processDefinition = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); if (processDefinition == null) { return -1; } dqExecuteResult.setProcessDefinitionId(processDefinition.getId()); dqExecuteResult.setUserId(processDefinition.getUserId()); dqExecuteResult.setState(DqTaskState.DEFAULT.getCode()); return dqExecuteResultMapper.updateById(dqExecuteResult); } @Override public int updateDqExecuteResultState(DqExecuteResult dqExecuteResult) { return dqExecuteResultMapper.updateById(dqExecuteResult); } @Override public int deleteDqExecuteResultByTaskInstanceId(int taskInstanceId) { return dqExecuteResultMapper.delete(
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
new QueryWrapper<DqExecuteResult>() .eq(TASK_INSTANCE_ID, taskInstanceId)); } @Override public int deleteTaskStatisticsValueByTaskInstanceId(int taskInstanceId) { return dqTaskStatisticsValueMapper.delete( new QueryWrapper<DqTaskStatisticsValue>() .eq(TASK_INSTANCE_ID, taskInstanceId)); } @Override public DqRule getDqRule(int ruleId) { return dqRuleMapper.selectById(ruleId); } @Override public List<DqRuleInputEntry> getRuleInputEntry(int ruleId) { return DqRuleUtils.transformInputEntry(dqRuleInputEntryMapper.getRuleInputEntryList(ruleId)); } @Override public List<DqRuleExecuteSql> getDqExecuteSql(int ruleId) { return dqRuleExecuteSqlMapper.getExecuteSqlList(ruleId); } @Override public DqComparisonType getComparisonTypeById(int id) { return dqComparisonTypeMapper.selectById(id); } /** * the first time (when submit the task ) get the resource of the task group * * @param taskId task id */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
@Override public boolean acquireTaskGroup(int taskId, String taskName, int groupId, int processId, int priority) { TaskGroup taskGroup = taskGroupMapper.selectById(groupId); if (taskGroup == null) { return true; } if (taskGroup.getStatus() == Flag.NO.getCode()) { return true; } TaskGroupQueue taskGroupQueue = this.taskGroupQueueMapper.queryByTaskId(taskId); if (taskGroupQueue == null) { taskGroupQueue = insertIntoTaskGroupQueue(taskId, taskName, groupId, processId, priority, TaskGroupQueueStatus.WAIT_QUEUE); } else { logger.info("The task queue is already exist, taskId: {}", taskId); if (taskGroupQueue.getStatus() == TaskGroupQueueStatus.ACQUIRE_SUCCESS) { return true; } taskGroupQueue.setInQueue(Flag.NO.getCode()); taskGroupQueue.setStatus(TaskGroupQueueStatus.WAIT_QUEUE); this.taskGroupQueueMapper.updateById(taskGroupQueue); } List<TaskGroupQueue> highPriorityTasks = taskGroupQueueMapper.queryHighPriorityTasks(groupId, priority, TaskGroupQueueStatus.WAIT_QUEUE.getCode()); if (CollectionUtils.isNotEmpty(highPriorityTasks)) { return false;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
} int count = taskGroupMapper.selectAvailableCountById(groupId); if (count == 1 && robTaskGroupResource(taskGroupQueue)) { logger.info("Success acquire taskGroup, taskInstanceId: {}, taskGroupId: {}", taskId, groupId); return true; } logger.info("Failed to acquire taskGroup, taskInstanceId: {}, taskGroupId: {}", taskId, groupId); this.taskGroupQueueMapper.updateInQueue(Flag.NO.getCode(), taskGroupQueue.getId()); return false; } /** * try to get the task group resource(when other task release the resource) */ @Override public boolean robTaskGroupResource(TaskGroupQueue taskGroupQueue) { TaskGroup taskGroup = taskGroupMapper.selectById(taskGroupQueue.getGroupId()); int affectedCount = taskGroupMapper.updateTaskGroupResource(taskGroup.getId(), taskGroupQueue.getId(), TaskGroupQueueStatus.WAIT_QUEUE.getCode()); if (affectedCount > 0) { logger.info("Success rob taskGroup, taskInstanceId: {}, taskGroupId: {}", taskGroupQueue.getTaskId(), taskGroupQueue.getId()); taskGroupQueue.setStatus(TaskGroupQueueStatus.ACQUIRE_SUCCESS); this.taskGroupQueueMapper.updateById(taskGroupQueue); this.taskGroupQueueMapper.updateInQueue(Flag.NO.getCode(), taskGroupQueue.getId()); return true; } logger.info("Failed to rob taskGroup, taskInstanceId: {}, taskGroupId: {}", taskGroupQueue.getTaskId(), taskGroupQueue.getId());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
return false; } @Override public void releaseAllTaskGroup(int processInstanceId) { List<TaskInstance> taskInstances = this.taskInstanceMapper.loadAllInfosNoRelease(processInstanceId, TaskGroupQueueStatus.ACQUIRE_SUCCESS.getCode()); for (TaskInstance info : taskInstances) { releaseTaskGroup(info); } } /** * release the TGQ resource when the corresponding task is finished. * * @return the result code and msg */ @Override public TaskInstance releaseTaskGroup(TaskInstance taskInstance) { TaskGroup taskGroup; TaskGroupQueue thisTaskGroupQueue; logger.info("Begin to release task group: {}", taskInstance.getTaskGroupId()); try { do { taskGroup = taskGroupMapper.selectById(taskInstance.getTaskGroupId()); if (taskGroup == null) { logger.error("The taskGroup is null, taskGroupId: {}", taskInstance.getTaskGroupId()); return null; } thisTaskGroupQueue = this.taskGroupQueueMapper.queryByTaskId(taskInstance.getId()); if (thisTaskGroupQueue.getStatus() == TaskGroupQueueStatus.RELEASE) { logger.info("The taskGroupQueue's status is release, taskInstanceId: {}", taskInstance.getId());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
return null; } } while (thisTaskGroupQueue.getForceStart() == Flag.NO.getCode() && taskGroupMapper.releaseTaskGroupResource(taskGroup.getId(), taskGroup.getUseSize(), thisTaskGroupQueue.getId(), TaskGroupQueueStatus.ACQUIRE_SUCCESS.getCode()) != 1); } catch (Exception e) { logger.error("release the task group error", e); return null; } logger.info("Finished to release task group, taskGroupId: {}", taskInstance.getTaskGroupId()); logger.info("Begin to release task group queue, taskGroupId: {}", taskInstance.getTaskGroupId()); changeTaskGroupQueueStatus(taskInstance.getId(), TaskGroupQueueStatus.RELEASE); TaskGroupQueue taskGroupQueue; do { taskGroupQueue = this.taskGroupQueueMapper.queryTheHighestPriorityTasks(taskGroup.getId(), TaskGroupQueueStatus.WAIT_QUEUE.getCode(), Flag.NO.getCode(), Flag.NO.getCode()); if (taskGroupQueue == null) { logger.info("The taskGroupQueue is null, taskGroup: {}", taskGroup.getId()); return null; } } while (this.taskGroupQueueMapper.updateInQueueCAS(Flag.NO.getCode(), Flag.YES.getCode(), taskGroupQueue.getId()) != 1); logger.info("Finished to release task group queue: taskGroupId: {}", taskInstance.getTaskGroupId()); return this.taskInstanceMapper.selectById(taskGroupQueue.getTaskId()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
/** * release the TGQ resource when the corresponding task is finished. * * @param taskId task id * @return the result code and msg */ @Override public void changeTaskGroupQueueStatus(int taskId, TaskGroupQueueStatus status) { TaskGroupQueue taskGroupQueue = taskGroupQueueMapper.queryByTaskId(taskId); taskGroupQueue.setStatus(status); taskGroupQueue.setUpdateTime(new Date(System.currentTimeMillis())); taskGroupQueueMapper.updateById(taskGroupQueue); } /** * insert into task group queue * * @param taskId task id * @param taskName task name * @param groupId group id * @param processId process id * @param priority priority * @return inserted task group queue */ @Override public TaskGroupQueue insertIntoTaskGroupQueue(Integer taskId, String taskName, Integer groupId, Integer processId, Integer priority, TaskGroupQueueStatus status) { TaskGroupQueue taskGroupQueue = new TaskGroupQueue(taskId, taskName, groupId, processId, priority, status); taskGroupQueue.setCreateTime(new Date()); taskGroupQueue.setUpdateTime(new Date());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
taskGroupQueueMapper.insert(taskGroupQueue); return taskGroupQueue; } @Override public int updateTaskGroupQueueStatus(Integer taskId, int status) { return taskGroupQueueMapper.updateStatusByTaskId(taskId, status); } @Override public int updateTaskGroupQueue(TaskGroupQueue taskGroupQueue) { return taskGroupQueueMapper.updateById(taskGroupQueue); } @Override public TaskGroupQueue loadTaskGroupQueue(int taskId) { return this.taskGroupQueueMapper.queryByTaskId(taskId); } @Override public void sendStartTask2Master(ProcessInstance processInstance, int taskId, org.apache.dolphinscheduler.remote.command.CommandType taskType) { TaskEventChangeCommand taskEventChangeCommand = new TaskEventChangeCommand( processInstance.getId(), taskId); Host host = new Host(processInstance.getHost()); stateEventCallbackService.sendResult(host, taskEventChangeCommand.convert2Command(taskType)); } @Override public ProcessInstance loadNextProcess4Serial(long code, int state, int id) { return this.processInstanceMapper.loadNextProcess4Serial(code, state, id); } protected void deleteCommandWithCheck(int commandId) { int delete = this.commandMapper.deleteById(commandId); if (delete != 1) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
throw new ServiceException("delete command fail, id:" + commandId); } } /** * find k8s config yaml by clusterName * * @param clusterName clusterName * @return datasource */ @Override public String findConfigYamlByName(String clusterName) { if (Strings.isNullOrEmpty(clusterName)) { return null; } QueryWrapper<Cluster> nodeWrapper = new QueryWrapper<>(); nodeWrapper.eq("name", clusterName); Cluster cluster = clusterMapper.selectOne(nodeWrapper); return cluster == null ? null : cluster.getConfig(); } @Override public void forceProcessInstanceSuccessByTaskInstanceId(Integer taskInstanceId) { TaskInstance task = taskInstanceMapper.selectById(taskInstanceId); if (task == null) { return; } ProcessInstance processInstance = findProcessInstanceDetailById(task.getProcessInstanceId()).orElse(null); if (processInstance != null && (processInstance.getState().isFailure() || processInstance.getState().isStop())) { List<TaskInstance> validTaskList = findValidTaskListByProcessId(processInstance.getId(), processInstance.getTestFlag());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,451
[Bug] [k8s] Read the incorrect kubeconfig
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Read the incorrect kubeconfig from `cluster.getConfig()` And if the kubeconfig content is wrong, `DefaultKubernetesClient(config)` will automatically reade the kubeconfig from `~/.kube/config` instead. ### What you expected to happen Read the correct kubeconfig ### How to reproduce see the code ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12451
https://github.com/apache/dolphinscheduler/pull/12452
fdac75137969d3e656e1aa898f7431f9657de50b
233bbdb09ebb6756a8b8578d4da7ec51820b2873
2022-10-19T15:28:50Z
java
2022-10-25T03:25:30Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
List<Long> instanceTaskCodeList = validTaskList.stream().map(TaskInstance::getTaskCode).collect(Collectors.toList()); List<ProcessTaskRelation> taskRelations = findRelationByCode(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); List<TaskDefinitionLog> taskDefinitionLogs = genTaskDefineList(taskRelations); List<Long> definiteTaskCodeList = taskDefinitionLogs.stream().filter(definitionLog -> definitionLog.getFlag() == Flag.YES) .map(TaskDefinitionLog::getCode).collect(Collectors.toList()); if (CollectionUtils.isEqualCollection(instanceTaskCodeList, definiteTaskCodeList)) { List<Integer> failTaskList = validTaskList.stream() .filter(instance -> instance.getState().isFailure() || instance.getState().isKill()) .map(TaskInstance::getId).collect(Collectors.toList()); if (failTaskList.size() == 1 && failTaskList.contains(taskInstanceId)) { processInstance.setStateWithDesc(WorkflowExecutionStatus.SUCCESS, "success by task force success"); processInstanceDao.updateProcessInstance(processInstance); } } } } @Override public Integer queryTestDataSourceId(Integer onlineDataSourceId) { Integer testDataSourceId = dataSourceMapper.queryTestDataSourceId(onlineDataSourceId); if (testDataSourceId != null) return testDataSourceId; return null; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannel.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.plugin.alert.script; import org.apache.dolphinscheduler.alert.api.AlertChannel; import org.apache.dolphinscheduler.alert.api.AlertData; import org.apache.dolphinscheduler.alert.api.AlertInfo; import org.apache.dolphinscheduler.alert.api.AlertResult; import java.util.Map; public final class ScriptAlertChannel implements AlertChannel {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannel.java
@Override public AlertResult process(AlertInfo alertinfo) { AlertData alertData = alertinfo.getAlertData(); Map<String, String> paramsMap = alertinfo.getAlertParams(); if (null == paramsMap) { return new AlertResult("false", "script params is null"); } return new ScriptSender(paramsMap).sendScriptAlert(alertData.getTitle(), alertData.getContent()); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptSender.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.plugin.alert.script; import org.apache.dolphinscheduler.alert.api.AlertResult; import java.io.File; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public final class ScriptSender {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptSender.java
private static final Logger logger = LoggerFactory.getLogger(ScriptSender.class); private static final String ALERT_TITLE_OPTION = " -t "; private static final String ALERT_CONTENT_OPTION = " -c "; private static final String ALERT_USER_PARAMS_OPTION = " -p "; private final String scriptPath; private final String scriptType; private final String userParams; ScriptSender(Map<String, String> config) { scriptPath = config.get(ScriptParamsConstants.NAME_SCRIPT_PATH); scriptType = config.get(ScriptParamsConstants.NAME_SCRIPT_TYPE);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptSender.java
userParams = config.get(ScriptParamsConstants.NAME_SCRIPT_USER_PARAMS); } AlertResult sendScriptAlert(String title, String content) { AlertResult alertResult = new AlertResult(); if (ScriptType.SHELL.getDescp().equals(scriptType)) { return executeShellScript(title, content); } return alertResult; } private AlertResult executeShellScript(String title, String content) { AlertResult alertResult = new AlertResult(); alertResult.setStatus("false"); if (Boolean.TRUE.equals(OSUtils.isWindows())) { alertResult.setMessage("shell script not support windows os"); return alertResult; } File shellScriptFile = new File(scriptPath); if (!shellScriptFile.exists()) { logger.error("shell script not exist : {}", scriptPath); alertResult.setMessage("shell script not exist : " + scriptPath); return alertResult; } if (!shellScriptFile.isFile()) { logger.error("shell script is not a file : {}", scriptPath); alertResult.setMessage("shell script is not a file : " + scriptPath); return alertResult; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptSender.java
if (userParams.contains("'")) { logger.error("shell script illegal user params : {}", userParams); alertResult.setMessage("shell script illegal user params : " + userParams); return alertResult; } if (title.contains("'")) { logger.error("shell script illegal title : {}", title); alertResult.setMessage("shell script illegal title : " + title); return alertResult; } if (content.contains("'")) { logger.error("shell script illegal content : {}", content); alertResult.setMessage("shell script illegal content : " + content); return alertResult; } String[] cmd = {"/bin/sh", "-c", scriptPath + ALERT_TITLE_OPTION + "'" + title + "'" + ALERT_CONTENT_OPTION + "'" + content + "'" + ALERT_USER_PARAMS_OPTION + "'" + userParams + "'"}; int exitCode = ProcessUtils.executeScript(cmd); if (exitCode == 0) { alertResult.setStatus("true"); alertResult.setMessage("send script alert msg success"); return alertResult; } alertResult.setMessage("send script alert msg error,exitCode is " + exitCode); logger.info("send script alert msg error,exitCode is {}", exitCode); return alertResult; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/test/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptSenderTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.plugin.alert.script; import org.apache.dolphinscheduler.alert.api.AlertResult; import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; /** * ScriptSenderTest */ public class ScriptSenderTest {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/test/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptSenderTest.java
private static final String rootPath = System.getProperty("user.dir"); private static final String shellFilPath = rootPath + "/src/test/script/shell/scriptExample.sh"; private static Map<String, String> scriptConfig = new HashMap<>(); @BeforeEach public void initScriptConfig() { scriptConfig.put(ScriptParamsConstants.NAME_SCRIPT_TYPE, String.valueOf(ScriptType.SHELL.getDescp())); scriptConfig.put(ScriptParamsConstants.NAME_SCRIPT_USER_PARAMS, "userParams"); scriptConfig.put(ScriptParamsConstants.NAME_SCRIPT_PATH, shellFilPath); } @Test public void testScriptSenderTest() { ScriptSender scriptSender = new ScriptSender(scriptConfig); AlertResult alertResult; alertResult = scriptSender.sendScriptAlert("test title Kris", "test content"); Assertions.assertEquals("true", alertResult.getStatus()); alertResult = scriptSender.sendScriptAlert("error msg title", "test content"); Assertions.assertEquals("false", alertResult.getStatus()); } @Test public void testScriptSenderInjectionTest() { scriptConfig.put(ScriptParamsConstants.NAME_SCRIPT_USER_PARAMS, "' ; calc.exe ; '"); ScriptSender scriptSender = new ScriptSender(scriptConfig); AlertResult alertResult = scriptSender.sendScriptAlert("test title Kris", "test content"); Assertions.assertEquals("false", alertResult.getStatus()); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.alert; import org.apache.dolphinscheduler.alert.api.AlertChannel; import org.apache.dolphinscheduler.alert.api.AlertConstants;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
import org.apache.dolphinscheduler.alert.api.AlertData; import org.apache.dolphinscheduler.alert.api.AlertInfo; import org.apache.dolphinscheduler.alert.api.AlertResult; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.AlertStatus; import org.apache.dolphinscheduler.common.enums.AlertType; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager; import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.AlertDao; import org.apache.dolphinscheduler.dao.entity.Alert; import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; import org.apache.dolphinscheduler.dao.entity.AlertSendStatus; import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseCommand; import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseResult; import org.apache.commons.collections.CollectionUtils; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import com.google.common.collect.Lists; @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
public final class AlertSenderService extends Thread { private static final Logger logger = LoggerFactory.getLogger(AlertSenderService.class); private final AlertDao alertDao; private final AlertPluginManager alertPluginManager; private final AlertConfig alertConfig; public AlertSenderService(AlertDao alertDao, AlertPluginManager alertPluginManager, AlertConfig alertConfig) { this.alertDao = alertDao; this.alertPluginManager = alertPluginManager; this.alertConfig = alertConfig; } @Override public synchronized void start() { super.setName("AlertSenderService");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
super.start(); } @Override public void run() { logger.info("Alert sender thread started"); while (!ServerLifeCycleManager.isStopped()) { try { List<Alert> alerts = alertDao.listPendingAlerts(); if (CollectionUtils.isEmpty(alerts)) { logger.debug("There is not waiting alerts"); continue; } AlertServerMetrics.registerPendingAlertGauge(alerts::size); this.send(alerts); } catch (Exception e) { logger.error("Alert sender thread meet an exception", e); } finally { ThreadUtils.sleep(Constants.SLEEP_TIME_MILLIS * 5L); } } logger.info("Alert sender thread stopped"); } public void send(List<Alert> alerts) { for (Alert alert : alerts) { int alertId = alert.getId(); int alertGroupId = Optional.ofNullable(alert.getAlertGroupId()).orElse(0); List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId); if (CollectionUtils.isEmpty(alertInstanceList)) { logger.error("send alert msg fail,no bind plugin instance.");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
List<AlertResult> alertResults = Lists.newArrayList(new AlertResult("false", "no bind plugin instance")); alertDao.updateAlert(AlertStatus.EXECUTION_FAILURE, JSONUtils.toJsonString(alertResults), alertId); continue; } AlertData alertData = AlertData.builder() .id(alertId) .content(alert.getContent()) .log(alert.getLog()) .title(alert.getTitle()) .warnType(alert.getWarningType().getCode()) .alertType(alert.getAlertType().getCode()) .build(); int sendSuccessCount = 0; List<AlertSendStatus> alertSendStatuses = new ArrayList<>(); List<AlertResult> alertResults = new ArrayList<>(); for (AlertPluginInstance instance : alertInstanceList) { AlertResult alertResult = this.alertResultHandler(instance, alertData); if (alertResult != null) { AlertStatus sendStatus = Boolean.parseBoolean(alertResult.getStatus()) ? AlertStatus.EXECUTION_SUCCESS : AlertStatus.EXECUTION_FAILURE; AlertSendStatus alertSendStatus = AlertSendStatus.builder() .alertId(alertId) .alertPluginInstanceId(instance.getId()) .sendStatus(sendStatus) .log(JSONUtils.toJsonString(alertResult)) .createTime(new Date()) .build(); alertSendStatuses.add(alertSendStatus);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
if (AlertStatus.EXECUTION_SUCCESS.equals(sendStatus)) { sendSuccessCount++; AlertServerMetrics.incAlertSuccessCount(); } else { AlertServerMetrics.incAlertFailCount(); } alertResults.add(alertResult); } } AlertStatus alertStatus = AlertStatus.EXECUTION_SUCCESS; if (sendSuccessCount == 0) { alertStatus = AlertStatus.EXECUTION_FAILURE; } else if (sendSuccessCount < alertInstanceList.size()) { alertStatus = AlertStatus.EXECUTION_PARTIAL_SUCCESS; } alertDao.updateAlert(alertStatus, JSONUtils.toJsonString(alertResults), alertId); alertDao.insertAlertSendStatus(alertSendStatuses); } } /** * sync send alert handler * * @param alertGroupId alertGroupId * @param title title * @param content content * @return AlertSendResponseCommand */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
public AlertSendResponseCommand syncHandler(int alertGroupId, String title, String content, int warnType) { List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId); AlertData alertData = AlertData.builder() .content(content) .title(title) .warnType(warnType) .build(); boolean sendResponseStatus = true; List<AlertSendResponseResult> sendResponseResults = new ArrayList<>(); if (CollectionUtils.isEmpty(alertInstanceList)) { AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult(); String message = String.format("Alert GroupId %s send error : not found alert instance", alertGroupId); alertSendResponseResult.setSuccess(false); alertSendResponseResult.setMessage(message); sendResponseResults.add(alertSendResponseResult); logger.error("Alert GroupId {} send error : not found alert instance", alertGroupId); return new AlertSendResponseCommand(false, sendResponseResults); } for (AlertPluginInstance instance : alertInstanceList) { AlertResult alertResult = this.alertResultHandler(instance, alertData); if (alertResult != null) { AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult( Boolean.parseBoolean(String.valueOf(alertResult.getStatus())), alertResult.getMessage()); sendResponseStatus = sendResponseStatus && alertSendResponseResult.isSuccess(); sendResponseResults.add(alertSendResponseResult); } } return new AlertSendResponseCommand(sendResponseStatus, sendResponseResults); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
* alert result handler * * @param instance instance * @param alertData alertData * @return AlertResult */ private @Nullable AlertResult alertResultHandler(AlertPluginInstance instance, AlertData alertData) { String pluginInstanceName = instance.getInstanceName(); int pluginDefineId = instance.getPluginDefineId(); Optional<AlertChannel> alertChannelOptional = alertPluginManager.getAlertChannel(instance.getPluginDefineId()); if (!alertChannelOptional.isPresent()) { String message = String.format("Alert Plugin %s send error: the channel doesn't exist, pluginDefineId: %s", pluginInstanceName, pluginDefineId); logger.error("Alert Plugin {} send error : not found plugin {}", pluginInstanceName, pluginDefineId); return new AlertResult("false", message); } AlertChannel alertChannel = alertChannelOptional.get(); Map<String, String> paramsMap = JSONUtils.toMap(instance.getPluginInstanceParams()); String instanceWarnType = WarningType.ALL.getDescp(); if (paramsMap != null) { instanceWarnType = paramsMap.getOrDefault(AlertConstants.NAME_WARNING_TYPE, WarningType.ALL.getDescp()); } WarningType warningType = WarningType.of(instanceWarnType); if (warningType == null) { String message = String.format("Alert Plugin %s send error : plugin warnType is null", pluginInstanceName); logger.error("Alert Plugin {} send error : plugin warnType is null", pluginInstanceName); return new AlertResult("false", message); } boolean sendWarning = false;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
switch (warningType) { case ALL: sendWarning = true; break; case SUCCESS: if (alertData.getWarnType() == WarningType.SUCCESS.getCode()) { sendWarning = true; } break; case FAILURE: if (alertData.getWarnType() == WarningType.FAILURE.getCode()) { sendWarning = true; } break; default: } if (!sendWarning) { logger.info( "Alert Plugin {} send ignore warning type not match: plugin warning type is {}, alert data warning type is {}", pluginInstanceName, warningType.getCode(), alertData.getWarnType()); return null; } AlertInfo alertInfo = AlertInfo.builder() .alertData(alertData) .alertParams(paramsMap) .alertPluginInstanceId(instance.getId()) .build(); int waitTimeout = alertConfig.getWaitTimeout(); try { AlertResult alertResult;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,439
[Bug] [Alert] Send script alert NPE
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ``` [ERROR] 2022-10-19 16:41:53.938 +0800 org.apache.dolphinscheduler.alert.AlertSenderService:[272] - send alert error alert data id :48, java.lang.NullPointerException: null at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.executeShellScript(ScriptSender.java:75) at org.apache.dolphinscheduler.plugin.alert.script.ScriptSender.sendScriptAlert(ScriptSender.java:47) at org.apache.dolphinscheduler.plugin.alert.script.ScriptAlertChannel.process(ScriptAlertChannel.java:35) at org.apache.dolphinscheduler.alert.AlertSenderService.alertResultHandler(AlertSenderService.java:252) at org.apache.dolphinscheduler.alert.AlertSenderService.send(AlertSenderService.java:112) at org.apache.dolphinscheduler.alert.AlertSenderService.run(AlertSenderService.java:79) ``` ![image](https://user-images.githubusercontent.com/11962619/196652722-448814d5-6eb1-45b2-a201-f2e43e44c7ac.png) ### What you expected to happen can run script alert success. ### How to reproduce add a script alert plugin without setting user params. ![image](https://user-images.githubusercontent.com/11962619/196653015-fcf896b1-3c0d-4807-8643-6fcd73f1ef3f.png) ### Anything else _No response_ ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12439
https://github.com/apache/dolphinscheduler/pull/12495
4aa9d60683e7295dbd3dd3e66618d43610edf9b9
f5c814f23b93b69aafb4e5a4302b813c9454c5e8
2022-10-19T09:27:56Z
java
2022-10-25T07:11:54Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
if (waitTimeout <= 0) { if (alertData.getAlertType() == AlertType.CLOSE_ALERT.getCode()) { alertResult = alertChannel.closeAlert(alertInfo); } else { alertResult = alertChannel.process(alertInfo); } } else { CompletableFuture<AlertResult> future; if (alertData.getAlertType() == AlertType.CLOSE_ALERT.getCode()) { future = CompletableFuture.supplyAsync(() -> alertChannel.closeAlert(alertInfo)); } else { future = CompletableFuture.supplyAsync(() -> alertChannel.process(alertInfo)); } alertResult = future.get(waitTimeout, TimeUnit.MILLISECONDS); } if (alertResult == null) { throw new RuntimeException("Alert result cannot be null"); } return alertResult; } catch (InterruptedException e) { logger.error("send alert error alert data id :{},", alertData.getId(), e); Thread.currentThread().interrupt(); return new AlertResult("false", e.getMessage()); } catch (Exception e) { logger.error("send alert error alert data id :{},", alertData.getId(), e); return new AlertResult("false", e.getMessage()); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http:www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.service.impl; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.INSTANCE_DELETE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.INSTANCE_UPDATE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_INSTANCE; import static org.apache.dolphinscheduler.api.enums.Status.PROCESS_INSTANCE_NOT_EXIST; import static org.apache.dolphinscheduler.api.enums.Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR; import static org.apache.dolphinscheduler.common.constants.Constants.DATA_LIST; import static org.apache.dolphinscheduler.common.constants.Constants.DEPENDENT_SPLIT; import static org.apache.dolphinscheduler.common.constants.Constants.GLOBAL_PARAMS;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
import static org.apache.dolphinscheduler.common.constants.Constants.LOCAL_PARAMS; import static org.apache.dolphinscheduler.common.constants.Constants.PROCESS_INSTANCE_STATE; import static org.apache.dolphinscheduler.common.constants.Constants.TASK_LIST; import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DEPENDENT; import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SUB_PROCESS; import org.apache.dolphinscheduler.api.dto.gantt.GanttDto; import org.apache.dolphinscheduler.api.dto.gantt.Task; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.ExecutorService; import org.apache.dolphinscheduler.api.service.LoggerService; import org.apache.dolphinscheduler.api.service.ProcessDefinitionService; import org.apache.dolphinscheduler.api.service.ProcessInstanceService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.UsersService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; import org.apache.dolphinscheduler.common.graph.DAG; import org.apache.dolphinscheduler.common.model.TaskNodeRelation; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.placeholder.BusinessTimeUtils; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.ResponseTaskLog;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao; import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao; import org.apache.dolphinscheduler.dao.utils.WorkflowUtils; import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; import org.apache.dolphinscheduler.plugin.task.api.model.Property; import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils; import org.apache.dolphinscheduler.service.expand.CuringParamsService; import org.apache.dolphinscheduler.service.model.TaskNode; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.commons.lang3.StringUtils; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * process instance service impl */ @Service public class ProcessInstanceServiceImpl extends BaseServiceImpl implements ProcessInstanceService { private static final Logger logger = LoggerFactory.getLogger(ProcessInstanceServiceImpl.class); public static final String TASK_TYPE = "taskType"; public static final String LOCAL_PARAMS_LIST = "localParamsList"; @Autowired ProjectMapper projectMapper; @Autowired ProjectService projectService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
@Autowired ProcessService processService; @Autowired TaskInstanceDao taskInstanceDao; @Autowired ProcessInstanceMapper processInstanceMapper; @Autowired ProcessInstanceDao processInstanceDao; @Autowired ProcessDefinitionMapper processDefineMapper; @Autowired ProcessDefinitionService processDefinitionService; @Autowired ExecutorService execService; @Autowired TaskInstanceMapper taskInstanceMapper; @Autowired LoggerService loggerService; @Autowired ProcessDefinitionLogMapper processDefinitionLogMapper; @Autowired TaskDefinitionLogMapper taskDefinitionLogMapper; @Autowired UsersService usersService; @Autowired private TenantMapper tenantMapper; @Autowired TaskDefinitionMapper taskDefinitionMapper; @Autowired private TaskPluginManager taskPluginManager;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
@Autowired private ScheduleMapper scheduleMapper; @Autowired private CuringParamsService curingGlobalParamsService; /** * return top n SUCCESS process instance order by running time which started between startTime and endTime */ @Override public Map<String, Object> queryTopNLongestRunningProcessInstance(User loginUser, long projectCode, int size, String startTime, String endTime) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_INSTANCE); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (0 > size) { putMsg(result, Status.NEGTIVE_SIZE_NUMBER_ERROR, size); return result; } if (Objects.isNull(startTime)) { putMsg(result, Status.DATA_IS_NULL, Constants.START_TIME); return result; } Date start = DateUtils.stringToDate(startTime); if (Objects.isNull(endTime)) { putMsg(result, Status.DATA_IS_NULL, Constants.END_TIME); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
Date end = DateUtils.stringToDate(endTime); if (start == null || end == null) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.START_END_DATE); return result; } if (start.getTime() > end.getTime()) { putMsg(result, Status.START_TIME_BIGGER_THAN_END_TIME_ERROR, startTime, endTime); return result; } List<ProcessInstance> processInstances = processInstanceMapper.queryTopNProcessInstance(size, start, end, WorkflowExecutionStatus.SUCCESS, projectCode); result.put(DATA_LIST, processInstances); putMsg(result, Status.SUCCESS); return result; } /** * query process instance by id * * @param loginUser login user * @param projectCode project code * @param processId process instance id * @return process instance detail */ @Override public Map<String, Object> queryProcessInstanceById(User loginUser, long projectCode, Integer processId) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_INSTANCE); if (result.get(Constants.STATUS) != Status.SUCCESS) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
return result; } ProcessInstance processInstance = processService.findProcessInstanceDetailById(processId) .orElseThrow(() -> new ServiceException(PROCESS_INSTANCE_NOT_EXIST, processId)); ProcessDefinition processDefinition = processService.findProcessDefinition(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { logger.error("Process definition does not exist, projectCode:{}.", projectCode); putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId); } else { processInstance.setLocations(processDefinition.getLocations()); processInstance.setDagData(processService.genDagData(processDefinition)); result.put(DATA_LIST, processInstance); putMsg(result, Status.SUCCESS); } return result; } /** * paging query process instance list, filtering according to project, process definition, time range, keyword, process status * * @param loginUser login user * @param projectCode project code * @param processDefineCode process definition code * @param pageNo page number * @param pageSize page size * @param searchVal search value * @param stateType state type * @param host host * @param startDate start time
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
* @param endDate end time * @param otherParamsJson otherParamsJson handle other params * @return process instance list */ @Override public Result queryProcessInstanceList(User loginUser, long projectCode, long processDefineCode, String startDate, String endDate, String searchVal, String executorName, WorkflowExecutionStatus stateType, String host, String otherParamsJson, Integer pageNo, Integer pageSize) { Result result = new Result(); Project project = projectMapper.queryByCode(projectCode); Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_INSTANCE); Status resultEnum = (Status) checkResult.get(Constants.STATUS); if (resultEnum != Status.SUCCESS) { putMsg(result, resultEnum); return result; } int[] statusArray = null; if (stateType != null) { statusArray = new int[]{stateType.getCode()}; } Map<String, Object> checkAndParseDateResult = checkAndParseDateParameters(startDate, endDate); resultEnum = (Status) checkAndParseDateResult.get(Constants.STATUS); if (resultEnum != Status.SUCCESS) { putMsg(result, resultEnum); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
Date start = (Date) checkAndParseDateResult.get(Constants.START_TIME); Date end = (Date) checkAndParseDateResult.get(Constants.END_TIME); Page<ProcessInstance> page = new Page<>(pageNo, pageSize); PageInfo<ProcessInstance> pageInfo = new PageInfo<>(pageNo, pageSize); int executorId = usersService.getUserIdByName(executorName); IPage<ProcessInstance> processInstanceList = processInstanceMapper.queryProcessInstanceListPaging(page, project.getCode(), processDefineCode, searchVal, executorId, statusArray, host, start, end); List<ProcessInstance> processInstances = processInstanceList.getRecords(); List<Integer> userIds = Collections.emptyList(); if (CollectionUtils.isNotEmpty(processInstances)) { userIds = processInstances.stream().map(ProcessInstance::getExecutorId).collect(Collectors.toList()); } List<User> users = usersService.queryUser(userIds); Map<Integer, User> idToUserMap = Collections.emptyMap(); if (CollectionUtils.isNotEmpty(users)) { idToUserMap = users.stream().collect(Collectors.toMap(User::getId, Function.identity())); } for (ProcessInstance processInstance : processInstances) { processInstance.setDuration(WorkflowUtils.getWorkflowInstanceDuration(processInstance)); User executor = idToUserMap.get(processInstance.getExecutorId()); if (null != executor) { processInstance.setExecutorName(executor.getUserName()); } } pageInfo.setTotal((int) processInstanceList.getTotal()); pageInfo.setTotalList(processInstances); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
/** * query task list by process instance id * * @param loginUser login user * @param projectCode project code * @param processId process instance id * @return task list for the process instance * @throws IOException io exception */ @Override public Map<String, Object> queryTaskListByProcessId(User loginUser, long projectCode, Integer processId) throws IOException { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_INSTANCE); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } ProcessInstance processInstance = processService.findProcessInstanceDetailById(processId) .orElseThrow(() -> new ServiceException(PROCESS_INSTANCE_NOT_EXIST, processId)); ProcessDefinition processDefinition = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); if (processDefinition != null && projectCode != processDefinition.getProjectCode()) { logger.error("Process definition does not exist, projectCode:{}, processDefinitionId:{}.", projectCode, processId); putMsg(result, PROCESS_INSTANCE_NOT_EXIST, processId); return result; } List<TaskInstance> taskInstanceList =
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
taskInstanceDao.findValidTaskListByProcessId(processId, processInstance.getTestFlag()); addDependResultForTaskList(taskInstanceList); Map<String, Object> resultMap = new HashMap<>(); resultMap.put(PROCESS_INSTANCE_STATE, processInstance.getState().toString()); resultMap.put(TASK_LIST, taskInstanceList); result.put(DATA_LIST, resultMap); putMsg(result, Status.SUCCESS); return result; } /** * add dependent result for dependent task */ private void addDependResultForTaskList(List<TaskInstance> taskInstanceList) throws IOException { for (TaskInstance taskInstance : taskInstanceList) { if (TASK_TYPE_DEPENDENT.equalsIgnoreCase(taskInstance.getTaskType())) { logger.info("DEPENDENT type task instance need to set dependent result, taskCode:{}, taskInstanceId:{}", taskInstance.getTaskCode(), taskInstance.getId()); Result<ResponseTaskLog> logResult = loggerService.queryLog( taskInstance.getId(), Constants.LOG_QUERY_SKIP_LINE_NUMBER, Constants.LOG_QUERY_LIMIT); if (logResult.getCode() == Status.SUCCESS.ordinal()) { String log = logResult.getData().getMessage(); Map<String, DependResult> resultMap = parseLogForDependentResult(log); taskInstance.setDependentResult(JSONUtils.toJsonString(resultMap)); } } } } @Override public Map<String, DependResult> parseLogForDependentResult(String log) throws IOException { Map<String, DependResult> resultMap = new HashMap<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
if (StringUtils.isEmpty(log)) { logger.warn("Log content is empty."); return resultMap; } BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(log.getBytes( StandardCharsets.UTF_8)), StandardCharsets.UTF_8)); String line; while ((line = br.readLine()) != null) { if (line.contains(DEPENDENT_SPLIT)) { String[] tmpStringArray = line.split(":\\|\\|"); if (tmpStringArray.length != 2) { continue; } String dependResultString = tmpStringArray[1]; String[] dependStringArray = dependResultString.split(","); if (dependStringArray.length != 2) { continue; } String key = dependStringArray[0].trim(); DependResult dependResult = DependResult.valueOf(dependStringArray[1].trim()); resultMap.put(key, dependResult); } } return resultMap; } /** * query sub process instance detail info by task id * * @param loginUser login user * @param projectCode project code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
* @param taskId task id * @return sub process instance detail */ @Override public Map<String, Object> querySubProcessInstanceByTaskId(User loginUser, long projectCode, Integer taskId) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_INSTANCE); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } TaskInstance taskInstance = taskInstanceDao.findTaskInstanceById(taskId); if (taskInstance == null) { logger.error("Task instance does not exist, projectCode:{}, taskInstanceId{}.", projectCode, taskId); putMsg(result, Status.TASK_INSTANCE_NOT_EXISTS, taskId); return result; } TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskInstance.getTaskCode()); if (taskDefinition != null && projectCode != taskDefinition.getProjectCode()) { logger.error("Task definition does not exist, projectCode:{}, taskDefinitionCode:{}.", projectCode, taskInstance.getTaskCode()); putMsg(result, Status.TASK_INSTANCE_NOT_EXISTS, taskId); return result; } if (!taskInstance.isSubProcess()) { logger.warn("Task instance is not {} type instance, projectCode:{}, taskInstanceId:{}.", TASK_TYPE_SUB_PROCESS, projectCode, taskId); putMsg(result, Status.TASK_INSTANCE_NOT_SUB_WORKFLOW_INSTANCE, taskInstance.getName()); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
} ProcessInstance subWorkflowInstance = processService.findSubProcessInstance( taskInstance.getProcessInstanceId(), taskInstance.getId()); if (subWorkflowInstance == null) { logger.error("SubProcess instance does not exist, projectCode:{}, taskInstanceId:{}.", projectCode, taskInstance.getId()); putMsg(result, Status.SUB_PROCESS_INSTANCE_NOT_EXIST, taskId); return result; } Map<String, Object> dataMap = new HashMap<>(); dataMap.put(Constants.SUBPROCESS_INSTANCE_ID, subWorkflowInstance.getId()); result.put(DATA_LIST, dataMap); putMsg(result, Status.SUCCESS); return result; } /** * update process instance * * @param loginUser login user * @param projectCode project code * @param taskRelationJson process task relation json * @param taskDefinitionJson taskDefinitionJson * @param processInstanceId process instance id * @param scheduleTime schedule time * @param syncDefine sync define * @param globalParams * @param locations locations for nodes * @param timeout timeout * @param tenantCode tenantCode * @return update result code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
*/ @Transactional @Override public Map<String, Object> updateProcessInstance(User loginUser, long projectCode, Integer processInstanceId, String taskRelationJson, String taskDefinitionJson, String scheduleTime, Boolean syncDefine, String globalParams, String locations, int timeout, String tenantCode) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, INSTANCE_UPDATE); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } ProcessInstance processInstance = processService.findProcessInstanceDetailById(processInstanceId) .orElseThrow(() -> new ServiceException(PROCESS_INSTANCE_NOT_EXIST, processInstanceId)); ProcessDefinition processDefinition0 = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); if (processDefinition0 != null && projectCode != processDefinition0.getProjectCode()) { logger.error("Process definition does not exist, projectCode:{}, processDefinitionCode:{}.", projectCode, processInstance.getProcessDefinitionCode()); putMsg(result, PROCESS_INSTANCE_NOT_EXIST, processInstanceId); return result; } if (!processInstance.getState().isFinished()) { logger.warn("Process Instance state is {} so can not update process instance, processInstanceId:{}.",
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
processInstance.getState().getDesc(), processInstanceId); putMsg(result, PROCESS_INSTANCE_STATE_OPERATION_ERROR, processInstance.getName(), processInstance.getState().toString(), "update"); return result; } Map<String, String> commandParamMap = JSONUtils.toMap(processInstance.getCommandParam()); String timezoneId = null; if (commandParamMap == null || StringUtils.isBlank(commandParamMap.get(Constants.SCHEDULE_TIMEZONE))) { timezoneId = loginUser.getTimeZone(); } else { timezoneId = commandParamMap.get(Constants.SCHEDULE_TIMEZONE); } setProcessInstance(processInstance, tenantCode, scheduleTime, globalParams, timeout, timezoneId); List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); if (taskDefinitionLogs.isEmpty()) { logger.warn("Parameter taskDefinitionJson is empty"); putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJson); return result; } for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() .taskType(taskDefinitionLog.getTaskType()) .taskParams(taskDefinitionLog.getTaskParams()) .dependence(taskDefinitionLog.getDependence()) .build())) { logger.error("Task parameters are invalid, taskDefinitionName:{}.", taskDefinitionLog.getName()); putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName()); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
} int saveTaskResult = processService.saveTaskDefine(loginUser, projectCode, taskDefinitionLogs, syncDefine); if (saveTaskResult == Constants.DEFINITION_FAILURE) { logger.error("Update task definition error, projectCode:{}, processInstanceId:{}", projectCode, processInstanceId); putMsg(result, Status.UPDATE_TASK_DEFINITION_ERROR); throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR); } ProcessDefinition processDefinition = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); List<ProcessTaskRelationLog> taskRelationList = JSONUtils.toList(taskRelationJson, ProcessTaskRelationLog.class); result = processDefinitionService.checkProcessNodeList(taskRelationJson, taskDefinitionLogs); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } int tenantId = -1; if (!Constants.DEFAULT.equals(tenantCode)) { Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); if (tenant == null) { logger.error("Tenant does not exist."); putMsg(result, Status.TENANT_NOT_EXIST); return result; } tenantId = tenant.getId(); } processDefinition.set(projectCode, processDefinition.getName(), processDefinition.getDescription(), globalParams, locations, timeout, tenantId); processDefinition.setUpdateTime(new Date());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
int insertVersion = processService.saveProcessDefine(loginUser, processDefinition, syncDefine, Boolean.FALSE); if (insertVersion == 0) { logger.error("Update process definition error, projectCode:{}, processDefinitionName:{}.", projectCode, processDefinition.getName()); putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); } else logger.info("Update process definition complete, projectCode:{}, processDefinitionName:{}.", projectCode, processDefinition.getName()); int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs, syncDefine); if (insertResult == Constants.EXIT_CODE_SUCCESS) { logger.info( "Update task relations complete, projectCode:{}, processDefinitionCode:{}, processDefinitionVersion:{}.", projectCode, processDefinition.getCode(), insertVersion); putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, processDefinition); } else { logger.info( "Update task relations error, projectCode:{}, processDefinitionCode:{}, processDefinitionVersion:{}.", projectCode, processDefinition.getCode(), insertVersion); putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); } processInstance.setProcessDefinitionVersion(insertVersion); int update = processInstanceDao.updateProcessInstance(processInstance); if (update == 0) { logger.error( "Update process instance version error, projectCode:{}, processDefinitionCode:{}, processDefinitionVersion:{}", projectCode, processDefinition.getCode(), insertVersion);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
putMsg(result, Status.UPDATE_PROCESS_INSTANCE_ERROR); throw new ServiceException(Status.UPDATE_PROCESS_INSTANCE_ERROR); } logger.info( "Update process instance complete, projectCode:{}, processDefinitionCode:{}, processDefinitionVersion:{}, processInstanceId:{}", projectCode, processDefinition.getCode(), insertVersion, processInstanceId); putMsg(result, Status.SUCCESS); return result; } /** * update process instance attributes */ private void setProcessInstance(ProcessInstance processInstance, String tenantCode, String scheduleTime, String globalParams, int timeout, String timezone) { Date schedule = processInstance.getScheduleTime(); if (scheduleTime != null) { schedule = DateUtils.stringToDate(scheduleTime); } processInstance.setScheduleTime(schedule); List<Property> globalParamList = JSONUtils.toList(globalParams, Property.class); Map<String, String> globalParamMap = globalParamList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue)); globalParams = curingGlobalParamsService.curingGlobalParams(processInstance.getId(), globalParamMap, globalParamList, processInstance.getCmdTypeIfComplement(), schedule, timezone); processInstance.setTimeout(timeout); processInstance.setTenantCode(tenantCode); processInstance.setGlobalParams(globalParams); } /** * query parent process instance detail info by sub process instance id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
* * @param loginUser login user * @param projectCode project code * @param subId sub process id * @return parent instance detail */ @Override public Map<String, Object> queryParentInstanceBySubId(User loginUser, long projectCode, Integer subId) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_INSTANCE); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } ProcessInstance subInstance = processService.findProcessInstanceDetailById(subId) .orElseThrow(() -> new ServiceException(PROCESS_INSTANCE_NOT_EXIST, subId)); if (subInstance.getIsSubProcess() == Flag.NO) { logger.warn( "Process instance is not sub process instance type, processInstanceId:{}, processInstanceName:{}.", subId, subInstance.getName()); putMsg(result, Status.PROCESS_INSTANCE_NOT_SUB_PROCESS_INSTANCE, subInstance.getName()); return result; } ProcessInstance parentWorkflowInstance = processService.findParentProcessInstance(subId); if (parentWorkflowInstance == null) { logger.error("Parent process instance does not exist, projectCode:{}, subProcessInstanceId:{}.", projectCode, subId); putMsg(result, Status.SUB_PROCESS_INSTANCE_NOT_EXIST); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
} Map<String, Object> dataMap = new HashMap<>(); dataMap.put(Constants.PARENT_WORKFLOW_INSTANCE, parentWorkflowInstance.getId()); result.put(DATA_LIST, dataMap); putMsg(result, Status.SUCCESS); return result; } /** * delete process instance by id, at the same time,delete task instance and their mapping relation data * * @param loginUser login user * @param projectCode project code * @param processInstanceId process instance id * @return delete result code */ @Override @Transactional public Map<String, Object> deleteProcessInstanceById(User loginUser, long projectCode, Integer processInstanceId) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, INSTANCE_DELETE); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } ProcessInstance processInstance = processService.findProcessInstanceDetailById(processInstanceId) .orElseThrow(() -> new ServiceException(PROCESS_INSTANCE_NOT_EXIST, processInstanceId)); if (!processInstance.getState().isFinished()) { logger.warn("Process Instance state is {} so can not delete process instance, processInstanceId:{}.",
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
processInstance.getState().getDesc(), processInstanceId); throw new ServiceException(PROCESS_INSTANCE_STATE_OPERATION_ERROR, processInstance.getName(), processInstance.getState(), "delete"); } ProcessDefinition processDefinition = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); if (processDefinition != null && projectCode != processDefinition.getProjectCode()) { logger.error("Process definition does not exist, projectCode:{}, ProcessDefinitionCode:{}.", projectCode, processInstance.getProcessDefinitionCode()); throw new ServiceException(PROCESS_INSTANCE_NOT_EXIST, processInstanceId); } try { processService.removeTaskLogFile(processInstanceId); } catch (Exception ) { logger.warn( "Remove task log file exception, projectCode:{}, ProcessDefinitionCode{}, processInstanceId:{}.", projectCode, processInstance.getProcessDefinitionCode(), processInstanceId); } int delete = processService.deleteWorkProcessInstanceById(processInstanceId); processService.deleteAllSubWorkProcessByParentId(processInstanceId); processService.deleteWorkProcessMapByParentId(processInstanceId); processService.deleteWorkTaskInstanceByProcessInstanceId(processInstanceId); if (delete > 0) { logger.info( "Delete process instance complete, projectCode:{}, ProcessDefinitionCode{}, processInstanceId:{}.", projectCode, processInstance.getProcessDefinitionCode(), processInstanceId); putMsg(result, Status.SUCCESS); } else {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
logger.error( "Delete process instance error, projectCode:{}, ProcessDefinitionCode{}, processInstanceId:{}.", projectCode, processInstance.getProcessDefinitionCode(), processInstanceId); putMsg(result, Status.DELETE_PROCESS_INSTANCE_BY_ID_ERROR); throw new ServiceException(Status.DELETE_PROCESS_INSTANCE_BY_ID_ERROR); } return result; } /** * view process instance variables * * @param projectCode project code * @param processInstanceId process instance id * @return variables data */ @Override public Map<String, Object> viewVariables(long projectCode, Integer processInstanceId) { Map<String, Object> result = new HashMap<>(); ProcessInstance processInstance = processInstanceMapper.queryDetailById(processInstanceId); if (processInstance == null) { logger.error("Process instance does not exist, projectCode:{}, processInstanceId:{}.", projectCode, processInstanceId); putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); return result; } ProcessDefinition processDefinition = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); if (processDefinition != null && projectCode != processDefinition.getProjectCode()) { logger.error("Process definition does not exist, projectCode:{}, processDefinitionCode:{}.", projectCode, processInstance.getProcessDefinitionCode());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
putMsg(result, PROCESS_INSTANCE_NOT_EXIST, processInstanceId); return result; } Map<String, String> commandParam = JSONUtils.toMap(processInstance.getCommandParam()); String timezone = null; if (commandParam != null) { timezone = commandParam.get(Constants.SCHEDULE_TIMEZONE); } Map<String, String> timeParams = BusinessTimeUtils .getBusinessTime(processInstance.getCmdTypeIfComplement(), processInstance.getScheduleTime(), timezone); String userDefinedParams = processInstance.getGlobalParams(); List<Property> globalParams = new ArrayList<>(); String globalParamStr = ParameterUtils.convertParameterPlaceholders(JSONUtils.toJsonString(globalParams), timeParams); globalParams = JSONUtils.toList(globalParamStr, Property.class); for (Property property : globalParams) { timeParams.put(property.getProp(), property.getValue()); } if (userDefinedParams != null && userDefinedParams.length() > 0) { globalParams = JSONUtils.toList(userDefinedParams, Property.class); } Map<String, Map<String, Object>> localUserDefParams = getLocalParams(processInstance, timeParams); Map<String, Object> resultMap = new HashMap<>(); resultMap.put(GLOBAL_PARAMS, globalParams); resultMap.put(LOCAL_PARAMS, localUserDefParams); result.put(DATA_LIST, resultMap); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
return result; } /** * get local params */ private Map<String, Map<String, Object>> getLocalParams(ProcessInstance processInstance, Map<String, String> timeParams) { Map<String, Map<String, Object>> localUserDefParams = new HashMap<>(); List<TaskInstance> taskInstanceList = taskInstanceMapper.findValidTaskListByProcessId(processInstance.getId(), Flag.YES, processInstance.getTestFlag()); for (TaskInstance taskInstance : taskInstanceList) { TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion( taskInstance.getTaskCode(), taskInstance.getTaskDefinitionVersion()); String localParams = JSONUtils.getNodeString(taskDefinitionLog.getTaskParams(), LOCAL_PARAMS); if (!StringUtils.isEmpty(localParams)) { localParams = ParameterUtils.convertParameterPlaceholders(localParams, timeParams); List<Property> localParamsList = JSONUtils.toList(localParams, Property.class); Map<String, Object> localParamsMap = new HashMap<>(); localParamsMap.put(TASK_TYPE, taskDefinitionLog.getTaskType()); localParamsMap.put(LOCAL_PARAMS_LIST, localParamsList); if (CollectionUtils.isNotEmpty(localParamsList)) { localUserDefParams.put(taskDefinitionLog.getName(), localParamsMap); } } } return localUserDefParams; } /** * encapsulation gantt structure
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
* * @param projectCode project code * @param processInstanceId process instance id * @return gantt tree data * @throws Exception exception when json parse */ @Override public Map<String, Object> viewGantt(long projectCode, Integer processInstanceId) throws Exception { Map<String, Object> result = new HashMap<>(); ProcessInstance processInstance = processInstanceMapper.queryDetailById(processInstanceId); if (processInstance == null) { logger.error("Process instance does not exist, projectCode:{}, processInstanceId:{}.", projectCode, processInstanceId); putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); return result; } ProcessDefinition processDefinition = processDefinitionLogMapper.queryByDefinitionCodeAndVersion( processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { logger.error("Process definition does not exist, projectCode:{}, processDefinitionCode:{}.", projectCode, processInstance.getProcessDefinitionCode()); putMsg(result, PROCESS_INSTANCE_NOT_EXIST, processInstanceId); return result; } GanttDto ganttDto = new GanttDto(); DAG<String, TaskNode, TaskNodeRelation> dag = processService.genDagGraph(processDefinition); List<String> nodeList = dag.topologicalSort(); ganttDto.setTaskNames(nodeList);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
List<Task> taskList = new ArrayList<>(); if (CollectionUtils.isNotEmpty(nodeList)) { List<Long> taskCodes = nodeList.stream().map(Long::parseLong).collect(Collectors.toList()); List<TaskInstance> taskInstances = taskInstanceMapper.queryByProcessInstanceIdsAndTaskCodes( Collections.singletonList(processInstanceId), taskCodes); for (String node : nodeList) { TaskInstance taskInstance = null; for (TaskInstance instance : taskInstances) { if (instance.getProcessInstanceId() == processInstanceId && instance.getTaskCode() == Long.parseLong(node)) { taskInstance = instance; break; } } if (taskInstance == null) { continue; } Date startTime = taskInstance.getStartTime() == null ? new Date() : taskInstance.getStartTime(); Date endTime = taskInstance.getEndTime() == null ? new Date() : taskInstance.getEndTime(); Task task = new Task(); task.setTaskName(taskInstance.getName()); task.getStartDate().add(startTime.getTime()); task.getEndDate().add(endTime.getTime()); task.setIsoStart(startTime); task.setIsoEnd(endTime); task.setStatus(taskInstance.getState().getDesc().toUpperCase()); task.setExecutionDate(taskInstance.getStartTime()); task.setDuration(DateUtils.format2Readable(endTime.getTime() - startTime.getTime())); taskList.add(task); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,429
[Bug] [API] The workflow definition and the tenant in the workflow instance are inconsistent
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened <img width="680" alt="1666837161777" src="https://user-images.githubusercontent.com/33045461/198175765-4089aa91-437b-4314-8e27-7dad5fc59a3d.png"> <img width="711" alt="1666837141669" src="https://user-images.githubusercontent.com/33045461/198175773-7fee4a5a-1343-4aaf-930e-1f8859c8f268.png"> ### What you expected to happen The workflow definition is consistent with the tenant in the workflow instance. ### How to reproduce 1.create workflow definition 2.run workflow definition 3.click edit workflow 4.click edit wotkflow instance ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12429
https://github.com/apache/dolphinscheduler/pull/12533
2c1583d1941f9b2cdfcfced80db359cb738d8981
547aa437ab424250dac6b4df3de7a4b1b8af7d98
2022-10-19T02:03:06Z
java
2022-10-26T08:11:24Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
} ganttDto.setTasks(taskList); result.put(DATA_LIST, ganttDto); putMsg(result, Status.SUCCESS); return result; } /** * query process instance by processDefinitionCode and stateArray * * @param processDefinitionCode processDefinitionCode * @param states states array * @return process instance list */ @Override public List<ProcessInstance> queryByProcessDefineCodeAndStatus(Long processDefinitionCode, int[] states) { return processInstanceMapper.queryByProcessDefineCodeAndStatus(processDefinitionCode, states); } /** * query process instance by processDefinitionCode * * @param processDefinitionCode processDefinitionCode * @param size size * @return process instance list */ @Override public List<ProcessInstance> queryByProcessDefineCode(Long processDefinitionCode, int size) { return processInstanceMapper.queryByProcessDefineCode(processDefinitionCode, size); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkerGroupService.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.service; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.dao.entity.User; import java.util.Map; /** * worker group service */ public interface WorkerGroupService {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkerGroupService.java
/** * create or update a worker group * * @param loginUser login user * @param id worker group id * @param name worker group name * @param addrList addr list * @param description description * @param otherParamsJson otherParamsJson * @return create or update result code */ Map<String, Object> saveWorkerGroup(User loginUser, int id, String name, String addrList, String description, String otherParamsJson); /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkerGroupService.java
* query worker group paging * * @param loginUser login user * @param pageNo page number * @param searchVal search value * @param pageSize page size * @return worker group list page */ Result queryAllGroupPaging(User loginUser, Integer pageNo, Integer pageSize, String searchVal); /** * query all worker group * * @param loginUser * @return all worker group list */ Map<String, Object> queryAllGroup(User loginUser); /** * delete worker group by id * @param id worker group id * @return delete result code */ Map<String, Object> deleteWorkerGroupById(User loginUser, Integer id); /** * query all worker address list * * @return all worker address list */ Map<String, Object> getWorkerAddressList(); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* limitations under the License. */ package org.apache.dolphinscheduler.api.service.impl; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_START; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_COMPLEMENT_DATA_END_DATE; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_COMPLEMENT_DATA_START_DATE; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_RECOVER_PROCESS_ID_STRING; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_START_NODES; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_START_PARAMS; import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE; import static org.apache.dolphinscheduler.common.constants.Constants.COMMA; import static org.apache.dolphinscheduler.common.constants.Constants.MAX_TASK_TIMEOUT; import static org.apache.dolphinscheduler.common.constants.Constants.SCHEDULE_TIME_MAX_LENGTH; import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant; import org.apache.dolphinscheduler.api.enums.ExecuteType; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.ExecutorService; import org.apache.dolphinscheduler.api.service.MonitorService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.ComplementDependentMode; import org.apache.dolphinscheduler.common.enums.CycleEnum; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.RunMode;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
import org.apache.dolphinscheduler.common.enums.TaskDependType; import org.apache.dolphinscheduler.common.enums.TaskGroupQueueStatus; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; import org.apache.dolphinscheduler.common.model.Server; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.DependentProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskGroupQueue; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper; import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao; import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.remote.command.TaskExecuteStartCommand; import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataRequestCommand; import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataResponseCommand; import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
import org.apache.dolphinscheduler.remote.dto.WorkflowExecuteDto; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.service.command.CommandService; import org.apache.dolphinscheduler.service.cron.CronUtils; import org.apache.dolphinscheduler.service.exceptions.CronParseException; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.fasterxml.jackson.core.type.TypeReference; import com.google.common.collect.Lists; /** * executor service impl */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorService { private static final Logger logger = LoggerFactory.getLogger(ExecutorServiceImpl.class); @Autowired private ProjectMapper projectMapper; @Autowired private ProjectService projectService; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private MonitorService monitorService; @Autowired private ProcessInstanceMapper processInstanceMapper; @Autowired private ProcessService processService; @Autowired private CommandService commandService; @Autowired private ProcessInstanceDao processInstanceDao; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
private StateEventCallbackService stateEventCallbackService; @Autowired private TaskDefinitionMapper taskDefinitionMapper; @Autowired private ProcessTaskRelationMapper processTaskRelationMapper; @Autowired private TaskGroupQueueMapper taskGroupQueueMapper; /** * execute process instance * * @param loginUser login user * @param projectCode project code * @param processDefinitionCode process definition code * @param cronTime cron time * @param commandType command type * @param failureStrategy failure strategy * @param startNodeList start nodelist * @param taskDependType node dependency type * @param warningType warning type * @param warningGroupId notify group id * @param processInstancePriority process instance priority * @param workerGroup worker group name * @param environmentCode environment code * @param runMode run mode * @param timeout timeout * @param startParams the global param values which pass to new process instance * @param expectedParallelismNumber the expected parallelism number when execute complement in parallel mode * @param testFlag testFlag * @return execute process instance code */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
@Override public Map<String, Object> execProcessInstance(User loginUser, long projectCode, long processDefinitionCode, String cronTime, CommandType commandType, FailureStrategy failureStrategy, String startNodeList, TaskDependType taskDependType, WarningType warningType, Integer warningGroupId, RunMode runMode, Priority processInstancePriority, String workerGroup, Long environmentCode, Integer timeout, Map<String, String> startParams, Integer expectedParallelismNumber, int dryRun, int testFlag, ComplementDependentMode complementDependentMode) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_START); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (timeout <= 0 || timeout > MAX_TASK_TIMEOUT) { logger.warn("Parameter timeout is invalid, timeout:{}.", timeout); putMsg(result, Status.TASK_TIMEOUT_PARAMS_ERROR); return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode); this.checkProcessDefinitionValid(projectCode, processDefinition, processDefinitionCode, processDefinition.getVersion()); if (!checkTenantSuitable(processDefinition)) { logger.error(
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
"There is not any valid tenant for the process definition, processDefinitionCode:{}, processDefinitionName:{}.", processDefinition.getCode(), processDefinition.getName()); putMsg(result, Status.TENANT_NOT_SUITABLE); return result; } if (!checkScheduleTimeNum(commandType, cronTime)) { putMsg(result, Status.SCHEDULE_TIME_NUMBER); return result; } if (!checkMasterExists(result)) { return result; } /** * create command */ int create = this.createCommand(commandType, processDefinition.getCode(), taskDependType, failureStrategy, startNodeList, cronTime, warningType, loginUser.getId(), warningGroupId, runMode, processInstancePriority, workerGroup, environmentCode, startParams, expectedParallelismNumber, dryRun, testFlag, complementDependentMode); if (create > 0) { processDefinition.setWarningGroupId(warningGroupId); processDefinitionMapper.updateById(processDefinition); logger.info("Create command complete, processDefinitionCode:{}, commandCount:{}.", processDefinition.getCode(), create); putMsg(result, Status.SUCCESS); } else {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
logger.error("Start process instance failed because create command error, processDefinitionCode:{}.", processDefinition.getCode()); putMsg(result, Status.START_PROCESS_INSTANCE_ERROR); } return result; } /** * check whether master exists * * @param result result * @return master exists return true , otherwise return false */ private boolean checkMasterExists(Map<String, Object> result) { List<Server> masterServers = monitorService.getServerListFromRegistry(true); if (masterServers.isEmpty()) { logger.error("Master does not exist."); putMsg(result, Status.MASTER_NOT_EXISTS); return false; } return true; } /** * @param complementData * @param cronTime * @return CommandType is COMPLEMENT_DATA and cronTime's number is not greater than 100 return true , otherwise return false */ private boolean checkScheduleTimeNum(CommandType complementData, String cronTime) { if (!CommandType.COMPLEMENT_DATA.equals(complementData)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
return true; } if (cronTime == null) { return true; } Map<String, String> cronMap = JSONUtils.toMap(cronTime); if (cronMap.containsKey(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST)) { String[] stringDates = cronMap.get(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST).split(COMMA); if (stringDates.length > SCHEDULE_TIME_MAX_LENGTH) { logger.warn("Parameter cornTime is bigger than {}.", SCHEDULE_TIME_MAX_LENGTH); return false; } } return true; } /** * check whether the process definition can be executed * * @param projectCode project code * @param processDefinition process definition * @param processDefineCode process definition code * @param version process instance version */ @Override public void checkProcessDefinitionValid(long projectCode, ProcessDefinition processDefinition, long processDefineCode, Integer version) { if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { throw new ServiceException(Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(processDefineCode)); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (processDefinition.getReleaseState() != ReleaseState.ONLINE) { throw new ServiceException(Status.PROCESS_DEFINE_NOT_RELEASE, String.valueOf(processDefineCode), version); } if (!checkSubProcessDefinitionValid(processDefinition)) { throw new ServiceException(Status.SUB_PROCESS_DEFINE_NOT_RELEASE); } } /** * check whether the current process has subprocesses and validate all subprocesses * * @param processDefinition * @return check result */ @Override public boolean checkSubProcessDefinitionValid(ProcessDefinition processDefinition) { List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryDownstreamByProcessDefinitionCode(processDefinition.getCode()); if (processTaskRelations.isEmpty()) { return true; } Set<Long> relationCodes = processTaskRelations.stream().map(ProcessTaskRelation::getPostTaskCode).collect(Collectors.toSet()); List<TaskDefinition> taskDefinitions = taskDefinitionMapper.queryByCodeList(relationCodes); Set<Long> processDefinitionCodeSet = new HashSet<>(); taskDefinitions.stream() .filter(task -> TaskConstants.TASK_TYPE_SUB_PROCESS.equalsIgnoreCase(task.getTaskType())).forEach(
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
taskDefinition -> processDefinitionCodeSet.add(Long.valueOf( JSONUtils.getNodeString(taskDefinition.getTaskParams(), CMD_PARAM_SUB_PROCESS_DEFINE_CODE)))); if (processDefinitionCodeSet.isEmpty()) { return true; } List<ProcessDefinition> processDefinitions = processDefinitionMapper.queryByCodes(processDefinitionCodeSet); return processDefinitions.stream() .filter(definition -> definition.getReleaseState().equals(ReleaseState.OFFLINE)) .collect(Collectors.toSet()) .isEmpty(); } /** * do action to process instance:pause, stop, repeat, recover from pause, recover from stop,rerun failed task * * @param loginUser login user * @param projectCode project code * @param processInstanceId process instance id * @param executeType execute type * @return execute result code */ @Override public Map<String, Object> execute(User loginUser, long projectCode, Integer processInstanceId, ExecuteType executeType) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
ApiFuncIdentificationConstant.map.get(executeType)); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (!checkMasterExists(result)) { return result; } ProcessInstance processInstance = processService.findProcessInstanceDetailById(processInstanceId) .orElseThrow(() -> new ServiceException(Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId)); ProcessDefinition processDefinition = processService.findProcessDefinition(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); processDefinition.setReleaseState(ReleaseState.ONLINE); if (executeType != ExecuteType.STOP && executeType != ExecuteType.PAUSE) { this.checkProcessDefinitionValid(projectCode, processDefinition, processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); } result = checkExecuteType(processInstance, executeType); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (!checkTenantSuitable(processDefinition)) { logger.error( "There is not any valid tenant for the process definition, processDefinitionId:{}, processDefinitionCode:{}, ", processDefinition.getId(), processDefinition.getName()); putMsg(result, Status.TENANT_NOT_SUITABLE); } // g Map<String, Object> commandMap =
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
JSONUtils.parseObject(processInstance.getCommandParam(), new TypeReference<Map<String, Object>>() { }); String startParams = null; if (MapUtils.isNotEmpty(commandMap) && executeType == ExecuteType.REPEAT_RUNNING) { Object startParamsJson = commandMap.get(CMD_PARAM_START_PARAMS); if (startParamsJson != null) { startParams = startParamsJson.toString(); } } switch (executeType) { case REPEAT_RUNNING: result = insertCommand(loginUser, processInstanceId, processDefinition.getCode(), processDefinition.getVersion(), CommandType.REPEAT_RUNNING, startParams, processInstance.getTestFlag()); break; case RECOVER_SUSPENDED_PROCESS: result = insertCommand(loginUser, processInstanceId, processDefinition.getCode(), processDefinition.getVersion(), CommandType.RECOVER_SUSPENDED_PROCESS, startParams, processInstance.getTestFlag()); break; case START_FAILURE_TASK_PROCESS: result = insertCommand(loginUser, processInstanceId, processDefinition.getCode(), processDefinition.getVersion(), CommandType.START_FAILURE_TASK_PROCESS, startParams, processInstance.getTestFlag()); break; case STOP: if (processInstance.getState() == WorkflowExecutionStatus.READY_STOP) { logger.warn("Process instance status is already {}, processInstanceName:{}.", WorkflowExecutionStatus.READY_STOP.getDesc(), processInstance.getName()); putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
processInstance.getState()); } else { result = updateProcessInstancePrepare(processInstance, CommandType.STOP, WorkflowExecutionStatus.READY_STOP); } break; case PAUSE: if (processInstance.getState() == WorkflowExecutionStatus.READY_PAUSE) { logger.warn("Process instance status is already {}, processInstanceName:{}.", WorkflowExecutionStatus.READY_STOP.getDesc(), processInstance.getName()); putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(), processInstance.getState()); } else { result = updateProcessInstancePrepare(processInstance, CommandType.PAUSE, WorkflowExecutionStatus.READY_PAUSE); } break; default: logger.warn("Unknown execute type for process instance, processInstanceId:{}.", processInstance.getId()); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "unknown execute type"); break; } return result; } @Override public Map<String, Object> forceStartTaskInstance(User loginUser, int queueId) { Map<String, Object> result = new HashMap<>(); TaskGroupQueue taskGroupQueue = taskGroupQueueMapper.selectById(queueId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
// c ProcessInstance processInstance = processInstanceMapper.selectById(taskGroupQueue.getProcessId()); if (processInstance == null) { logger.error("Process instance does not exist, projectCode:{}, processInstanceId:{}.", taskGroupQueue.getProjectCode(), taskGroupQueue.getProcessId()); putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, taskGroupQueue.getProcessId()); return result; } if (!checkMasterExists(result)) { return result; } return forceStart(processInstance, taskGroupQueue); } /** * check tenant suitable * * @param processDefinition process definition * @return true if tenant suitable, otherwise return false */ private boolean checkTenantSuitable(ProcessDefinition processDefinition) { Tenant tenant = processService.getTenantForProcess(processDefinition.getTenantId(), processDefinition.getUserId()); return tenant != null; } /** * Check the state of process instance and the type of operation match * * @param processInstance process instance * @param executeType execute type
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @return check result code */ private Map<String, Object> checkExecuteType(ProcessInstance processInstance, ExecuteType executeType) { Map<String, Object> result = new HashMap<>(); WorkflowExecutionStatus executionStatus = processInstance.getState(); boolean checkResult = false; switch (executeType) { case PAUSE: if (executionStatus.isRunning()) { checkResult = true; } break; case STOP: if (executionStatus.canStop()) { checkResult = true; } break; case REPEAT_RUNNING: if (executionStatus.isFinished()) { checkResult = true; } break; case START_FAILURE_TASK_PROCESS: if (executionStatus.isFailure()) { checkResult = true; } break; case RECOVER_SUSPENDED_PROCESS: if (executionStatus.isPause() || executionStatus.isStop()) { checkResult = true;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} break; default: break; } if (!checkResult) { putMsg(result, Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR, processInstance.getName(), executionStatus.toString(), executeType.toString()); } else { putMsg(result, Status.SUCCESS); } return result; } /** * prepare to update process instance command type and status * * @param processInstance process instance * @param commandType command type * @param executionStatus execute status * @return update result */ private Map<String, Object> updateProcessInstancePrepare(ProcessInstance processInstance, CommandType commandType, WorkflowExecutionStatus executionStatus) { Map<String, Object> result = new HashMap<>(); processInstance.setCommandType(commandType); processInstance.addHistoryCmd(commandType); processInstance.setStateWithDesc(executionStatus, commandType.getDescp() + "by ui"); int update = processInstanceDao.updateProcessInstance(processInstance); // d if (update > 0) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
logger.info("Process instance state is updated to {} in database, processInstanceName:{}.", executionStatus.getDesc(), processInstance.getName()); // d // s WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand( processInstance.getId(), 0, processInstance.getState(), processInstance.getId(), 0); Host host = new Host(processInstance.getHost()); stateEventCallbackService.sendResult(host, workflowStateEventChangeCommand.convert2Command()); putMsg(result, Status.SUCCESS); } else { logger.error("Process instance state update error, processInstanceName:{}.", processInstance.getName()); putMsg(result, Status.EXECUTE_PROCESS_INSTANCE_ERROR); } return result; } /** * prepare to update process instance command type and status * * @param processInstance process instance * @return update result */ private Map<String, Object> forceStart(ProcessInstance processInstance, TaskGroupQueue taskGroupQueue) { Map<String, Object> result = new HashMap<>(); if (taskGroupQueue.getStatus() != TaskGroupQueueStatus.WAIT_QUEUE) { logger.warn("Task group queue already starts, taskGroupQueueId:{}.", taskGroupQueue.getId()); putMsg(result, Status.TASK_GROUP_QUEUE_ALREADY_START); return result; } taskGroupQueue.setForceStart(Flag.YES.getCode()); processService.updateTaskGroupQueue(taskGroupQueue);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
logger.info("Sending force start command to master."); processService.sendStartTask2Master(processInstance, taskGroupQueue.getTaskId(), org.apache.dolphinscheduler.remote.command.CommandType.TASK_FORCE_STATE_EVENT_REQUEST); putMsg(result, Status.SUCCESS); return result; } /** * insert command, used in the implementation of the page, rerun, recovery (pause / failure) execution * * @param loginUser login user * @param instanceId instance id * @param processDefinitionCode process definition code * @param processVersion * @param commandType command type * @return insert result code */ private Map<String, Object> insertCommand(User loginUser, Integer instanceId, long processDefinitionCode, int processVersion, CommandType commandType, String startParams, int testFlag) { Map<String, Object> result = new HashMap<>(); // T Map<String, Object> cmdParam = new HashMap<>(); cmdParam.put(CMD_PARAM_RECOVER_PROCESS_ID_STRING, instanceId); if (!StringUtils.isEmpty(startParams)) { cmdParam.put(CMD_PARAM_START_PARAMS, startParams); } Command command = new Command(); command.setCommandType(commandType); command.setProcessDefinitionCode(processDefinitionCode); command.setCommandParam(JSONUtils.toJsonString(cmdParam));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
command.setExecutorId(loginUser.getId()); command.setProcessDefinitionVersion(processVersion); command.setProcessInstanceId(instanceId); command.setTestFlag(testFlag); if (!commandService.verifyIsNeedCreateCommand(command)) { logger.warn( "Process instance is executing the command, processDefinitionCode:{}, processDefinitionVersion:{}, processInstanceId:{}.", processDefinitionCode, processVersion, instanceId); putMsg(result, Status.PROCESS_INSTANCE_EXECUTING_COMMAND, String.valueOf(processDefinitionCode)); return result; } logger.info("Creating command, commandInfo:{}.", command); int create = commandService.createCommand(command); if (create > 0) { logger.info("Create {} command complete, processDefinitionCode:{}, processDefinitionVersion:{}.", command.getCommandType().getDescp(), command.getProcessDefinitionCode(), processVersion); putMsg(result, Status.SUCCESS); } else { logger.error( "Execute process instance failed because create {} command error, processDefinitionCode:{}, processDefinitionVersion:{}, processInstanceId:{}.", command.getCommandType().getDescp(), command.getProcessDefinitionCode(), processVersion, instanceId); putMsg(result, Status.EXECUTE_PROCESS_INSTANCE_ERROR); } return result; } /** * check whether sub processes are offline before starting process definition * * @param processDefinitionCode process definition code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @return check result code */ @Override public Map<String, Object> startCheckByProcessDefinedCode(long processDefinitionCode) { Map<String, Object> result = new HashMap<>(); ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode); if (processDefinition == null) { logger.error("Process definition is not be found, processDefinitionCode:{}.", processDefinitionCode); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "processDefinitionCode"); return result; } List<Long> codes = new ArrayList<>(); processService.recurseFindSubProcess(processDefinition.getCode(), codes); if (!codes.isEmpty()) { List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(codes); if (processDefinitionList != null) { for (ProcessDefinition processDefinitionTmp : processDefinitionList) { /** * if there is no online process, exit directly */ if (processDefinitionTmp.getReleaseState() != ReleaseState.ONLINE) { logger.warn("Subprocess definition {} of process definition {} is not {}.", processDefinitionTmp.getName(), processDefinition.getName(), ReleaseState.ONLINE.getDescp()); putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, processDefinitionTmp.getName()); return result; } } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,470
[Refactor] Migrate all workergroup-related interface functions from ProcessServiceImpl
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description + This is a part of #12403 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12470
https://github.com/apache/dolphinscheduler/pull/12493
547aa437ab424250dac6b4df3de7a4b1b8af7d98
ed209bdf82d855a804b68d8833f20595e86bb069
2022-10-20T13:08:02Z
java
2022-10-26T11:18:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
putMsg(result, Status.SUCCESS); return result; } /** * create command * * @param commandType commandType * @param processDefineCode processDefineCode * @param nodeDep nodeDep * @param failureStrategy failureStrategy * @param startNodeList startNodeList * @param schedule schedule * @param warningType warningType * @param executorId executorId * @param warningGroupId warningGroupId * @param runMode runMode * @param processInstancePriority processInstancePriority * @param workerGroup workerGroup * @param testFlag testFlag * @param environmentCode environmentCode * @return command id */ private int createCommand(CommandType commandType, long processDefineCode, TaskDependType nodeDep, FailureStrategy failureStrategy, String startNodeList, String schedule, WarningType warningType, int executorId, Integer warningGroupId, RunMode runMode, Priority processInstancePriority, String workerGroup, Long environmentCode, Map<String, String> startParams, Integer expectedParallelismNumber, int dryRun, int testFlag, ComplementDependentMode complementDependentMode) { /** * instantiate command schedule instance