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
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
private ProcessInstanceDao processInstanceDao; @Autowired private TaskDefinitionLogMapper taskDefinitionLogMapper; @Autowired private StateEventCallbackService stateEventCallbackService; @Autowired private TaskDefinitionMapper taskDefinitionMapper; @Autowired private ProcessTaskRelationMapper processTaskRelationMapper; @Autowired private TaskGroupQueueMapper taskGroupQueueMapper; @Autowired private WorkerGroupService workerGroupService; @Autowired private TriggerRelationService triggerRelationService; /** * execute process instance * * @param loginUser login user * @param projectCode project code * @param processDefinitionCode code * @param cronTime cron time * @param commandType command type * @param failureStrategy failure strategy * @param s start nodelist * @param t node dependency type * @param warningType warning type * @param warningGroupId notify group id * @param processInstancePriority process instance priority * @param workerGroup worker group name
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @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 */ @Override @Transactional(rollbackFor = Exception.class) public Map<String, Object> execProcessInstance(User loginUser, long projectCode, long processDefinitionCode, String cronTime, CommandType commandType, FailureStrategy failureStrategy, String s, T t, 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, Integer version) { 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
putMsg(result, Status.TASK_TIMEOUT_PARAMS_ERROR); return result; } ProcessDefinition processDefinition; if (null != version) { processDefinition = processService.findProcessDefinition(processDefinitionCode, version); } else { processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode); } this.checkProcessDefinitionValid(projectCode, processDefinition, processDefinitionCode, processDefinition.getVersion()); checkS(s, processDefinitionCode, processDefinition.getVersion()); if (!checkTenantSuitable(processDefinition)) { logger.error( "There is not any valid tenant for the , 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; } long triggerCode = CodeGenerateUtils.getInstance().genCode();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
/** * create command */ int create = this.createCommand(triggerCode, commandType, processDefinition.getCode(), t, failureStrategy, s, 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); result.put(Constants.DATA_LIST, triggerCode); putMsg(result, Status.SUCCESS); } else { 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
*/ 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)) { 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;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} } return true; } /** * check whether the can be executed * * @param projectCode project code * @param processDefinition * @param processDefineCode 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)); } 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* * @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( 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())
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
.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, 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 =
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
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 , processDefinitionId:{}, processDefinitionCode:{}, ", processDefinition.getId(), processDefinition.getName()); putMsg(result, Status.TENANT_NOT_SUITABLE); } // g Map<String, Object> commandMap = 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:
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
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(), 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());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
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; } /** * do action to workflow instance:pause, stop, repeat, recover from pause, recover from stop,rerun failed task * * @param loginUser login user * @param workflowInstanceId workflow instance id * @param executeType execute type * @return execute result code */ @Override public Map<String, Object> execute(User loginUser, Integer workflowInstanceId, ExecuteType executeType) { ProcessInstance processInstance = processInstanceMapper.selectById(workflowInstanceId); ProcessDefinition processDefinition = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
return execute(loginUser, processDefinition.getProjectCode(), workflowInstanceId, executeType); } /** * do action to execute task in process instance * * @param loginUser login user * @param projectCode project code * @param processInstanceId process instance id * @param s start node list * @param t task depend type * @return execute result code */ @Override public WorkflowExecuteResponse executeTask(User loginUser, long projectCode, Integer processInstanceId, String s, T t) { WorkflowExecuteResponse response = new WorkflowExecuteResponse(); Project project = projectMapper.queryByCode(projectCode); projectService.checkProjectAndAuthThrowException(loginUser, project, ApiFuncIdentificationConstant.map.get(ExecuteType.EXECUTE_TASK)); ProcessInstance processInstance = processService.findProcessInstanceDetailById(processInstanceId) .orElseThrow(() -> new ServiceException(Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId)); if (!processInstance.getState().isFinished()) { logger.error("Can not execute task for process instance which is not finished, processInstanceId:{}.", processInstanceId); putMsg(response, Status.WORKFLOW_INSTANCE_IS_NOT_FINISHED); return response; } ProcessDefinition processDefinition = processService.findProcessDefinition(processInstance.getProcessDefinitionCode(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
processInstance.getProcessDefinitionVersion()); processDefinition.setReleaseState(ReleaseState.ONLINE); this.checkProcessDefinitionValid(projectCode, processDefinition, processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); if (!checkTenantSuitable(processDefinition)) { logger.error( "There is not any valid tenant for the , processDefinitionId:{}, processDefinitionCode:{}, ", processDefinition.getId(), processDefinition.getName()); putMsg(response, Status.TENANT_NOT_SUITABLE); return response; } // g long sLong; try { sLong = Long.parseLong(s); } catch (NumberFormatException e) { logger.error("s is not a number"); putMsg(response, Status.REQUEST_PARAMS_NOT_VALID_ERROR, s); return response; } if (taskDefinitionLogMapper.queryMaxVersionForDefinition(sLong) == null) { putMsg(response, Status.EXECUTE_NOT_DEFINE_TASK); return response; } // To ad Map<String, Object> cmdParam = new HashMap<>(); cmdParam.put(CMD_PARAM_RECOVER_PROCESS_ID_STRING, processInstanceId); // Add S cmdParam.put(CMD_PARAM_START_NODES, s); Command command = new Command();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
command.setCommandType(CommandType.EXECUTE_TASK); command.setProcessDefinitionCode(processDefinition.getCode()); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); command.setExecutorId(loginUser.getId()); command.setProcessDefinitionVersion(processDefinition.getVersion()); command.setProcessInstanceId(processInstanceId); command.setTestFlag(processInstance.getTestFlag()); // Add t command.setT(t); if (!commandService.verifyIsNeedCreateCommand(command)) { logger.warn( "Process instance is executing the command, processDefinitionCode:{}, processDefinitionVersion:{}, processInstanceId:{}.", processDefinition.getCode(), processDefinition.getVersion(), processInstanceId); putMsg(response, Status.PROCESS_INSTANCE_EXECUTING_COMMAND, String.valueOf(processDefinition.getCode())); return response; } 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(), processDefinition.getVersion()); putMsg(response, Status.SUCCESS); } else { logger.error( "Execute process instance failed because create {} command error, processDefinitionCode:{}, processDefinitionVersion:{}, processInstanceId:{}.", command.getCommandType().getDescp(), command.getProcessDefinitionCode(), processDefinition.getVersion(), processInstanceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
putMsg(response, Status.EXECUTE_PROCESS_INSTANCE_ERROR); } return response; } @Override public Map<String, Object> forceStartTaskInstance(User loginUser, int queueId) { Map<String, Object> result = new HashMap<>(); TaskGroupQueue taskGroupQueue = taskGroupQueueMapper.selectById(queueId); // check process instance exist 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 * @return true if tenant suitable, otherwise return false */ private boolean checkTenantSuitable(ProcessDefinition processDefinition) { Tenant tenant =
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
processService.getTenantForProcess(processDefinition.getTenantId(), processDefinition.getUserId()); return tenant != null; } public void checkS(String s, Long processDefinitionCode, int version) { if (StringUtils.isNotEmpty(s)) { List<ProcessTaskRelation> processTaskRelations = processService.findRelationByCode(processDefinitionCode, version); List<Long> existsNodes = processTaskRelations.stream().map(ProcessTaskRelation::getPostTaskCode) .collect(Collectors.toList()); for (String startNode : s.split(Constants.COMMA)) { if (!existsNodes.contains(Long.valueOf(startNode))) { throw new ServiceException(Status.START_NODE_NOT_EXIST_IN_LAST_PROCESS, startNode); } } } } /** * Check the state of process instance and the type of operation match * * @param processInstance process instance * @param executeType execute type * @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()) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
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; } break; default: break; } if (!checkResult) { putMsg(result, Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR, processInstance.getName(), executionStatus.toString(), executeType.toString()); } else {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
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); // determine whether the process is normal if (update > 0) { logger.info("Process instance state is updated to {} in database, processInstanceName:{}.", executionStatus.getDesc(), processInstance.getName()); // directl // success 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} 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); 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 *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @param loginUser login user * @param instanceId instance id * @param processDefinitionCode 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<>(); // To ad 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)); 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));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
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 * * @param processDefinitionCode code * @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");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
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("Sub {} of {} is not {}.", processDefinitionTmp.getName(), processDefinition.getName(), ReleaseState.ONLINE.getDescp()); putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, processDefinitionTmp.getName()); return result; } } } } putMsg(result, Status.SUCCESS); return result; } /** * create command * * @param commandType commandType * @param processDefineCode processDefineCode * @param nodeDep nodeDep
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @param failureStrategy failureStrategy * @param s s * @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(Long triggerCode, CommandType commandType, long processDefineCode, T nodeDep, FailureStrategy failureStrategy, String s, 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 */ Command command = new Command(); Map<String, String> cmdParam = new HashMap<>(); if (commandType == null) { command.setCommandType(CommandType.START_PROCESS); } else { command.setCommandType(commandType); } command.setProcessDefinitionCode(processDefineCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (nodeDep != null) { command.setT(nodeDep); } if (failureStrategy != null) { command.setFailureStrategy(failureStrategy); } if (!StringUtils.isEmpty(s)) { cmdParam.put(CMD_PARAM_START_NODES, s); } if (warningType != null) { command.setWarningType(warningType); } if (startParams != null && startParams.size() > 0) { cmdParam.put(CMD_PARAM_START_PARAMS, JSONUtils.toJsonString(startParams)); } command.setCommandParam(JSONUtils.toJsonString(cmdParam)); command.setExecutorId(executorId); command.setWarningGroupId(warningGroupId); command.setProcessInstancePriority(processInstancePriority); command.setWorkerGroup(workerGroup); command.setEnvironmentCode(environmentCode); command.setDryRun(dryRun); command.setTestFlag(testFlag); ProcessDefinition processDefinition = processService.findProcessDefinitionByCode(processDefineCode); if (processDefinition != null) { command.setProcessDefinitionVersion(processDefinition.getVersion()); } command.setProcessInstanceId(0); // determine whether to complement if (commandType == CommandType.COMPLEMENT_DATA) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (schedule == null || StringUtils.isEmpty(schedule)) { logger.error("Create {} type command error because parameter schedule is invalid.", command.getCommandType().getDescp()); return 0; } if (!isValidateScheduleTime(schedule)) { return 0; } try { logger.info("Start to create {} command, processDefinitionCode:{}.", command.getCommandType().getDescp(), processDefineCode); return createComplementCommandList(triggerCode, schedule, runMode, command, expectedParallelismNumber, complementDependentMode); } catch (CronParseException cronParseException) { // We catch // cron expr return 0; } } else { command.setCommandParam(JSONUtils.toJsonString(cmdParam)); int count = commandService.createCommand(command); if (count > 0) { triggerRelationService.saveTriggerToDb(ApiTriggerType.COMMAND, triggerCode, command.getId()); } return count; } } /** * create complement command * close left and close right
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* * @param scheduleTimeParam * @param runMode * @return */ protected int createComplementCommandList(Long triggerCode, String scheduleTimeParam, RunMode runMode, Command command, Integer expectedParallelismNumber, ComplementDependentMode complementDependentMode) throws CronParseException { int createCount = 0; String startDate = null; String endDate = null; String dateList = null; int dependentProcessDefinitionCreateCount = 0; runMode = (runMode == null) ? RunMode.RUN_MODE_SERIAL : runMode; Map<String, String> cmdParam = JSONUtils.toMap(command.getCommandParam()); Map<String, String> scheduleParam = JSONUtils.toMap(scheduleTimeParam); if (scheduleParam.containsKey(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST)) { dateList = scheduleParam.get(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST); dateList = removeDuplicates(dateList); } if (scheduleParam.containsKey(CMD_PARAM_COMPLEMENT_DATA_START_DATE) && scheduleParam.containsKey( CMD_PARAM_COMPLEMENT_DATA_END_DATE)) { startDate = scheduleParam.get(CMD_PARAM_COMPLEMENT_DATA_START_DATE); endDate = scheduleParam.get(CMD_PARAM_COMPLEMENT_DATA_END_DATE); } switch (runMode) { case RUN_MODE_SERIAL: { logger.info("RunMode of {} command is serial run, processDefinitionCode:{}.", command.getCommandType().getDescp(), command.getProcessDefinitionCode());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (StringUtils.isNotEmpty(dateList)) { cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST, dateList); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); logger.info("Creating command, commandInfo:{}.", command); createCount = commandService.createCommand(command); if (createCount > 0) { logger.info("Create {} command complete, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } else { logger.error("Create {} command error, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } } if (startDate != null && endDate != null) { cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_START_DATE, startDate); cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_END_DATE, endDate); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); logger.info("Creating command, commandInfo:{}.", command); createCount = commandService.createCommand(command); if (createCount > 0) { logger.info("Create {} command complete, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } else { logger.error("Create {} command error, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } // dependent List<Schedule> schedules = processService.queryReleaseSchedulerListByProcessDefinitionCode( command.getProcessDefinitionCode()); if (schedules.isEmpty() || complementDependentMode == ComplementDependentMode.OFF_MODE) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
logger.info( "Complement dependent mode is off mode or Scheduler is empty, so skip create complement dependent command, processDefinitionCode:{}.", command.getProcessDefinitionCode()); } else { logger.info( "Complement dependent mode is all dependent and Scheduler is not empty, need create complement dependent command, processDefinitionCode:{}.", command.getProcessDefinitionCode()); dependentProcessDefinitionCreateCount += createComplementDependentCommand(schedules, command); } } if (createCount > 0) { triggerRelationService.saveTriggerToDb(ApiTriggerType.COMMAND, triggerCode, command.getId()); } break; } case RUN_MODE_PARALLEL: { logger.info("RunMode of {} command is parallel run, processDefinitionCode:{}.", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); if (startDate != null && endDate != null) { List<Schedule> schedules = processService.queryReleaseSchedulerListByProcessDefinitionCode( command.getProcessDefinitionCode()); List<ZonedDateTime> listDate = CronUtils.getSelfFireDateList( DateUtils.stringToZoneDateTime(startDate), DateUtils.stringToZoneDateTime(endDate), schedules); int listDateSize = listDate.size(); createCount = listDate.size(); if (!CollectionUtils.isEmpty(listDate)) { if (expectedParallelismNumber != null && expectedParallelismNumber != 0) { createCount = Math.min(createCount, expectedParallelismNumber);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} logger.info("Complement command run in parallel mode, current expectedParallelismNumber:{}.", createCount); // Distribut // The last int itemsPerCommand = (listDateSize / createCount); int remainingItems = (listDateSize % createCount); int startDateIndex = 0; int endDateIndex = 0; for (int i = 1; i <= createCount; i++) { int extra = (i <= remainingItems) ? 1 : 0; int singleCommandItems = (itemsPerCommand + extra); if (i == 1) { endDateIndex += singleCommandItems - 1; } else { startDateIndex = endDateIndex + 1; endDateIndex += singleCommandItems; } cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(listDate.get(startDateIndex))); cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(listDate.get(endDateIndex))); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); logger.info("Creating command, commandInfo:{}.", command); if (commandService.createCommand(command) > 0) { logger.info("Create {} command complete, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); triggerRelationService.saveTriggerToDb(ApiTriggerType.COMMAND, triggerCode, command.getId()); } else {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
logger.error("Create {} command error, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } if (schedules.isEmpty() || complementDependentMode == ComplementDependentMode.OFF_MODE) { logger.info( "Complement dependent mode is off mode or Scheduler is empty, so skip create complement dependent command, processDefinitionCode:{}.", command.getProcessDefinitionCode()); } else { logger.info( "Complement dependent mode is all dependent and Scheduler is not empty, need create complement dependent command, processDefinitionCode:{}.", command.getProcessDefinitionCode()); dependentProcessDefinitionCreateCount += createComplementDependentCommand(schedules, command); } } } } if (StringUtils.isNotEmpty(dateList)) { List<String> listDate = Arrays.asList(dateList.split(COMMA)); createCount = listDate.size(); if (!CollectionUtils.isEmpty(listDate)) { if (expectedParallelismNumber != null && expectedParallelismNumber != 0) { createCount = Math.min(createCount, expectedParallelismNumber); } logger.info("Complement command run in parallel mode, current expectedParallelismNumber:{}.", createCount); for (List<String> stringDate : Lists.partition(listDate, createCount)) { cmdParam.put(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST, String.join(COMMA, stringDate)); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); logger.info("Creating command, commandInfo:{}.", command);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (commandService.createCommand(command) > 0) { logger.info("Create {} command complete, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } else { logger.error("Create {} command error, processDefinitionCode:{}", command.getCommandType().getDescp(), command.getProcessDefinitionCode()); } } } } break; } default: break; } logger.info("Create complement command count:{}, Create dependent complement command count:{}", createCount, dependentProcessDefinitionCreateCount); return createCount; } /** * create complement dependent command */ public int createComplementDependentCommand(List<Schedule> schedules, Command command) { int dependentProcessDefinitionCreateCount = 0; Command dependentCommand; try { dependentCommand = (Command) BeanUtils.cloneBean(command); } catch (Exception e) { logger.error("Copy dependent command error.", e); return dependentProcessDefinitionCreateCount;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} List<DependentProcessDefinition> dependentProcessDefinitionList = getComplementDependentDefinitionList(dependentCommand.getProcessDefinitionCode(), CronUtils.getMaxCycle(schedules.get(0).getCrontab()), dependentCommand.getWorkerGroup()); dependentCommand.setT(T.TASK_POST); for (DependentProcessDefinition dependentProcessDefinition : dependentProcessDefinitionList) { // If the id // and causi dependentCommand.setId(null); dependentCommand.setProcessDefinitionCode(dependentProcessDefinition.getProcessDefinitionCode()); dependentCommand.setProcessDefinitionVersion(dependentProcessDefinition.getProcessDefinitionVersion()); dependentCommand.setWorkerGroup(dependentProcessDefinition.getWorkerGroup()); Map<String, String> cmdParam = JSONUtils.toMap(dependentCommand.getCommandParam()); cmdParam.put(CMD_PARAM_START_NODES, String.valueOf(dependentProcessDefinition.getTaskDefinitionCode())); dependentCommand.setCommandParam(JSONUtils.toJsonString(cmdParam)); logger.info("Creating complement dependent command, commandInfo:{}.", command); dependentProcessDefinitionCreateCount += commandService.createCommand(dependentCommand); } return dependentProcessDefinitionCreateCount; } /** * get complement dependent online list */ private List<DependentProcessDefinition> getComplementDependentDefinitionList(long processDefinitionCode, CycleEnum processDefinitionCycle, String workerGroup) { List<DependentProcessDefinition> dependentProcessDefinitionList = processService.queryDependentProcessDefinitionByProcessDefinitionCode(processDefinitionCode); return checkDependentProcessDefinitionValid(dependentProcessDefinitionList, processDefinitionCycle, workerGroup, processDefinitionCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} /** * Check whether the dependency cycle of the dependent node is consistent with the schedule cycle of * the dependent and if there is no worker group in the schedule, use the complement selection's * worker group */ private List<DependentProcessDefinition> checkDependentProcessDefinitionValid( List<DependentProcessDefinition> dependentProcessDefinitionList, CycleEnum processDefinitionCycle, String workerGroup, long upstreamProcessDefinitionCode) { List<DependentProcessDefinition> validDependentProcessDefinitionList = new ArrayList<>(); List<Long> processDefinitionCodeList = dependentProcessDefinitionList.stream().map(DependentProcessDefinition::getProcessDefinitionCode) .collect(Collectors.toList()); Map<Long, String> processDefinitionWorkerGroupMap = workerGroupService.queryWorkerGroupByProcessDefinitionCodes(processDefinitionCodeList); for (DependentProcessDefinition dependentProcessDefinition : dependentProcessDefinitionList) { if (dependentProcessDefinition.getDependentCycle(upstreamProcessDefinitionCode) == processDefinitionCycle) { if (processDefinitionWorkerGroupMap .get(dependentProcessDefinition.getProcessDefinitionCode()) == null) { dependentProcessDefinition.setWorkerGroup(workerGroup); } validDependentProcessDefinitionList.add(dependentProcessDefinition); } } return validDependentProcessDefinitionList; } /** * @param schedule
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @return check error return 0, otherwise 1 */ private boolean isValidateScheduleTime(String schedule) { Map<String, String> scheduleResult = JSONUtils.toMap(schedule); if (scheduleResult == null) { return false; } if (scheduleResult.containsKey(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST)) { if (scheduleResult.get(CMD_PARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST) == null) { return false; } } if (scheduleResult.containsKey(CMD_PARAM_COMPLEMENT_DATA_START_DATE)) { String startDate = scheduleResult.get(CMD_PARAM_COMPLEMENT_DATA_START_DATE); String endDate = scheduleResult.get(CMD_PARAM_COMPLEMENT_DATA_END_DATE); if (startDate == null || endDate == null) { return false; } try { ZonedDateTime start = DateUtils.stringToZoneDateTime(startDate); ZonedDateTime end = DateUtils.stringToZoneDateTime(endDate); if (start == null || end == null) { return false; } if (start.isAfter(end)) { logger.error( "Complement data parameter error, start time should be before end time, startDate:{}, endDate:{}.", start, end); return false; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} catch (Exception ex) { logger.warn("Parse schedule time error, startDate:{}, endDate:{}.", startDate, endDate); return false; } } return true; } /** * @param scheduleTimeList * @return remove duplicate date list */ private String removeDuplicates(String scheduleTimeList) { if (StringUtils.isNotEmpty(scheduleTimeList)) { Set<String> dateSet = Arrays.stream(scheduleTimeList.split(COMMA)).map(String::trim).collect(Collectors.toSet()); return String.join(COMMA, dateSet); } return null; } /** * query executing data of processInstance by master * @param processInstanceId * @return */ @Override public WorkflowExecuteDto queryExecutingWorkflowByProcessInstanceId(Integer processInstanceId) { ProcessInstance processInstance = processService.findProcessInstanceDetailById(processInstanceId).orElse(null); if (processInstance == null) { logger.error("Process instance does not exist, processInstanceId:{}.", processInstanceId); return null;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} Host host = new Host(processInstance.getHost()); WorkflowExecutingDataRequestCommand requestCommand = new WorkflowExecutingDataRequestCommand(); requestCommand.setProcessInstanceId(processInstanceId); org.apache.dolphinscheduler.remote.command.Command command = stateEventCallbackService.sendSync(host, requestCommand.convert2Command()); if (command == null) { logger.error("Query executing process instance from master error, processInstanceId:{}.", processInstanceId); return null; } WorkflowExecutingDataResponseCommand responseCommand = JSONUtils.parseObject(command.getBody(), WorkflowExecutingDataResponseCommand.class); return responseCommand.getWorkflowExecuteDto(); } @Override public Map<String, Object> execStreamTaskInstance(User loginUser, long projectCode, long taskDefinitionCode, int taskDefinitionVersion, int warningGroupId, String workerGroup, Long environmentCode, Map<String, String> startParams, int dryRun) { 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 (!checkMasterExists(result)) { return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,483
[Improvement][Api Server] Complement tasks are not executed in chronological order as entered
### 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 When manually entering the date to complete the task, the workflow instance is not generated and executed in the order of input ![补数](https://user-images.githubusercontent.com/20266837/216005574-2c0e1389-02bb-4c18-8cbd-3e8aa7e12701.png) ![补数2](https://user-images.githubusercontent.com/20266837/216005581-fb88eca8-d007-489b-a71e-dbbb527aac53.png) ### 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/13483
https://github.com/apache/dolphinscheduler/pull/13487
5a9cb7ee64783776ae6fa0865937d25234e0159a
19ffd64e23bdc27c7af50ef0c8518d81e0a0e15b
2023-02-01T09:35:47Z
java
2023-02-03T11:44:45Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} // todo dispatch improvement List<Server> masterServerList = monitorService.getServerListFromRegistry(true); Host host = new Host(masterServerList.get(0).getHost(), masterServerList.get(0).getPort()); TaskExecuteStartCommand taskExecuteStartCommand = new TaskExecuteStartCommand(); taskExecuteStartCommand.setExecutorId(loginUser.getId()); taskExecuteStartCommand.setExecutorName(loginUser.getUserName()); taskExecuteStartCommand.setProjectCode(projectCode); taskExecuteStartCommand.setTaskDefinitionCode(taskDefinitionCode); taskExecuteStartCommand.setTaskDefinitionVersion(taskDefinitionVersion); taskExecuteStartCommand.setWorkerGroup(workerGroup); taskExecuteStartCommand.setWarningGroupId(warningGroupId); taskExecuteStartCommand.setEnvironmentCode(environmentCode); taskExecuteStartCommand.setStartParams(startParams); taskExecuteStartCommand.setDryRun(dryRun); org.apache.dolphinscheduler.remote.command.Command response = stateEventCallbackService.sendSync(host, taskExecuteStartCommand.convert2Command()); if (response != null) { logger.info("Send task execute start command complete, response is {}.", response); putMsg(result, Status.SUCCESS); } else { logger.error( "Start to execute stream task instance error, projectCode:{}, taskDefinitionCode:{}, taskVersion:{}.", projectCode, taskDefinitionCode, taskDefinitionVersion); putMsg(result, Status.START_TASK_INSTANCE_ERROR); } return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.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.common.constants.Constants.ALIAS; import static org.apache.dolphinscheduler.common.constants.Constants.CONTENT; import static org.apache.dolphinscheduler.common.constants.Constants.FOLDER_SEPARATOR; import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_SS; import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_S_S; import static org.apache.dolphinscheduler.common.constants.Constants.JAR; import static org.apache.dolphinscheduler.common.constants.Constants.PERIOD;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
import org.apache.dolphinscheduler.api.dto.resources.DeleteDataTransferResponse; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter; import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor; import org.apache.dolphinscheduler.api.dto.resources.visitor.Visitor; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.ProcessDefinitionService; import org.apache.dolphinscheduler.api.service.ResourcesService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.RegexUtils; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.ProgramType; import org.apache.dolphinscheduler.common.enums.ResUploadType; import org.apache.dolphinscheduler.common.utils.FileUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.ResourcesTask; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UdfFunc; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
import org.apache.dolphinscheduler.dao.mapper.ResourceTaskMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity; import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate; import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import java.io.File; import java.io.IOException; import java.text.MessageFormat; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
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 org.springframework.web.multipart.MultipartFile; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.SerializationFeature; import com.google.common.base.Joiner; import com.google.common.io.Files; /** * resources service impl */ @Service public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesService { private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceImpl.class); @Autowired private ResourceMapper resourcesMapper; @Autowired private ResourceTaskMapper resourceTaskMapper; @Autowired private TaskDefinitionMapper taskDefinitionMapper; @Autowired private UdfFuncMapper udfFunctionMapper; @Autowired private ProcessService processService; @Autowired private ProcessDefinitionService processDefinitionService; @Autowired private TenantMapper tenantMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
@Autowired private UserMapper userMapper; @Autowired private ResourceUserMapper resourceUserMapper; @Autowired private ProcessDefinitionLogMapper processDefinitionLogMapper; @Autowired private ProcessTaskRelationMapper processTaskRelationMapper; @Autowired(required = false) private StorageOperate storageOperate; /** * create directory * * @param loginUser login user * @param name alias * @param description description * @param type type * @param pid parent id * @param currentDir current directory * @return create directory result */ @Override @Transactional public Result<Object> createDirectory(User loginUser, String name, String description, ResourceType type, int pid, String currentDir) { Result<Object> result = new Result<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } if (FileUtils.directoryTraversal(name)) { logger.warn("Parameter name is invalid, name:{}.", RegexUtils.escapeNRT(name)); putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return result; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return result; } String tenantCode = tenant.getTenantCode(); if (!isUserTenantValid(isAdmin(loginUser), tenantCode, "")) { logger.error("current user does not have permission"); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } if (checkDescriptionLength(description)) { logger.warn("Parameter description is too long."); putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } String userResRootPath = ResourceType.UDF.equals(type) ? storageOperate.getUdfDir(tenantCode) : storageOperate.getResDir(tenantCode); String fullName = !currentDir.contains(userResRootPath) ? userResRootPath + name : currentDir + name; try { if (checkResourceExists(fullName)) { logger.error("resource directory {} has exist, can't recreate", fullName); putMsg(result, Status.RESOURCE_EXIST); return result; } } catch (Exception e) { logger.warn("Resource exists, can not create again, fullName:{}.", fullName, e); throw new ServiceException("resource already exists, can't recreate"); } createDirectory(loginUser, fullName, type, result); return result; } private String getFullName(String currentDir, String name) { return currentDir.equals(FOLDER_SEPARATOR) ? String.format(FORMAT_SS, currentDir, name) : String.format(FORMAT_S_S, currentDir, name); } /** * create resource * * @param loginUser login user * @param name alias * @param desc description * @param type type
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param file file * @param currentDir current directory * @return create result code */ @Override @Transactional public Result<Object> createResource(User loginUser, String name, String desc, ResourceType type, MultipartFile file, String currentDir) { Result<Object> result = new Result<>(); result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return result; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return result; } String tenantCode = tenant.getTenantCode();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!isUserTenantValid(isAdmin(loginUser), tenantCode, "")) { logger.error("current user does not have permission"); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } result = verifyFile(name, type, file); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String userResRootPath = ResourceType.UDF.equals(type) ? storageOperate.getUdfDir(tenantCode) : storageOperate.getResDir(tenantCode); String currDirNFileName = !currentDir.contains(userResRootPath) ? userResRootPath + name : currentDir + name; try { if (checkResourceExists(currDirNFileName)) { logger.error("resource {} has exist, can't recreate", RegexUtils.escapeNRT(name)); putMsg(result, Status.RESOURCE_EXIST); return result; } } catch (Exception e) { throw new ServiceException("resource already exists, can't recreate"); } if (currDirNFileName.length() > Constants.RESOURCE_FULL_NAME_MAX_LENGTH) { logger.error( "Resource file's name is longer than max full name length, fullName:{}, " + "fullNameSize:{}, maxFullNameSize:{}", RegexUtils.escapeNRT(name), currDirNFileName.length(), Constants.RESOURCE_FULL_NAME_MAX_LENGTH); putMsg(result, Status.RESOURCE_FULL_NAME_TOO_LONG_ERROR); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!upload(loginUser, currDirNFileName, file, type)) { logger.error("upload resource: {} file: {} failed.", RegexUtils.escapeNRT(name), RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.STORE_OPERATE_CREATE_ERROR); throw new ServiceException( String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename())); } else logger.info("Upload resource file complete, resourceName:{}, fileName:{}.", RegexUtils.escapeNRT(name), RegexUtils.escapeNRT(file.getOriginalFilename())); return result; } /** * update the folder's size of the resource * * @param resource the current resource * @param size size */ private void updateParentResourceSize(Resource resource, long size) { if (resource.getSize() > 0) { String[] splits = resource.getFullName().split("/"); for (int i = 1; i < splits.length; i++) { String parentFullName = Joiner.on("/").join(Arrays.copyOfRange(splits, 0, i)); if (StringUtils.isNotBlank(parentFullName)) { List<Resource> resources = resourcesMapper.queryResource(parentFullName, resource.getType().ordinal()); if (CollectionUtils.isNotEmpty(resources)) { Resource parentResource = resources.get(0); if (parentResource.getSize() + size >= 0) { parentResource.setSize(parentResource.getSize() + size);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} else { parentResource.setSize(0L); } resourcesMapper.updateById(parentResource); logger.info("Resource size update complete, resourceFullName:{}, newSize:{}.", parentResource.getFullName(), parentResource.getSize()); } } } } } /** * check resource is exists * * @param fullName fullName * @return true if resource exists */ private boolean checkResourceExists(String fullName) { Boolean existResource = false; try { existResource = storageOperate.exists(fullName); } catch (IOException e) { logger.error("error occurred when checking resource: " + fullName, e); } return Boolean.TRUE.equals(existResource); } /** * update resource * * @param loginUser login user
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param resourceFullName resource full name * @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource, * can be different from the login user in the case of logging in as admin users. * @param name name * @param desc description * @param type resource type * @param file resource file * @return update result code */ @Override @Transactional public Result<Object> updateResource(User loginUser, String resourceFullName, String resTenantCode, String name, String desc, ResourceType type, MultipartFile file) { Result<Object> result = new Result<>(); result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return result; } Tenant tenant = tenantMapper.queryById(user.getTenantId());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return result; } String tenantCode = tenant.getTenantCode(); if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) { logger.error("current user does not have permission"); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } String defaultPath = storageOperate.getResDir(tenantCode); StorageEntity resource; try { resource = storageOperate.getFileStatus(resourceFullName, defaultPath, resTenantCode, type); } catch (Exception e) { logger.error("Get file status fail, resource path: {}", resourceFullName, e); putMsg(result, Status.RESOURCE_NOT_EXIST); throw new ServiceException((String.format("Get file status fail, resource path: %s", resourceFullName))); } if (!PropertyUtils.getResUploadStartupState()) { logger.error("Storage does not start up, resource upload startup state: {}.", PropertyUtils.getResUploadStartupState()); putMsg(result, Status.STORAGE_NOT_STARTUP); return result; } if (resource.isDirectory() && storageOperate.returnStorageType().equals(ResUploadType.S3) && !resource.getFileName().equals(name)) { logger.warn("Directory in S3 storage can not be renamed.");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result, Status.S3_CANNOT_RENAME); return result; } if (file == null && name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) { logger.info("Resource does not need to be updated due to no change, resource full name:{}.", resourceFullName); putMsg(result, Status.SUCCESS); return result; } String originFullName = resource.getFullName(); String originResourceName = resource.getAlias(); originFullName = originFullName.endsWith("/") ? StringUtils.chop(originFullName) : originFullName; name = name.endsWith("/") ? StringUtils.chop(name) : name; String fullName = String.format(FORMAT_SS, originFullName.substring(0, originFullName.lastIndexOf(FOLDER_SEPARATOR) + 1), name); if (!originResourceName.equals(name)) { try { if (checkResourceExists(fullName)) { logger.error("resource {} already exists, can't recreate", fullName); putMsg(result, Status.RESOURCE_EXIST); return result; } } catch (Exception e) { throw new ServiceException(String.format("error occurs while querying resource: %s", fullName)); } } result = verifyFile(name, type, file);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Date now = new Date(); long originFileSize = resource.getSize(); resource.setAlias(name); resource.setFileName(name); resource.setFullName(fullName); resource.setDescription(desc); resource.setUpdateTime(now); if (file != null) { resource.setSize(file.getSize()); } if (originResourceName.equals(name) && file == null) { return result; } List<ResourcesTask> existResourcesList; if (resource.isDirectory()) { existResourcesList = resourceTaskMapper.selectSubfoldersFullNames(originFullName + FOLDER_SEPARATOR); } else { existResourcesList = resourceTaskMapper.selectByMap( Collections.singletonMap("full_name", originFullName)); } if (existResourcesList.size() > 0 && !fullName.equals(originFullName)) { for (ResourcesTask existResource : existResourcesList) { int taskId = existResource.getTaskId(); if (processService.isTaskOnline(taskDefinitionMapper.selectById(taskId).getCode())) { logger.error("can't be updated,because it is used of process definition that's online");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.error("resource task relation id:{} is used of task code {}", existResource.getId(), taskDefinitionMapper.selectById(taskId).getCode()); putMsg(result, Status.RESOURCE_IS_USED); return result; } } for (ResourcesTask existResource : existResourcesList) { int taskId = existResource.getTaskId(); long taskCode = taskDefinitionMapper.selectById(taskId).getCode(); List<ProcessTaskRelation> processTaskRelation = processTaskRelationMapper.selectByMap( Collections.singletonMap("post_task_code", taskCode)); if (processTaskRelation.size() > 0) { long processDefinitionCode = processTaskRelation.get(0).getProcessDefinitionCode(); int processDefinitionVersion = processTaskRelation.get(0).getProcessDefinitionVersion(); List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryByProcessCode( processTaskRelation.get(0).getProjectCode(), processDefinitionCode); List<TaskDefinition> taskDefinitionLogList = new ArrayList<>(); if (taskRelationList.size() > 0) { ProcessDefinitionLog processDefinition = processDefinitionLogMapper.queryByDefinitionCodeAndVersion( processDefinitionCode, processDefinitionVersion); for (ProcessTaskRelation taskRelation : taskRelationList) { long taskCodeInProcess = taskRelation.getPostTaskCode(); TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCodeInProcess); if (taskCodeInProcess == taskCode) { taskDefinition.setTaskParams(RemoveResourceFromResourceList(originFullName, taskDefinition.getTaskParams(), resource.isDirectory()));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
taskDefinition.setTaskParams(AddResourceToResourceList(originFullName, fullName, existResource.getFullName(), taskDefinition.getTaskParams(), resource.isDirectory())); } taskDefinitionLogList.add(taskDefinition); } if (processDefinition != null) { processDefinitionService.updateProcessDefinition(loginUser, processDefinition.getProjectCode(), processDefinition.getName(), processDefinition.getCode(), processDefinition.getDescription(), processDefinition.getGlobalParams(), processDefinition.getLocations(), processDefinition.getTimeout(), tenantCode, JSONUtils.toJsonString(taskRelationList.toArray()), JSONUtils.toJsonString(taskDefinitionLogList.toArray()), "", processDefinition.getExecutionType()); } } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} if (file != null) { if (!upload(loginUser, fullName, file, type)) { logger.error("Storage operation error, resourceName:{}, originFileName:{}.", name, RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.HDFS_OPERATION_ERROR); throw new ServiceException( String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename())); } if (!fullName.equals(originFullName)) { try { storageOperate.delete(originFullName, false); } catch (IOException e) { logger.error("Resource delete error, resourceFullName:{}.", originFullName, e); throw new ServiceException(String.format("delete resource: %s failed.", originFullName)); } } return result; } String destHdfsFileName = fullName; try { logger.info("start copy {} -> {}", originFullName, destHdfsFileName); storageOperate.copy(originFullName, destHdfsFileName, true, true); } catch (Exception e) { logger.error(MessageFormat.format(" copy {0} -> {1} fail", originFullName, destHdfsFileName), e); putMsg(result, Status.HDFS_COPY_FAIL); throw new ServiceException(MessageFormat.format( Status.HDFS_COPY_FAIL.getMsg(), originFullName, destHdfsFileName));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} return result; } private Result<Object> verifyFile(String name, ResourceType type, MultipartFile file) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (FileUtils.directoryTraversal(name)) { logger.warn("Parameter file alias name verify failed, fileAliasName:{}.", RegexUtils.escapeNRT(name)); putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } if (file != null && FileUtils.directoryTraversal(Objects.requireNonNull(file.getOriginalFilename()))) { logger.warn("File original name verify failed, fileOriginalName:{}.", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } if (file != null) { if (file.isEmpty()) { logger.warn("Parameter file is empty, fileOriginalName:{}.", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_FILE_IS_EMPTY); return result; } String fileSuffix = Files.getFileExtension(file.getOriginalFilename()); String nameSuffix = Files.getFileExtension(name); if (!fileSuffix.equalsIgnoreCase(nameSuffix)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.warn("Rename file suffix and original suffix must be consistent, fileOriginalName:{}.", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE); return result; } if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) { logger.warn(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg()); putMsg(result, Status.UDF_RESOURCE_SUFFIX_NOT_JAR); return result; } if (file.getSize() > Constants.MAX_FILE_SIZE) { logger.warn( "Resource file size is larger than max file size, fileOriginalName:{}, fileSize:{}, maxFileSize:{}.", RegexUtils.escapeNRT(file.getOriginalFilename()), file.getSize(), Constants.MAX_FILE_SIZE); putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT); return result; } } return result; } /** * query resources list paging * * @param loginUser login user * @param fullName resource full name * @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource, * can be different from the login user in the case of logging in as admin users. * @param type resource type
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param searchVal search value * @param pageNo page number * @param pageSize page size * @return resource list page */ @Override public Result<PageInfo<StorageEntity>> queryResourceListPaging(User loginUser, String fullName, String resTenantCode, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) { Result<PageInfo<StorageEntity>> result = new Result<>(); PageInfo<StorageEntity> pageInfo = new PageInfo<>(pageNo, pageSize); if (storageOperate == null) { logger.warn("The resource storage is not opened."); return Result.success(pageInfo); } User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return result; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return result; } String tenantCode = tenant.getTenantCode(); if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.error("current user does not have permission"); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } String defaultPath = ""; List<StorageEntity> resourcesList = new ArrayList<>(); if (isAdmin(loginUser) && StringUtils.isBlank(fullName)) { List<User> userList = userMapper.selectList(null); Set<String> visitedTenantEntityCode = new HashSet<>(); for (User userEntity : userList) { String tenantEntityCode = tenantMapper.queryById(userEntity.getTenantId()).getTenantCode(); if (!visitedTenantEntityCode.contains(tenantEntityCode)) { defaultPath = storageOperate.getResDir(tenantEntityCode); if (type.equals(ResourceType.UDF)) { defaultPath = storageOperate.getUdfDir(tenantEntityCode); } try { resourcesList.addAll(storageOperate.listFilesStatus(defaultPath, defaultPath, tenantEntityCode, type)); visitedTenantEntityCode.add(tenantEntityCode); } catch (Exception e) { logger.error(e.getMessage() + " Resource path: {}", defaultPath, e); putMsg(result, Status.RESOURCE_NOT_EXIST); throw new ServiceException(String.format(e.getMessage() + " make sure resource path: %s exists in hdfs", defaultPath)); } } } } else {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
defaultPath = storageOperate.getResDir(tenantCode); if (type.equals(ResourceType.UDF)) { defaultPath = storageOperate.getUdfDir(tenantCode); } try { if (StringUtils.isBlank(fullName)) { resourcesList = storageOperate.listFilesStatus(defaultPath, defaultPath, tenantCode, type); } else { resourcesList = storageOperate.listFilesStatus(fullName, defaultPath, tenantCode, type); } } catch (Exception e) { logger.error(e.getMessage() + " Resource path: {}", fullName, e); putMsg(result, Status.RESOURCE_NOT_EXIST); throw new ServiceException(String.format(e.getMessage() + " make sure resource path: %s exists in hdfs", defaultPath)); } } String trimmedSearchVal = searchVal != null ? searchVal.trim() : ""; List<StorageEntity> filteredResourceList = resourcesList.stream() .filter(x -> x.getFileName().contains(trimmedSearchVal)).collect(Collectors.toList()); List<StorageEntity> slicedResourcesList = filteredResourceList.stream().skip((long) (pageNo - 1) * pageSize) .limit(pageSize).collect(Collectors.toList()); pageInfo.setTotal(resourcesList.size()); pageInfo.setTotalList(slicedResourcesList); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} /** * create directory * xxx The steps to verify resources are cumbersome and can be optimized * * @param loginUser login user * @param fullName full name * @param type resource type * @param result Result */ private void createDirectory(User loginUser, String fullName, ResourceType type, Result<Object> result) { String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String resourceRootPath = storageOperate.getDir(type, tenantCode); try { if (!storageOperate.exists(resourceRootPath)) { storageOperate.createTenantDirIfNotExists(tenantCode); } if (!storageOperate.mkdir(tenantCode, fullName)) { logger.error("create resource directory {} failed", fullName); putMsg(result, Status.STORE_OPERATE_CREATE_ERROR); } } catch (Exception e) { logger.error("create resource directory {} failed", fullName); putMsg(result, Status.STORE_OPERATE_CREATE_ERROR); throw new ServiceException(String.format("create resource directory: %s failed.", fullName)); } } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* upload file to hdfs * * @param loginUser login user * @param fullName full name * @param file file * @param type resource type * @return upload success return true, otherwise false */ private boolean upload(User loginUser, String fullName, MultipartFile file, ResourceType type) { String fileSuffix = Files.getFileExtension(file.getOriginalFilename()); String nameSuffix = Files.getFileExtension(fullName); if (!fileSuffix.equalsIgnoreCase(nameSuffix)) { return false; } String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); String resourcePath = storageOperate.getDir(type, tenantCode); try { if (!storageOperate.exists(resourcePath)) { storageOperate.createTenantDirIfNotExists(tenantCode); } org.apache.dolphinscheduler.api.utils.FileUtils.copyInputStreamToFile(file, localFilename); storageOperate.upload(tenantCode, localFilename, fullName, true, true); } catch (Exception e) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
FileUtils.deleteFile(localFilename); logger.error(e.getMessage(), e); return false; } return true; } /** * query resource list * * @param loginUser login user * @param type resource type * @param fullName resource full name * @return resource list */ @Override public Map<String, Object> queryResourceList(User loginUser, ResourceType type, String fullName) { Map<String, Object> result = new HashMap<>(); if (storageOperate == null) { result.put(Constants.DATA_LIST, Collections.emptyList()); result.put(Constants.STATUS, Status.SUCCESS); return result; } User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return null; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return null; } String tenantCode = tenant.getTenantCode(); String defaultPath = ""; List<StorageEntity> resourcesList = new ArrayList<>(); if (StringUtils.isBlank(fullName)) { if (isAdmin(loginUser)) { List<User> userList = userMapper.selectList(null); Set<String> visitedTenantEntityCode = new HashSet<>(); for (User userEntity : userList) { Tenant tt = tenantMapper.queryById(userEntity.getTenantId()); String tenantEntityCode = tenantMapper.queryById(userEntity.getTenantId()).getTenantCode(); if (!visitedTenantEntityCode.contains(tenantEntityCode)) { defaultPath = storageOperate.getResDir(tenantEntityCode); if (type.equals(ResourceType.UDF)) { defaultPath = storageOperate.getUdfDir(tenantEntityCode); } resourcesList.addAll(storageOperate.listFilesStatusRecursively(defaultPath, defaultPath, tenantEntityCode, type)); visitedTenantEntityCode.add(tenantEntityCode); } } } else { defaultPath = storageOperate.getResDir(tenantCode); if (type.equals(ResourceType.UDF)) { defaultPath = storageOperate.getUdfDir(tenantCode); } resourcesList = storageOperate.listFilesStatusRecursively(defaultPath, defaultPath, tenantCode, type);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} } else { defaultPath = storageOperate.getResDir(tenantCode); if (type.equals(ResourceType.UDF)) { defaultPath = storageOperate.getUdfDir(tenantCode); } resourcesList = storageOperate.listFilesStatusRecursively(fullName, defaultPath, tenantCode, type); } Visitor resourceTreeVisitor = new ResourceTreeVisitor(resourcesList); result.put(Constants.DATA_LIST, resourceTreeVisitor.visit(defaultPath).getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * query resource list by program type * * @param loginUser login user * @param type resource type * @return resource list */ @Override public Result<Object> queryResourceByProgramType(User loginUser, ResourceType type, ProgramType programType) { Result<Object> result = new Result<>(); Set<Integer> resourceIds = resourcePermissionCheckService .userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger); if (resourceIds.isEmpty()) { result.setData(Collections.emptyList()); putMsg(result, Status.SUCCESS); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
List<Resource> allResourceList = resourcesMapper.selectBatchIds(resourceIds); String suffix = ".jar"; if (programType != null) { switch (programType) { case JAVA: case SCALA: break; case PYTHON: suffix = ".py"; break; default: } } List<Resource> resources = new ResourceFilter(suffix, new ArrayList<>(allResourceList)).filter(); List<StorageEntity> transformedResourceList = resources.stream() .map(this::createStorageEntityBasedOnResource) .collect(Collectors.toList()); Visitor visitor = new ResourceTreeVisitor(transformedResourceList); result.setData(visitor.visit("").getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * transform resource object into StorageEntity object * * @param resource a resource object * @return a storageEntity object */ private StorageEntity createStorageEntityBasedOnResource(Resource resource) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
StorageEntity entity = new StorageEntity(); entity.setFullName(resource.getFullName()); entity.setPfullName(resource.getPid() == -1 ? "" : resourcesMapper.selectById(resource.getPid()).getFullName()); entity.setDirectory(resource.isDirectory()); entity.setAlias(resource.getAlias()); entity.setId(resource.getId()); entity.setType(resource.getType()); entity.setDescription(resource.getDescription()); return entity; } /** * delete resource * * @param loginUser login user * @param fullName resource full name * @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource, * can be different from the login user in the case of logging in as admin users. * @return delete result code * @throws IOException exception */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> delete(User loginUser, String fullName, String resTenantCode) throws IOException { Result<Object> result = new Result<>(); result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return result; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return result; } String tenantCode = tenant.getTenantCode(); if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) { logger.error("current user does not have permission"); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } String defaultPath = storageOperate.getResDir(tenantCode); StorageEntity resource; try { resource = storageOperate.getFileStatus(fullName, defaultPath, resTenantCode, null); } catch (Exception e) { logger.error(e.getMessage() + " Resource path: {}", fullName, e); putMsg(result, Status.RESOURCE_NOT_EXIST); throw new ServiceException(String.format(e.getMessage() + " Resource path: %s", fullName)); } if (resource == null) { logger.error("Resource does not exist, resource full name:{}.", fullName); putMsg(result, Status.RESOURCE_NOT_EXIST);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } List<String> allChildren = storageOperate.listFilesStatusRecursively(fullName, defaultPath, resTenantCode, resource.getType()).stream().map(storageEntity -> storageEntity.getFullName()) .collect(Collectors.toList()); Set<ResourcesTask> resourcesNeedToDeleteSet = new HashSet<>(); String[] allChildrenFullNameArray = allChildren.stream().toArray(String[]::new); if (allChildrenFullNameArray.length != 0) { resourcesNeedToDeleteSet.addAll( resourceTaskMapper.selectBatchFullNames(allChildrenFullNameArray)); } if (resource.getType() == (ResourceType.UDF)) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceFullName(allChildrenFullNameArray); if (CollectionUtils.isNotEmpty(udfFuncs)) { logger.warn("Resource can not be deleted because it is bound by UDF functions, udfFuncIds:{}", udfFuncs); putMsg(result, Status.UDF_RESOURCE_IS_BOUND, udfFuncs.get(0).getFuncName()); return result; } } if (resourcesNeedToDeleteSet.size() > 0) { for (ResourcesTask resourcesTask : resourcesNeedToDeleteSet) { int taskId = resourcesTask.getTaskId(); if (processService.isTaskOnline(taskDefinitionMapper.selectById(taskId).getCode())) { logger.error("can't be deleted,because it is used of process definition that's online"); logger.error("resource task relation id:{} is used of task code {}", resourcesTask.getId(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
taskDefinitionMapper.selectById(taskId).getCode()); putMsg(result, Status.RESOURCE_IS_USED); return result; } } for (ResourcesTask existResource : resourcesNeedToDeleteSet) { int taskId = existResource.getTaskId(); long taskCode = taskDefinitionMapper.selectById(taskId).getCode(); List<ProcessTaskRelation> processTaskRelation = processTaskRelationMapper.selectByMap( Collections.singletonMap("post_task_code", taskCode)); if (processTaskRelation.size() > 0) { long processDefinitionCode = processTaskRelation.get(0).getProcessDefinitionCode(); int processDefinitionVersion = processTaskRelation.get(0).getProcessDefinitionVersion(); List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryByProcessCode( processTaskRelation.get(0).getProjectCode(), processDefinitionCode); List<TaskDefinition> taskDefinitionLogList = new ArrayList<>(); if (taskRelationList.size() > 0) { ProcessDefinitionLog processDefinition = processDefinitionLogMapper.queryByDefinitionCodeAndVersion( processDefinitionCode, processDefinitionVersion); for (ProcessTaskRelation taskRelation : taskRelationList) { long taskCodeInProcess = taskRelation.getPostTaskCode(); TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCodeInProcess); if (taskCodeInProcess == taskCode) { taskDefinition.setTaskParams(RemoveResourceFromResourceList(existResource.getFullName(), taskDefinition.getTaskParams(), false)); } taskDefinitionLogList.add(taskDefinition);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} if (processDefinition != null) { processDefinitionService.updateProcessDefinition(loginUser, processDefinition.getProjectCode(), processDefinition.getName(), processDefinition.getCode(), processDefinition.getDescription(), processDefinition.getGlobalParams(), processDefinition.getLocations(), processDefinition.getTimeout(), tenantCode, JSONUtils.toJsonString(taskRelationList.toArray()), JSONUtils.toJsonString(taskDefinitionLogList.toArray()), "", processDefinition.getExecutionType()); } } } } } storageOperate.delete(fullName, allChildren, true); putMsg(result, Status.SUCCESS); return result; } private String RemoveResourceFromResourceList(String stringToDelete, String taskParameter, boolean isDir) { Map<String, Object> taskParameters = JSONUtils.parseObject( taskParameter, new TypeReference<Map<String, Object>>() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
}); if (taskParameters.containsKey("resourceList")) { String resourceListStr = JSONUtils.toJsonString(taskParameters.get("resourceList")); List<ResourceInfo> resourceInfoList = JSONUtils.toList(resourceListStr, ResourceInfo.class); List<ResourceInfo> updatedResourceInfoList; if (isDir) { String stringToDeleteWSeparator = stringToDelete + FOLDER_SEPARATOR; updatedResourceInfoList = resourceInfoList.stream() .filter(Objects::nonNull) .filter(resourceInfo -> !resourceInfo.getResourceName().startsWith(stringToDeleteWSeparator)) .collect(Collectors.toList()); } else { updatedResourceInfoList = resourceInfoList.stream() .filter(Objects::nonNull) .filter(resourceInfo -> !resourceInfo.getResourceName().equals(stringToDelete)) .collect(Collectors.toList()); } taskParameters.put("resourceList", updatedResourceInfoList); return JSONUtils.toJsonString(taskParameters); } return taskParameter; } private String AddResourceToResourceList(String oldPrefix, String newPrefix, String resFullName, String taskParameter, boolean isDir) { Map<String, Object> taskParameters = JSONUtils.parseObject( taskParameter, new TypeReference<Map<String, Object>>() { }); if (taskParameters.containsKey("resourceList")) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String resourceListStr = JSONUtils.toJsonString(taskParameters.get("resourceList")); List<ResourceInfo> resourceInfos = JSONUtils.toList(resourceListStr, ResourceInfo.class); ResourceInfo newResource = new ResourceInfo(); if (isDir) { String oldFullNameWSeparator = oldPrefix + FOLDER_SEPARATOR; String newFullNameWSpearator = newPrefix + FOLDER_SEPARATOR; newResource.setResourceName(resFullName.replace(oldFullNameWSeparator, newFullNameWSpearator)); } else { newResource.setResourceName(newPrefix); } resourceInfos.add(newResource); taskParameters.put("resourceList", resourceInfos); return JSONUtils.toJsonString(taskParameters); } return taskParameter; } private String RemoveResourceFromIdsNew(int idToDelete, String idNews) { String[] resourceIds = idNews.split(","); Set<Integer> resourceIdSet = Arrays.stream(resourceIds) .map(Integer::parseInt) .filter(integerId -> !integerId.equals(idToDelete)) .collect(Collectors.toSet()); return Joiner.on(",").join(resourceIdSet); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* verify resource by name and type * * @param loginUser login user * @param fullName resource full name * @param type resource type * @return true if the resource name not exists, otherwise return false */ @Override public Result<Object> verifyResourceName(String fullName, ResourceType type, User loginUser) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (checkResourceExists(fullName)) { logger.error("Resource with same name exists so can not create again, resourceType:{}, resourceName:{}.", type, RegexUtils.escapeNRT(fullName)); putMsg(result, Status.RESOURCE_EXIST); } return result; } /** * verify resource by full name or pid and type * * @param fileName resource file name * @param type resource type * @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource, * can be different from the login user in the case of logging in as admin users. * @return true if the resource full name or pid not exists, otherwise return false */ @Override public Result<Object> queryResourceByFileName(User loginUser, String fileName, ResourceType type, String resTenantCode) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Result<Object> result = new Result<>(); if (StringUtils.isBlank(fileName)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR); return result; } User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return result; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return result; } String tenantCode = tenant.getTenantCode(); if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) { logger.error("current user does not have permission"); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } String defaultPath = storageOperate.getResDir(resTenantCode); if (type.equals(ResourceType.UDF)) { defaultPath = storageOperate.getUdfDir(resTenantCode); } StorageEntity file; try { file = storageOperate.getFileStatus(defaultPath + fileName, defaultPath, resTenantCode, type);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} catch (Exception e) { logger.error(e.getMessage() + " Resource path: {}", defaultPath + fileName, e); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } putMsg(result, Status.SUCCESS); result.setData(file); return result; } /** * get resource by id * @param fullName resource full name * @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource, * can be different from the login user in the case of logging in as admin users. * @return resource */ @Override public Result<Object> queryResourceByFullName(User loginUser, String fullName, String resTenantCode, ResourceType type) throws IOException { Result<Object> result = new Result<>(); User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return result; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } String tenantCode = tenant.getTenantCode(); if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) { logger.error("current user does not have permission"); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } String defaultPath = storageOperate.getResDir(resTenantCode); if (type.equals(ResourceType.UDF)) { defaultPath = storageOperate.getUdfDir(resTenantCode); } StorageEntity file; try { file = storageOperate.getFileStatus(fullName, defaultPath, resTenantCode, type); } catch (Exception e) { logger.error(e.getMessage() + " Resource path: {}", fullName, e); putMsg(result, Status.RESOURCE_NOT_EXIST); throw new ServiceException(String.format(e.getMessage() + " Resource path: %s", fullName)); } putMsg(result, Status.SUCCESS); result.setData(file); return result; } /** * view resource file online * * @param fullName resource fullName * @param resTenantCode owner's tenant code of the resource * @param skipLineNum skip line number
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param limit limit * @return resource content */ @Override public Result<Object> readResource(User loginUser, String fullName, String resTenantCode, int skipLineNum, int limit) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return result; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return result; } String tenantCode = tenant.getTenantCode(); if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) { logger.error("current user does not have permission"); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } String nameSuffix = Files.getFileExtension(fullName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String resourceViewSuffixes = FileUtils.getResourceViewSuffixes(); if (StringUtils.isNotEmpty(resourceViewSuffixes)) { List<String> strList = Arrays.asList(resourceViewSuffixes.split(",")); if (!strList.contains(nameSuffix)) { logger.error("Resource suffix does not support view,resourceFullName:{}, suffix:{}.", fullName, nameSuffix); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } List<String> content = new ArrayList<>(); try { if (storageOperate.exists(fullName)) { content = storageOperate.vimFile(tenantCode, fullName, skipLineNum, limit); } else { logger.error("read file {} not exist in storage", fullName); putMsg(result, Status.RESOURCE_FILE_NOT_EXIST, fullName); return result; } } catch (Exception e) { logger.error("Resource {} read failed", fullName, e); putMsg(result, Status.HDFS_OPERATION_ERROR); return result; } putMsg(result, Status.SUCCESS); Map<String, Object> map = new HashMap<>(); map.put(ALIAS, fullName); map.put(CONTENT, String.join("\n", content)); result.setData(map); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} /** * create resource file online * * @param loginUser login user * @param type resource type * @param fileName file name * @param fileSuffix file suffix * @param desc description * @param content content * @param currentDir current directory * @return create result code */ @Override @Transactional public Result<Object> onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content, String currentDir) { Result<Object> result = new Result<>(); result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return result; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return result; } String tenantCode = tenant.getTenantCode(); if (!isUserTenantValid(isAdmin(loginUser), tenantCode, "")) { logger.error("current user does not have permission"); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } if (FileUtils.directoryTraversal(fileName)) { logger.warn("File name verify failed, fileName:{}.", RegexUtils.escapeNRT(fileName)); putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } String nameSuffix = fileSuffix.trim(); String resourceViewSuffixes = FileUtils.getResourceViewSuffixes(); if (StringUtils.isNotEmpty(resourceViewSuffixes)) { List<String> strList = Arrays.asList(resourceViewSuffixes.split(",")); if (!strList.contains(nameSuffix)) { logger.warn("Resource suffix does not support view, suffix:{}.", nameSuffix); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String name = fileName.trim() + "." + nameSuffix; String fullName = ""; String userResRootPath = storageOperate.getResDir(tenantCode); if (!currentDir.contains(userResRootPath)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
fullName = userResRootPath + name; } else { fullName = currentDir + name; } result = verifyResourceName(fullName, type, loginUser); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } result = uploadContentToStorage(loginUser, fullName, tenantCode, content); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg()); } return result; } @Override @Transactional public StorageEntity createOrUpdateResource(String userName, String filepath, String resourceContent) throws Exception { User user = userMapper.queryByUserNameAccurately(userName); int suffixLabelIndex = filepath.indexOf(PERIOD); if (suffixLabelIndex == -1) { throw new IllegalArgumentException(String .format("Not allow create or update resources without extension name, filepath: %s", filepath)); } String defaultPath = storageOperate.getResDir(user.getTenantCode()); String fullName = defaultPath + filepath; Result<Object> result = uploadContentToStorage(user, fullName, user.getTenantCode(), resourceContent); if (result.getCode() != Status.SUCCESS.getCode()) { throw new ServiceException(result.getMsg()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return storageOperate.getFileStatus(fullName, defaultPath, user.getTenantCode(), ResourceType.FILE); } private void permissionPostHandle(ResourceType resourceType, User loginUser, Integer resourceId) { AuthorizationType authorizationType = resourceType.equals(ResourceType.FILE) ? AuthorizationType.RESOURCE_FILE_ID : AuthorizationType.UDF_FILE; permissionPostHandle(authorizationType, loginUser.getId(), Collections.singletonList(resourceId), logger); } private Result<Object> checkResourceUploadStartupState() { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (!PropertyUtils.getResUploadStartupState()) { logger.error("Storage does not start up, resource upload startup state: {}.", PropertyUtils.getResUploadStartupState()); putMsg(result, Status.STORAGE_NOT_STARTUP); return result; } return result; } private Result<Object> verifyResource(User loginUser, ResourceType type, String fullName, int pid) { Result<Object> result = verifyResourceName(fullName, type, loginUser); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } return verifyPid(loginUser, pid); } private Result<Object> verifyPid(User loginUser, int pid) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (pid != -1) { Resource parentResource = resourcesMapper.selectById(pid); if (parentResource == null) { logger.error("Parent resource does not exist, parentResourceId:{}.", pid); putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST); return result; } if (!canOperator(loginUser, parentResource.getUserId())) { logger.warn("User does not have operation privilege, loginUserName:{}.", loginUser.getUserName()); putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } } return result; } /** * updateProcessInstance resource * * @param fullName resource full name * @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource, * can be different from the login user in the case of logging in as admin users. * @param content content * @return update result cod */ @Override @Transactional public Result<Object> updateResourceContent(User loginUser, String fullName, String resTenantCode, String content) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return result; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return result; } String tenantCode = tenant.getTenantCode(); if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) { logger.error("current user does not have permission"); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } StorageEntity resource; try { resource = storageOperate.getFileStatus(fullName, "", resTenantCode, ResourceType.FILE); } catch (Exception e) { logger.error("error occurred when fetching resource information , resource full name {}", fullName); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (resource == null) { logger.error("Resource does not exist, resource full name:{}.", fullName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String nameSuffix = Files.getFileExtension(resource.getAlias()); String resourceViewSuffixes = FileUtils.getResourceViewSuffixes(); if (StringUtils.isNotEmpty(resourceViewSuffixes)) { List<String> strList = Arrays.asList(resourceViewSuffixes.split(",")); if (!strList.contains(nameSuffix)) { logger.warn("Resource suffix does not support view, resource full name:{}, suffix:{}.", fullName, nameSuffix); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } result = uploadContentToStorage(loginUser, resource.getFullName(), resTenantCode, content); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg()); } else logger.info("Update resource content complete, resource full name:{}.", fullName); return result; } /** * @param fullName resource full name * @param tenantCode tenant code * @param content content * @return result */ private Result<Object> uploadContentToStorage(User loginUser, String fullName, String tenantCode, String content) { Result<Object> result = new Result<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String localFilename = ""; try { localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); if (!FileUtils.writeContent2File(content, localFilename)) { logger.error("Write file error, fileName:{}, content:{}.", localFilename, RegexUtils.escapeNRT(content)); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String resourcePath = storageOperate.getResDir(tenantCode); logger.info("resource path is {}, resource dir is {}", fullName, resourcePath); if (!storageOperate.exists(resourcePath)) { storageOperate.createTenantDirIfNotExists(tenantCode); logger.info("Create tenant dir because path {} does not exist, tenantCode:{}.", resourcePath, tenantCode); } if (storageOperate.exists(fullName)) { storageOperate.delete(fullName, false); } storageOperate.upload(tenantCode, localFilename, fullName, true, true); } catch (Exception e) { logger.error("Upload content to storage error, tenantCode:{}, destFileName:{}.", tenantCode, localFilename, e); result.setCode(Status.HDFS_OPERATION_ERROR.getCode()); result.setMsg(String.format("copy %s to hdfs %s fail", localFilename, fullName)); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.info("Upload content to storage complete, tenantCode:{}, destFileName:{}.", tenantCode, localFilename); putMsg(result, Status.SUCCESS); return result; } /** * download file * @return resource content * @throws IOException exception */ @Override public org.springframework.core.io.Resource downloadResource(User loginUser, String fullName) throws IOException { if (!PropertyUtils.getResUploadStartupState()) { logger.warn("Storage does not start up, resource upload startup state: {}.", PropertyUtils.getResUploadStartupState()); throw new ServiceException("hdfs not startup"); } if (fullName.endsWith("/")) { logger.error("resource id {} is directory,can't download it", fullName); throw new ServiceException("can't download directory"); } int userId = loginUser.getId(); User user = userMapper.selectById(userId); if (user == null) { logger.error("User does not exits, userId:{}.", userId); throw new ServiceException(String.format("Resource owner id %d does not exist", userId)); } String tenantCode = ""; if (user.getTenantId() != 0) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("Tenant id {} not exists", user.getTenantId()); throw new ServiceException( String.format("The tenant id %d of resource owner not exist", user.getTenantId())); } tenantCode = tenant.getTenantCode(); } String[] aliasArr = fullName.split("/"); String alias = aliasArr[aliasArr.length - 1]; String localFileName = FileUtils.getDownloadFilename(alias); logger.info("Resource path is {}, download local filename is {}", alias, localFileName); try { storageOperate.download(tenantCode, fullName, localFileName, false, true); return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName); } catch (IOException e) { logger.error("Download resource error, the path is {}, and local filename is {}, the error message is {}", fullName, localFileName, e.getMessage()); throw new ServiceException("Download the resource file failed ,it may be related to your storage"); } } /** * list all file * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Map<String, Object> result = new HashMap<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } List<Resource> resourceList; if (isAdmin(loginUser)) { resourceList = resourcesMapper.queryResourceExceptUserId(userId); } else { resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1); } List<ResourceComponent> list; if (CollectionUtils.isNotEmpty(resourceList)) { List<StorageEntity> transformedResourceList = resourceList.stream() .map(this::createStorageEntityBasedOnResource) .collect(Collectors.toList()); Visitor visitor = new ResourceTreeVisitor(transformedResourceList); list = visitor.visit("").getChildren(); } else { list = new ArrayList<>(0); } result.put(Constants.DATA_LIST, list); putMsg(result, Status.SUCCESS); return result; } @Override public StorageEntity queryFileStatus(String userName, String fileName) throws Exception {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
User user = userMapper.queryByUserNameAccurately(userName); String defaultPath = storageOperate.getResDir(user.getTenantCode()); return storageOperate.getFileStatus(defaultPath + fileName, defaultPath, user.getTenantCode(), ResourceType.FILE); } @Override public DeleteDataTransferResponse deleteDataTransferData(User loginUser, Integer days) { DeleteDataTransferResponse result = new DeleteDataTransferResponse(); User user = userMapper.selectById(loginUser.getId()); if (user == null) { logger.error("user {} not exists", loginUser.getId()); putMsg(result, Status.USER_NOT_EXIST, loginUser.getId()); return result; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return result; } String tenantCode = tenant.getTenantCode(); String baseFolder = storageOperate.getResourceFileName(tenantCode, "DATA_TRANSFER"); LocalDateTime now = LocalDateTime.now(); now = now.minus(days, ChronoUnit.DAYS); String deleteDate = now.toLocalDate().toString().replace("-", ""); List<StorageEntity> storageEntities; try { storageEntities = new ArrayList<>( storageOperate.listFilesStatus(baseFolder, baseFolder, tenantCode, ResourceType.FILE));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} catch (Exception e) { logger.error("delete data transfer data error", e); putMsg(result, Status.DELETE_RESOURCE_ERROR); return result; } List<String> successList = new ArrayList<>(); List<String> failList = new ArrayList<>(); for (StorageEntity storageEntity : storageEntities) { File path = new File(storageEntity.getFullName()); String date = path.getName(); if (date.compareTo(deleteDate) <= 0) { try { storageOperate.delete(storageEntity.getFullName(), true); successList.add(storageEntity.getFullName()); } catch (Exception ex) { logger.error("delete data transfer data {} error, please delete it manually", date, ex); failList.add(storageEntity.getFullName()); } } } result.setSuccessList(successList); result.setFailedList(failList); putMsg(result, Status.SUCCESS); return result; } /** * unauthorized file * * @param loginUser login user * @param userId user id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @return unauthorized result code */ @Override public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); List<Resource> resourceList; if (isAdmin(loginUser)) { resourceList = resourcesMapper.queryResourceExceptUserId(userId); } else { resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1); } List<Resource> list; if (resourceList != null && !resourceList.isEmpty()) { Set<Resource> resourceSet = new HashSet<>(resourceList); List<Resource> authedResourceList = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); getAuthorizedResourceList(resourceSet, authedResourceList); list = new ArrayList<>(resourceSet); } else { list = new ArrayList<>(0); } List<StorageEntity> transformedResourceList = list.stream() .map(this::createStorageEntityBasedOnResource) .collect(Collectors.toList()); Visitor visitor = new ResourceTreeVisitor(transformedResourceList); result.put(Constants.DATA_LIST, visitor.visit("").getChildren()); putMsg(result, Status.SUCCESS); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} /** * unauthorized udf function * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } List<UdfFunc> udfFuncList; if (isAdmin(loginUser)) { udfFuncList = udfFunctionMapper.queryUdfFuncExceptUserId(userId); } else { udfFuncList = udfFunctionMapper.selectByMap(Collections.singletonMap("user_id", loginUser.getId())); } List<UdfFunc> resultList = new ArrayList<>(); Set<UdfFunc> udfFuncSet; if (CollectionUtils.isNotEmpty(udfFuncList)) { udfFuncSet = new HashSet<>(udfFuncList); List<UdfFunc> authedUDFFuncList = udfFunctionMapper.queryAuthedUdfFunc(userId); getAuthorizedResourceList(udfFuncSet, authedUDFFuncList); resultList = new ArrayList<>(udfFuncSet);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} result.put(Constants.DATA_LIST, resultList); putMsg(result, Status.SUCCESS); return result; } /** * authorized udf function * * @param loginUser login user * @param userId user id * @return authorized result code */ @Override public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId); result.put(Constants.DATA_LIST, udfFuncs); putMsg(result, Status.SUCCESS); return result; } /** * authorized file * * @param loginUser login user * @param userId user id * @return authorized result
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
*/ @Override public Map<String, Object> authorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } List<Resource> authedResources = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); List<StorageEntity> transformedResourceList = authedResources.stream() .map(this::createStorageEntityBasedOnResource) .collect(Collectors.toList()); Visitor visitor = new ResourceTreeVisitor(transformedResourceList); String visit = JSONUtils.toJsonString(visitor.visit(""), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(visit); String jsonTreeStr = JSONUtils.toJsonString(visitor.visit("").getChildren(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(jsonTreeStr); result.put(Constants.DATA_LIST, visitor.visit("").getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * get authorized resource list * * @param resourceSet resource set * @param authedResourceList authorized resource list */ private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Set<?> authedResourceSet; if (CollectionUtils.isNotEmpty(authedResourceList)) { authedResourceSet = new HashSet<>(authedResourceList); resourceSet.removeAll(authedResourceSet); } } /** * list all children id * * @param resource resource * @param containSelf whether add self to children list * @return all children id */ List<Integer> listAllChildren(Resource resource, boolean containSelf) { List<Integer> childList = new ArrayList<>(); if (resource.getId() != null && containSelf) { childList.add(resource.getId()); } if (resource.isDirectory()) { listAllChildren(resource.getId(), childList); } return childList; } /** * list all children id * * @param resourceId resource id * @param childList child list */ void listAllChildren(int resourceId, List<Integer> childList) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
List<Integer> children = resourcesMapper.listChildren(resourceId); for (int childId : children) { childList.add(childId); listAllChildren(childId, childList); } } /** * query authored resource list (own and authorized) * * @param loginUser login user * @param type ResourceType * @return all authored resource list */ private List<Resource> queryAuthoredResourceList(User loginUser, ResourceType type) { Set<Integer> resourceIds = resourcePermissionCheckService .userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger); if (resourceIds.isEmpty()) { return Collections.emptyList(); } List<Resource> resources = resourcesMapper.selectBatchIds(resourceIds); resources = resources.stream().filter(rs -> rs.getType() == type).collect(Collectors.toList()); return resources; } /** * query resource list by userId and perm * * @param userId userId * @param perm perm * @return resource list */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
private List<Resource> queryResourceList(Integer userId, int perm) { List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, perm); return CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourcesMapper.queryResourceListById(resIds); } private AuthorizationType checkResourceType(ResourceType type) { return type.equals(ResourceType.FILE) ? AuthorizationType.RESOURCE_FILE_ID : AuthorizationType.UDF_FILE; } /** * check permission by comparing login user's tenantCode with tenantCode in the request * * @param isAdmin is the login user admin * @param userTenantCode loginUser's tenantCode * @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource, * can be different from the login user in the case of logging in as admin users. * @return isValid */ private boolean isUserTenantValid(boolean isAdmin, String userTenantCode, String resTenantCode) throws ServiceException { if (!isAdmin) { resTenantCode = resTenantCode == null ? "" : resTenantCode; if (!StringUtils.isBlank(resTenantCode) && !resTenantCode.equals(userTenantCode)) { return false; } } return true; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
13,434
[Bug] [Resource Center] NPE when use OSS as the resource center
### 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 * NPE when use OSS as the resource center <img width="830" alt="截屏2023-01-20 10 18 21" src="https://user-images.githubusercontent.com/38122586/213605577-0734f363-08d5-4422-9132-905bbcf58e8f.png"> <img width="1202" alt="image" src="https://user-images.githubusercontent.com/38122586/213605613-32a71789-26da-4f4c-8103-70a6abe9f633.png"> ### What you expected to happen no NPE ### How to reproduce use OSS as the resource center ### Anything else * After the resource center is refactored in #12076 * The new methods in `StorageOperate` is not implemented in `OSS` <img width="882" alt="image" src="https://user-images.githubusercontent.com/38122586/213605852-8b50075f-bc13-41c8-a536-cc83d3409ef6.png"> ### 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/13434
https://github.com/apache/dolphinscheduler/pull/13435
9a6f83383be4858c710679cd2e44718408e7eacd
8a59ab44eb415274c70122c6d8e41621362fd351
2023-01-20T02:35:35Z
java
2023-02-07T03:55:07Z
dolphinscheduler-storage-plugin/dolphinscheduler-storage-oss/src/main/java/org/apache/dolphinscheduler/plugin/storage/oss/OssStorageOperator.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.storage.oss; import static org.apache.dolphinscheduler.common.constants.Constants.FOLDER_SEPARATOR; import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_S_S; import static org.apache.dolphinscheduler.common.constants.Constants.RESOURCE_TYPE_FILE; import static org.apache.dolphinscheduler.common.constants.Constants.RESOURCE_TYPE_UDF; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.ResUploadType; import org.apache.dolphinscheduler.common.factory.OssClientFactory; import org.apache.dolphinscheduler.common.model.OssConnection;