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
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
return result; } Map<String, Object> scheduleResult = updateDagSchedule(loginUser, projectCode, code, scheduleJson); if (scheduleResult.get(Constants.STATUS) != Status.SUCCESS) { Status scheduleResultStatus = (Status) scheduleResult.get(Constants.STATUS); putMsg(result, scheduleResultStatus); throw new ServiceException(scheduleResultStatus); } return result; } private void updateWorkflowValid(User user, ProcessDefinition oldProcessDefinition, ProcessDefinition newProcessDefinition) { if (oldProcessDefinition.getReleaseState() == ReleaseState.ONLINE) { throw new ServiceException(Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT, oldProcessDefinition.getName()); } Project project = projectMapper.queryByCode(oldProcessDefinition.getProjectCode()); projectService.checkProjectAndAuthThrowException(user, project, WORKFLOW_UPDATE); if (checkDescriptionLength(newProcessDefinition.getDescription())) { throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR); } if (!oldProcessDefinition.getName().equals(newProcessDefinition.getName())) { ProcessDefinition definition = processDefinitionMapper .verifyByDefineName(newProcessDefinition.getProjectCode(), newProcessDefinition.getName()); if (definition != null) { throw new ServiceException(Status.PROCESS_DEFINITION_NAME_EXIST, newProcessDefinition.getName()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
} } /** * update single resource workflow * * @param loginUser login user * @param workflowCode workflow resource code want to update * @param workflowUpdateRequest workflow update resource object * @return Process definition */ @Override @Transactional public ProcessDefinition updateSingleProcessDefinition(User loginUser, long workflowCode, WorkflowUpdateRequest workflowUpdateRequest) { ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(workflowCode); if (processDefinition == null) { throw new ServiceException(Status.PROCESS_DEFINE_NOT_EXIST, workflowCode); } ProcessDefinition processDefinitionUpdate = workflowUpdateRequest.mergeIntoProcessDefinition(processDefinition); this.updateWorkflowValid(loginUser, processDefinition, processDefinitionUpdate); if (processDefinitionUpdate.getTenantCode() != null) { Tenant tenant = tenantMapper.queryByTenantCode(processDefinitionUpdate.getTenantCode()); if (tenant == null) { throw new ServiceException(Status.TENANT_NOT_EXIST); } processDefinitionUpdate.setTenantId(tenant.getId()); } int update = processDefinitionMapper.updateById(processDefinitionUpdate);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
if (update <= 0) { throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); } this.syncObj2Log(loginUser, processDefinition); return processDefinition; } protected Map<String, Object> updateDagSchedule(User loginUser, long projectCode, long processDefinitionCode, String scheduleJson) { Map<String, Object> result = new HashMap<>(); Schedule schedule = JSONUtils.parseObject(scheduleJson, Schedule.class); if (schedule == null) { putMsg(result, Status.DATA_IS_NOT_VALID, scheduleJson); throw new ServiceException(Status.DATA_IS_NOT_VALID); } FailureStrategy failureStrategy = schedule.getFailureStrategy() == null ? FailureStrategy.CONTINUE : schedule.getFailureStrategy(); WarningType warningType = schedule.getWarningType() == null ? WarningType.NONE : schedule.getWarningType(); Priority processInstancePriority = schedule.getProcessInstancePriority() == null ? Priority.MEDIUM : schedule.getProcessInstancePriority(); int warningGroupId = schedule.getWarningGroupId() == 0 ? 1 : schedule.getWarningGroupId(); String workerGroup = schedule.getWorkerGroup() == null ? "default" : schedule.getWorkerGroup(); long environmentCode = schedule.getEnvironmentCode() == null ? -1 : schedule.getEnvironmentCode(); ScheduleParam param = new ScheduleParam(); param.setStartTime(schedule.getStartTime()); param.setEndTime(schedule.getEndTime()); param.setCrontab(schedule.getCrontab()); param.setTimezoneId(schedule.getTimezoneId());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
return schedulerService.updateScheduleByProcessDefinitionCode( loginUser, projectCode, processDefinitionCode, JSONUtils.toJsonString(param), warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup, environmentCode); } /** * release process definition and schedule * * @param loginUser login user * @param projectCode project code * @param code process definition code * @param releaseState releaseState * @return update result code */ @Transactional @Override public Map<String, Object> releaseWorkflowAndSchedule(User loginUser, long projectCode, long code, ReleaseState releaseState) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_ONLINE_OFFLINE); if (result.get(Constants.STATUS) != Status.SUCCESS) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
return result; } if (null == releaseState) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE); return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); if (processDefinition == null) { logger.error("Process definition does not exist, code:{}.", code); putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); return result; } Schedule scheduleObj = scheduleMapper.queryByProcessDefinitionCode(code); if (scheduleObj == null) { logger.error("Schedule cron does not exist, processDefinitionCode:{}.", code); putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, "processDefinitionCode:" + code); return result; } switch (releaseState) { case ONLINE: List<ProcessTaskRelation> relationList = processService.findRelationByCode(code, processDefinition.getVersion()); if (CollectionUtils.isEmpty(relationList)) { logger.warn("Process definition has no task relation, processDefinitionCode:{}.", code); putMsg(result, Status.PROCESS_DAG_IS_EMPTY); return result; } processDefinition.setReleaseState(releaseState); processDefinitionMapper.updateById(processDefinition);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
schedulerService.setScheduleState(loginUser, projectCode, scheduleObj.getId(), ReleaseState.ONLINE); break; case OFFLINE: processDefinition.setReleaseState(releaseState); int updateProcess = processDefinitionMapper.updateById(processDefinition); if (updateProcess > 0) { logger.info("Set schedule offline, projectCode:{}, processDefinitionCode:{}, scheduleId:{}.", projectCode, code, scheduleObj.getId()); scheduleObj.setReleaseState(ReleaseState.OFFLINE); int updateSchedule = scheduleMapper.updateById(scheduleObj); if (updateSchedule == 0) { logger.error( "Set schedule offline error, projectCode:{}, processDefinitionCode:{}, scheduleId:{}", projectCode, code, scheduleObj.getId()); putMsg(result, Status.OFFLINE_SCHEDULE_ERROR); throw new ServiceException(Status.OFFLINE_SCHEDULE_ERROR); } schedulerService.deleteSchedule(project.getId(), scheduleObj.getId()); } break; default: putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE); return result; } putMsg(result, Status.SUCCESS); return result; } /** * save other relation
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
* @param loginUser * @param processDefinition * @param result * @param otherParamsJson */ @Override public void saveOtherRelation(User loginUser, ProcessDefinition processDefinition, Map<String, Object> result, String otherParamsJson) { } /** * get Json String * @param loginUser * @param processDefinition * @return Json String */ @Override public String doOtherOperateProcess(User loginUser, ProcessDefinition processDefinition) { return null; } /** * delete other relation * @param project * @param result * @param processDefinition */ @Override public void deleteOtherRelation(Project project, Map<String, Object> result, ProcessDefinition processDefinition) { } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
* the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.service; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.TASK_DEFINITION_MOVE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_BATCH_COPY; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_CREATE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION_DELETE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_IMPORT; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_ONLINE_OFFLINE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_TREE_VIEW; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_UPDATE; import static org.apache.dolphinscheduler.common.Constants.DEFAULT; import static org.apache.dolphinscheduler.common.Constants.EMPTY_STRING; import static org.mockito.ArgumentMatchers.isA; import org.apache.dolphinscheduler.api.dto.workflow.WorkflowCreateRequest; import org.apache.dolphinscheduler.api.dto.workflow.WorkflowFilterRequest; import org.apache.dolphinscheduler.api.dto.workflow.WorkflowUpdateRequest; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.impl.ProcessDefinitionServiceImpl; import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ProcessExecutionTypeEnum; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.graph.DAG; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.DagData; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; import org.apache.dolphinscheduler.dao.entity.TaskMainInfo; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.model.PageListingResult; import org.apache.dolphinscheduler.dao.repository.ProcessDefinitionDao;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.commons.lang3.StringUtils; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; 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.Set; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import javax.servlet.http.HttpServletResponse; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.jupiter.api.Assertions; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.mock.web.MockMultipartFile; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; @RunWith(MockitoJUnitRunner.class)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
public class ProcessDefinitionServiceTest extends BaseServiceTestTool { private static final String taskRelationJson = "[{\"name\":\"\",\"preTaskCode\":0,\"preTaskVersion\":0,\"postTaskCode\":123456789," + "\"postTaskVersion\":1,\"conditionType\":0,\"conditionParams\":\"{}\"},{\"name\":\"\",\"preTaskCode\":123456789," + "\"preTaskVersion\":1,\"postTaskCode\":123451234,\"postTaskVersion\":1,\"conditionType\":0,\"conditionParams\":\"{}\"}]"; private static final String taskDefinitionJson = "[{\"code\":123456789,\"name\":\"test1\",\"version\":1,\"description\":\"\",\"delayTime\":0,\"taskType\":\"SHELL\"," + "\"taskParams\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"echo 1\",\"dependence\":{},\"conditionResult\":{\"successNode\":[],\"failedNode\":[]},\"waitStartTimeout\":{}," + "\"switchResult\":{}},\"flag\":\"YES\",\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\"," + "\"timeoutNotifyStrategy\":null,\"timeout\":0,\"environmentCode\":-1},{\"code\":123451234,\"name\":\"test2\",\"version\":1,\"description\":\"\",\"delayTime\":0,\"taskType\":\"SHELL\"," + "\"taskParams\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"echo 2\",\"dependence\":{},\"conditionResult\":{\"successNode\":[],\"failedNode\":[]},\"waitStartTimeout\":{}," + "\"switchResult\":{}},\"flag\":\"YES\",\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\"," + "\"timeoutNotifyStrategy\":\"WARN\",\"timeout\":0,\"environmentCode\":-1}]"; @InjectMocks private ProcessDefinitionServiceImpl processDefinitionService; @Mock private ProcessDefinitionMapper processDefinitionMapper; @Mock private ProcessDefinitionLogMapper processDefinitionLogMapper; @Mock private ProcessDefinitionDao processDefinitionDao; @Mock private ProcessTaskRelationMapper processTaskRelationMapper; @Mock private ProjectMapper projectMapper; @Mock private ProjectServiceImpl projectService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
@Mock private ScheduleMapper scheduleMapper; @Mock private SchedulerService schedulerService; @Mock private ProcessService processService; @Mock private ProcessInstanceService processInstanceService; @Mock private TenantMapper tenantMapper; @Mock private DataSourceMapper dataSourceMapper; @Mock private WorkFlowLineageService workFlowLineageService; protected User user; protected Exception exception; protected final static long projectCode = 1L; protected final static long projectCodeOther = 2L; protected final static long processDefinitionCode = 11L; protected final static String name = "testProcessDefinitionName"; protected final static String description = "this is a description"; protected final static String releaseState = "ONLINE"; protected final static int warningGroupId = 1; protected final static int timeout = 60; protected final static String executionType = "PARALLEL"; protected final static String tenantCode = "tenant"; @Before public void before() { User loginUser = new User(); loginUser.setId(1);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
loginUser.setTenantId(2); loginUser.setUserType(UserType.GENERAL_USER); loginUser.setUserName("admin"); user = loginUser; } @Test public void testQueryProcessDefinitionList() { Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Project project = getProject(projectCode); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) .thenReturn(result); Map<String, Object> map = processDefinitionService.queryProcessDefinitionList(user, projectCode); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS)); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) .thenReturn(result); List<ProcessDefinition> resourceList = new ArrayList<>(); resourceList.add(getProcessDefinition()); Mockito.when(processDefinitionMapper.queryAllDefinitionList(project.getCode())).thenReturn(resourceList); Map<String, Object> checkSuccessRes = processDefinitionService.queryProcessDefinitionList(user, projectCode); Assert.assertEquals(Status.SUCCESS, checkSuccessRes.get(Constants.STATUS)); } @Test public void testQueryProcessDefinitionListPaging() { Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
Project project = getProject(projectCode); try { Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(null); Mockito.doThrow(new ServiceException(Status.PROJECT_NOT_EXIST)).when(projectService) .checkProjectAndAuthThrowException(user, null, WORKFLOW_DEFINITION); processDefinitionService.queryProcessDefinitionListPaging(user, projectCode, "", "", 1, 5, 0); } catch (ServiceException serviceException) { Assert.assertEquals(Status.PROJECT_NOT_EXIST.getCode(), serviceException.getCode()); } Map<String, Object> result = new HashMap<>(); putMsg(result, Status.SUCCESS, projectCode); user.setId(1); Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(user, project, WORKFLOW_DEFINITION); Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(project); PageListingResult<ProcessDefinition> pageListingResult = PageListingResult.<ProcessDefinition>builder() .records(Collections.emptyList()) .currentPage(1) .pageSize(10) .totalCount(30) .build(); Mockito.when(processDefinitionDao.listingProcessDefinition( Mockito.eq(0), Mockito.eq(10), Mockito.eq(""), Mockito.eq(1), Mockito.eq(project.getCode()))).thenReturn(pageListingResult); PageInfo<ProcessDefinition> pageInfo = processDefinitionService.queryProcessDefinitionListPaging( user, project.getCode(), "", "", 1, 0, 10);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
Assert.assertNotNull(pageInfo); } @Test public void testQueryProcessDefinitionByCode() { Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Project project = getProject(projectCode); Tenant tenant = new Tenant(); tenant.setId(1); tenant.setTenantCode("root"); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) .thenReturn(result); Map<String, Object> map = processDefinitionService.queryProcessDefinitionByCode(user, 1L, 1L); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS)); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) .thenReturn(result); DagData dagData = new DagData(getProcessDefinition(), null, null); Mockito.when(processService.genDagData(Mockito.any())).thenReturn(dagData); Map<String, Object> instanceNotexitRes = processDefinitionService.queryProcessDefinitionByCode(user, projectCode, 1L); Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, instanceNotexitRes.get(Constants.STATUS)); Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(getProcessDefinition()); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) .thenReturn(result);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
Mockito.when(tenantMapper.queryById(1)).thenReturn(tenant); Map<String, Object> successRes = processDefinitionService.queryProcessDefinitionByCode(user, projectCode, 46L); Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); } @Test public void testQueryProcessDefinitionByName() { Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Project project = getProject(projectCode); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) .thenReturn(result); Map<String, Object> map = processDefinitionService.queryProcessDefinitionByName(user, projectCode, "test_def"); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS)); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) .thenReturn(result); Mockito.when(processDefinitionMapper.queryByDefineName(project.getCode(), "test_def")).thenReturn(null); Map<String, Object> instanceNotExitRes = processDefinitionService.queryProcessDefinitionByName(user, projectCode, "test_def"); Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, instanceNotExitRes.get(Constants.STATUS)); Mockito.when(processDefinitionMapper.queryByDefineName(project.getCode(), "test")) .thenReturn(getProcessDefinition()); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION))
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
.thenReturn(result); Map<String, Object> successRes = processDefinitionService.queryProcessDefinitionByName(user, projectCode, "test"); Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); } @Test public void testBatchCopyProcessDefinition() { Project project = getProject(projectCode); Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_BATCH_COPY)) .thenReturn(result); Map<String, Object> map = processDefinitionService.batchCopyProcessDefinition(user, projectCode, StringUtils.EMPTY, 2L); Assert.assertEquals(Status.PROCESS_DEFINITION_CODES_IS_EMPTY, map.get(Constants.STATUS)); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_BATCH_COPY)) .thenReturn(result); Map<String, Object> map1 = processDefinitionService.batchCopyProcessDefinition( user, projectCode, String.valueOf(project.getId()), 2L); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map1.get(Constants.STATUS)); Project project1 = getProject(projectCodeOther); Mockito.when(projectMapper.queryByCode(projectCodeOther)).thenReturn(project1); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCodeOther, WORKFLOW_BATCH_COPY)) .thenReturn(result); putMsg(result, Status.SUCCESS, projectCodeOther);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
ProcessDefinition definition = getProcessDefinition(); List<ProcessDefinition> processDefinitionList = new ArrayList<>(); processDefinitionList.add(definition); Set<Long> definitionCodes = new HashSet<>(); for (String code : String.valueOf(processDefinitionCode).split(Constants.COMMA)) { try { long parse = Long.parseLong(code); definitionCodes.add(parse); } catch (NumberFormatException e) { Assertions.fail(); } } Mockito.when(processDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(processDefinitionList); Mockito.when(processService.saveProcessDefine(user, definition, Boolean.TRUE, Boolean.TRUE)).thenReturn(2); Map<String, Object> map3 = processDefinitionService.batchCopyProcessDefinition( user, projectCodeOther, String.valueOf(processDefinitionCode), projectCode); Assert.assertEquals(Status.SUCCESS, map3.get(Constants.STATUS)); } @Test public void testBatchMoveProcessDefinition() { Project project1 = getProject(projectCode); Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(project1); Project project2 = getProject(projectCodeOther); Mockito.when(projectMapper.queryByCode(projectCodeOther)).thenReturn(project2); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project1, projectCode, TASK_DEFINITION_MOVE)) .thenReturn(result); Mockito.when(projectService.checkProjectAndAuth(user, project2, projectCodeOther, TASK_DEFINITION_MOVE))
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
.thenReturn(result); ProcessDefinition definition = getProcessDefinition(); definition.setVersion(1); List<ProcessDefinition> processDefinitionList = new ArrayList<>(); processDefinitionList.add(definition); Set<Long> definitionCodes = new HashSet<>(); for (String code : String.valueOf(processDefinitionCode).split(Constants.COMMA)) { try { long parse = Long.parseLong(code); definitionCodes.add(parse); } catch (NumberFormatException e) { Assertions.fail(); } } Mockito.when(processDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(processDefinitionList); Mockito.when(processService.saveProcessDefine(user, definition, Boolean.TRUE, Boolean.TRUE)).thenReturn(2); Mockito.when(processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode)) .thenReturn(getProcessTaskRelation()); putMsg(result, Status.SUCCESS); Map<String, Object> successRes = processDefinitionService.batchMoveProcessDefinition( user, projectCode, String.valueOf(processDefinitionCode), projectCodeOther); Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); } @Test public void deleteProcessDefinitionByCodeTest() { Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Project project = getProject(projectCode); exception = Assertions.assertThrows(ServiceException.class,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 2L)); Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); Mockito.when(processDefinitionMapper.queryByCode(6L)).thenReturn(this.getProcessDefinition()); Mockito.doThrow(new ServiceException(Status.PROJECT_NOT_FOUND)).when(projectService) .checkProjectAndAuthThrowException(user, project, WORKFLOW_DEFINITION_DELETE); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.deleteProcessDefinitionByCode(user, 6L)); Assertions.assertEquals(Status.PROJECT_NOT_FOUND.getCode(), ((ServiceException) exception).getCode()); Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(user, project, WORKFLOW_DEFINITION_DELETE); Mockito.when(processDefinitionMapper.queryByCode(1L)).thenReturn(null); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.deleteProcessDefinitionByCode(user, 1L)); Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); ProcessDefinition processDefinition = getProcessDefinition(); Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); Assertions.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), ((ServiceException) exception).getCode()); user.setUserType(UserType.ADMIN_USER); processDefinition.setReleaseState(ReleaseState.ONLINE); Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); Assertions.assertEquals(Status.PROCESS_DEFINE_STATE_ONLINE.getCode(), ((ServiceException) exception).getCode());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
processDefinition.setReleaseState(ReleaseState.OFFLINE); Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); Mockito.when(scheduleMapper.queryByProcessDefinitionCode(46L)).thenReturn(getSchedule()); Mockito.when(scheduleMapper.deleteById(46)).thenReturn(1); Mockito.when(processDefinitionMapper.deleteById(processDefinition.getId())).thenReturn(1); Mockito.when(processTaskRelationMapper.deleteByCode(project.getCode(), processDefinition.getCode())) .thenReturn(1); Mockito.when(workFlowLineageService.queryTaskDepOnProcess(project.getCode(), processDefinition.getCode())) .thenReturn(Collections.emptySet()); processDefinitionService.deleteProcessDefinitionByCode(user, 46L); Schedule schedule = getSchedule(); schedule.setReleaseState(ReleaseState.ONLINE); Mockito.when(scheduleMapper.queryByProcessDefinitionCode(46L)).thenReturn(schedule); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); Assertions.assertEquals(Status.SCHEDULE_STATE_ONLINE.getCode(), ((ServiceException) exception).getCode()); user.setUserType(UserType.ADMIN_USER); TaskMainInfo taskMainInfo = getTaskMainInfo().get(0); Mockito.when(workFlowLineageService.queryTaskDepOnProcess(project.getCode(), processDefinition.getCode())) .thenReturn(ImmutableSet.copyOf(getTaskMainInfo())); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); Assertions.assertEquals(Status.DELETE_PROCESS_DEFINITION_USE_BY_OTHER_FAIL.getCode(), ((ServiceException) exception).getCode()); schedule.setReleaseState(ReleaseState.OFFLINE); Mockito.when(processDefinitionMapper.deleteById(46)).thenReturn(1); Mockito.when(scheduleMapper.deleteById(schedule.getId())).thenReturn(1);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
Mockito.when(processTaskRelationMapper.deleteByCode(project.getCode(), processDefinition.getCode())) .thenReturn(1); Mockito.when(scheduleMapper.queryByProcessDefinitionCode(46L)).thenReturn(getSchedule()); Mockito.when(workFlowLineageService.queryTaskDepOnProcess(project.getCode(), processDefinition.getCode())) .thenReturn(Collections.emptySet()); Assertions.assertDoesNotThrow(() -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); } @Test public void testReleaseProcessDefinition() { Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Project project = getProject(projectCode); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_ONLINE_OFFLINE)) .thenReturn(result); Map<String, Object> map = processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.OFFLINE); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS)); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(getProcessDefinition()); List<ProcessTaskRelation> processTaskRelationList = new ArrayList<>(); ProcessTaskRelation processTaskRelation = new ProcessTaskRelation(); processTaskRelation.setProjectCode(projectCode); processTaskRelation.setProcessDefinitionCode(46L); processTaskRelation.setPostTaskCode(123L); processTaskRelationList.add(processTaskRelation); Mockito.when(processService.findRelationByCode(46L, 1)).thenReturn(processTaskRelationList); Map<String, Object> onlineRes =
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
processDefinitionService.releaseProcessDefinition(user, projectCode, 46, ReleaseState.ONLINE); Assert.assertEquals(Status.SUCCESS, onlineRes.get(Constants.STATUS)); Map<String, Object> onlineWithResourceRes = processDefinitionService.releaseProcessDefinition(user, projectCode, 46, ReleaseState.ONLINE); Assert.assertEquals(Status.SUCCESS, onlineWithResourceRes.get(Constants.STATUS)); Map<String, Object> failRes = processDefinitionService.releaseProcessDefinition(user, projectCode, 46, ReleaseState.getEnum(2)); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, failRes.get(Constants.STATUS)); } @Test public void testVerifyProcessDefinitionName() { Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Project project = getProject(projectCode); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_CREATE)) .thenReturn(result); Map<String, Object> map = processDefinitionService.verifyProcessDefinitionName(user, projectCode, "test_pdf", 0); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS)); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(processDefinitionMapper.verifyByDefineName(project.getCode(), "test_pdf")).thenReturn(null); Map<String, Object> processNotExistRes = processDefinitionService.verifyProcessDefinitionName(user, projectCode, "test_pdf", 0); Assert.assertEquals(Status.SUCCESS, processNotExistRes.get(Constants.STATUS));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
Mockito.when(processDefinitionMapper.verifyByDefineName(project.getCode(), "test_pdf")) .thenReturn(getProcessDefinition()); Map<String, Object> processExistRes = processDefinitionService.verifyProcessDefinitionName(user, projectCode, "test_pdf", 0); Assert.assertEquals(Status.PROCESS_DEFINITION_NAME_EXIST, processExistRes.get(Constants.STATUS)); } @Test public void testCheckProcessNodeList() { Map<String, Object> dataNotValidRes = processDefinitionService.checkProcessNodeList(null, null); Assert.assertEquals(Status.DATA_IS_NOT_VALID, dataNotValidRes.get(Constants.STATUS)); List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); Map<String, Object> taskEmptyRes = processDefinitionService.checkProcessNodeList(taskRelationJson, taskDefinitionLogs); Assert.assertEquals(Status.PROCESS_DAG_IS_EMPTY, taskEmptyRes.get(Constants.STATUS)); } @Test public void testGetTaskNodeListByDefinitionCode() { Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Project project = getProject(projectCode); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, null)).thenReturn(result); Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(null); Map<String, Object> processDefinitionNullRes = processDefinitionService.getTaskNodeListByDefinitionCode(user, projectCode, 46L); Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionNullRes.get(Constants.STATUS)); ProcessDefinition processDefinition = getProcessDefinition();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
putMsg(result, Status.SUCCESS, projectCode); Mockito.when(processService.genDagData(Mockito.any())).thenReturn(new DagData(processDefinition, null, null)); Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); Map<String, Object> dataNotValidRes = processDefinitionService.getTaskNodeListByDefinitionCode(user, projectCode, 46L); Assert.assertEquals(Status.SUCCESS, dataNotValidRes.get(Constants.STATUS)); } @Test public void testGetTaskNodeListByDefinitionCodes() { Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Project project = getProject(projectCode); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, null)).thenReturn(result); String defineCodes = "46"; Set<Long> defineCodeSet = Lists.newArrayList(defineCodes.split(Constants.COMMA)).stream().map(Long::parseLong) .collect(Collectors.toSet()); Mockito.when(processDefinitionMapper.queryByCodes(defineCodeSet)).thenReturn(null); Map<String, Object> processNotExistRes = processDefinitionService.getNodeListMapByDefinitionCodes(user, projectCode, defineCodes); Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, processNotExistRes.get(Constants.STATUS)); putMsg(result, Status.SUCCESS, projectCode); ProcessDefinition processDefinition = getProcessDefinition(); List<ProcessDefinition> processDefinitionList = new ArrayList<>(); processDefinitionList.add(processDefinition); Mockito.when(processDefinitionMapper.queryByCodes(defineCodeSet)).thenReturn(processDefinitionList); Mockito.when(processService.genDagData(Mockito.any())).thenReturn(new DagData(processDefinition, null, null)); Project project1 = getProject(projectCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
List<Project> projects = new ArrayList<>(); projects.add(project1); Mockito.when(projectMapper.queryProjectCreatedAndAuthorizedByUserId(user.getId())).thenReturn(projects); Map<String, Object> successRes = processDefinitionService.getNodeListMapByDefinitionCodes(user, projectCode, defineCodes); Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); } @Test public void testQueryAllProcessDefinitionByProjectCode() { Map<String, Object> result = new HashMap<>(); Project project = getProject(projectCode); Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(project); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) .thenReturn(result); ProcessDefinition processDefinition = getProcessDefinition(); List<ProcessDefinition> processDefinitionList = new ArrayList<>(); processDefinitionList.add(processDefinition); Mockito.when(processDefinitionMapper.queryAllDefinitionList(projectCode)).thenReturn(processDefinitionList); Map<String, Object> successRes = processDefinitionService.queryAllProcessDefinitionByProjectCode(user, projectCode); Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); } @Test public void testViewTree() { Project project1 = getProject(projectCode); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectMapper.queryByCode(1)).thenReturn(project1); Mockito.when(projectService.checkProjectAndAuth(user, project1, projectCode, WORKFLOW_TREE_VIEW))
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
.thenReturn(result); ProcessDefinition processDefinition = getProcessDefinition(); Map<String, Object> processDefinitionNullRes = processDefinitionService.viewTree(user, processDefinition.getProjectCode(), 46, 10); Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionNullRes.get(Constants.STATUS)); putMsg(result, Status.SUCCESS, projectCode); Mockito.when(projectMapper.queryByCode(1)).thenReturn(project1); Mockito.when(projectService.checkProjectAndAuth(user, project1, 1, WORKFLOW_TREE_VIEW)).thenReturn(result); Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); Mockito.when(processService.genDagGraph(processDefinition)).thenReturn(new DAG<>()); Map<String, Object> taskNullRes = processDefinitionService.viewTree(user, processDefinition.getProjectCode(), 46, 10); Assert.assertEquals(Status.SUCCESS, taskNullRes.get(Constants.STATUS)); Map<String, Object> taskNotNuLLRes = processDefinitionService.viewTree(user, processDefinition.getProjectCode(), 46, 10); Assert.assertEquals(Status.SUCCESS, taskNotNuLLRes.get(Constants.STATUS)); } @Test public void testSubProcessViewTree() { ProcessDefinition processDefinition = getProcessDefinition(); Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); Project project1 = getProject(1); Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, Status.SUCCESS); Mockito.when(projectMapper.queryByCode(1)).thenReturn(project1); Mockito.when(projectService.checkProjectAndAuth(user, project1, 1, WORKFLOW_TREE_VIEW)).thenReturn(result); Mockito.when(processService.genDagGraph(processDefinition)).thenReturn(new DAG<>());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
Map<String, Object> taskNotNuLLRes = processDefinitionService.viewTree(user, processDefinition.getProjectCode(), 46, 10); Assert.assertEquals(Status.SUCCESS, taskNotNuLLRes.get(Constants.STATUS)); } @Test public void testUpdateProcessDefinition() { Map<String, Object> result = new HashMap<>(); putMsg(result, Status.SUCCESS); Project project = getProject(projectCode); Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_UPDATE)) .thenReturn(result); try { processDefinitionService.updateProcessDefinition(user, projectCode, "test", 1, "", "", "", 0, "root", null, "", null, ProcessExecutionTypeEnum.PARALLEL); Assert.fail(); } catch (ServiceException ex) { Assert.assertEquals(Status.DATA_IS_NOT_VALID.getCode(), ex.getCode()); } } @Test public void testBatchExportProcessDefinitionByCodes() { processDefinitionService.batchExportProcessDefinitionByCodes(null, 1L, null, null); Project project = getProject(projectCode); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.PROJECT_NOT_FOUND); Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); processDefinitionService.batchExportProcessDefinitionByCodes(user, projectCode, "1", null); ProcessDefinition processDefinition = new ProcessDefinition(); processDefinition.setId(1);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(project); HttpServletResponse response = Mockito.mock(HttpServletResponse.class); DagData dagData = new DagData(getProcessDefinition(), null, null); Mockito.when(processService.genDagData(Mockito.any())).thenReturn(dagData); processDefinitionService.batchExportProcessDefinitionByCodes(user, projectCode, "1", response); Assert.assertNotNull(processDefinitionService.exportProcessDagData(processDefinition)); } @Test public void testImportSqlProcessDefinition() throws Exception { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ZipOutputStream outputStream = new ZipOutputStream(byteArrayOutputStream); outputStream.putNextEntry(new ZipEntry("import_sql/")); outputStream.putNextEntry(new ZipEntry("import_sql/a.sql")); outputStream.write( "-- upstream: start_auto_dag\n-- datasource: mysql_1\nselect 1;".getBytes(StandardCharsets.UTF_8)); outputStream.putNextEntry(new ZipEntry("import_sql/b.sql")); outputStream .write("-- name: start_auto_dag\n-- datasource: mysql_1\nselect 1;".getBytes(StandardCharsets.UTF_8)); outputStream.close(); MockMultipartFile mockMultipartFile = new MockMultipartFile("import_sql.zip", byteArrayOutputStream.toByteArray()); DataSource dataSource = Mockito.mock(DataSource.class); Mockito.when(dataSource.getId()).thenReturn(1); Mockito.when(dataSource.getType()).thenReturn(DbType.MYSQL); Mockito.when(dataSourceMapper.queryDataSourceByNameAndUserId(user.getId(), "mysql_1")).thenReturn(dataSource); Project project = getProject(projectCode); Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, Status.SUCCESS); Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_IMPORT))
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
.thenReturn(result); Mockito.when(processService.saveTaskDefine(Mockito.same(user), Mockito.eq(projectCode), Mockito.notNull(), Mockito.anyBoolean())).thenReturn(2); Mockito.when(processService.saveProcessDefine(Mockito.same(user), Mockito.notNull(), Mockito.notNull(), Mockito.anyBoolean())).thenReturn(1); Mockito.when( processService.saveTaskRelation(Mockito.same(user), Mockito.eq(projectCode), Mockito.anyLong(), Mockito.eq(1), Mockito.notNull(), Mockito.notNull(), Mockito.anyBoolean())) .thenReturn(0); result = processDefinitionService.importSqlProcessDefinition(user, projectCode, mockMultipartFile); Assert.assertEquals(result.get(Constants.STATUS), Status.SUCCESS); } @Test public void testGetNewProcessName() { String processName1 = "test_copy_" + DateUtils.getCurrentTimeStamp(); final String newName1 = processDefinitionService.getNewName(processName1, Constants.COPY_SUFFIX); Assert.assertEquals(2, newName1.split(Constants.COPY_SUFFIX).length); String processName2 = "wf_copy_all_ods_data_to_d"; final String newName2 = processDefinitionService.getNewName(processName2, Constants.COPY_SUFFIX); Assert.assertEquals(3, newName2.split(Constants.COPY_SUFFIX).length); String processName3 = "test_import_" + DateUtils.getCurrentTimeStamp(); final String newName3 = processDefinitionService.getNewName(processName3, Constants.IMPORT_SUFFIX); Assert.assertEquals(2, newName3.split(Constants.IMPORT_SUFFIX).length); } @Test public void testCreateProcessDefinitionV2() { Project project = this.getProject(projectCode); WorkflowCreateRequest workflowCreateRequest = new WorkflowCreateRequest(); workflowCreateRequest.setName(name); workflowCreateRequest.setProjectCode(projectCode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest)); Assertions.assertEquals(Status.PROJECT_NOT_FOUND.getCode(), ((ServiceException) exception).getCode()); Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(project); Mockito.doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM)).when(projectService) .checkProjectAndAuthThrowException(user, project, WORKFLOW_CREATE); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest)); Assertions.assertEquals(Status.USER_NO_OPERATION_PROJECT_PERM.getCode(), ((ServiceException) exception).getCode()); workflowCreateRequest.setDescription(taskDefinitionJson); Mockito.doThrow(new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR)).when(projectService) .checkProjectAndAuthThrowException(user, project, WORKFLOW_CREATE); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest)); Assertions.assertEquals(Status.DESCRIPTION_TOO_LONG_ERROR.getCode(), ((ServiceException) exception).getCode()); workflowCreateRequest.setDescription(EMPTY_STRING); Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(user, project, WORKFLOW_CREATE); Mockito.when(processDefinitionMapper.verifyByDefineName(project.getCode(), name)) .thenReturn(this.getProcessDefinition()); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest)); Assertions.assertEquals(Status.PROCESS_DEFINITION_NAME_EXIST.getCode(), ((ServiceException) exception).getCode()); Mockito.when(processDefinitionMapper.verifyByDefineName(project.getCode(), name)).thenReturn(null);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest)); Assertions.assertEquals(Status.TENANT_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); workflowCreateRequest.setTenantCode(DEFAULT); workflowCreateRequest.setDescription(description); workflowCreateRequest.setTimeout(timeout); workflowCreateRequest.setReleaseState(releaseState); workflowCreateRequest.setWarningGroupId(warningGroupId); workflowCreateRequest.setExecutionType(executionType); Mockito.when(processDefinitionLogMapper.insert(Mockito.any())).thenReturn(1); Mockito.when(processDefinitionMapper.insert(Mockito.any())).thenReturn(1); ProcessDefinition processDefinition = processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest); Assertions.assertTrue(processDefinition.getCode() > 0L); Assertions.assertEquals(workflowCreateRequest.getName(), processDefinition.getName()); Assertions.assertEquals(workflowCreateRequest.getDescription(), processDefinition.getDescription()); Assertions.assertTrue(StringUtils.endsWithIgnoreCase(workflowCreateRequest.getReleaseState(), processDefinition.getReleaseState().getDescp())); Assertions.assertEquals(workflowCreateRequest.getTimeout(), processDefinition.getTimeout()); Assertions.assertTrue(StringUtils.endsWithIgnoreCase(workflowCreateRequest.getExecutionType(), processDefinition.getExecutionType().getDescp())); } @Test public void testFilterProcessDefinition() { Project project = this.getProject(projectCode); WorkflowFilterRequest workflowFilterRequest = new WorkflowFilterRequest(); workflowFilterRequest.setProjectName(project.getName()); Mockito.when(projectMapper.queryByName(project.getName())).thenReturn(project);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
Mockito.doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM, user.getUserName(), projectCode)) .when(projectService).checkProjectAndAuthThrowException(user, project, WORKFLOW_DEFINITION); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.filterProcessDefinition(user, workflowFilterRequest)); Assertions.assertEquals(Status.USER_NO_OPERATION_PROJECT_PERM.getCode(), ((ServiceException) exception).getCode()); } @Test public void testGetProcessDefinition() { exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.getProcessDefinition(user, processDefinitionCode)); Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)) .thenReturn(this.getProcessDefinition()); Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(this.getProject(projectCode)); Mockito.doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM, user.getUserName(), projectCode)) .when(projectService) .checkProjectAndAuthThrowException(user, this.getProject(projectCode), WORKFLOW_DEFINITION); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.getProcessDefinition(user, processDefinitionCode)); Assertions.assertEquals(Status.USER_NO_OPERATION_PROJECT_PERM.getCode(), ((ServiceException) exception).getCode()); Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(user, this.getProject(projectCode), WORKFLOW_DEFINITION); ProcessDefinition processDefinition = processDefinitionService.getProcessDefinition(user, processDefinitionCode); Assertions.assertEquals(this.getProcessDefinition(), processDefinition);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
} @Test public void testUpdateProcessDefinitionV2() { ProcessDefinition processDefinition; WorkflowUpdateRequest workflowUpdateRequest = new WorkflowUpdateRequest(); workflowUpdateRequest.setName(name); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.getProcessDefinition(user, processDefinitionCode)); Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); processDefinition = this.getProcessDefinition(); processDefinition.setReleaseState(ReleaseState.ONLINE); Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService .updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT.getCode(), ((ServiceException) exception).getCode()); processDefinition = this.getProcessDefinition(); Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(this.getProject(projectCode)); Mockito.doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM, user.getUserName(), projectCode)) .when(projectService) .checkProjectAndAuthThrowException(user, this.getProject(projectCode), WORKFLOW_DEFINITION); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService.getProcessDefinition(user, processDefinitionCode)); Assertions.assertEquals(Status.USER_NO_OPERATION_PROJECT_PERM.getCode(), ((ServiceException) exception).getCode());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
workflowUpdateRequest.setDescription(taskDefinitionJson); Mockito.doThrow(new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR)).when(projectService) .checkProjectAndAuthThrowException(user, this.getProject(projectCode), WORKFLOW_UPDATE); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService .updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); Assertions.assertEquals(Status.DESCRIPTION_TOO_LONG_ERROR.getCode(), ((ServiceException) exception).getCode()); workflowUpdateRequest.setDescription(EMPTY_STRING); Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(user, this.getProject(projectCode), WORKFLOW_UPDATE); Mockito.when(processDefinitionMapper.verifyByDefineName(projectCode, workflowUpdateRequest.getName())) .thenReturn(this.getProcessDefinition()); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService .updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); Assertions.assertEquals(Status.PROCESS_DEFINITION_NAME_EXIST.getCode(), ((ServiceException) exception).getCode()); processDefinition = this.getProcessDefinition(); workflowUpdateRequest.setTenantCode(tenantCode); Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); Mockito.when(processDefinitionMapper.verifyByDefineName(projectCode, workflowUpdateRequest.getName())) .thenReturn(null); Mockito.when(tenantMapper.queryByTenantCode(workflowUpdateRequest.getTenantCode())).thenReturn(null); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService .updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); Assertions.assertEquals(Status.TENANT_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); workflowUpdateRequest.setTenantCode(null); workflowUpdateRequest.setName(name); Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
Mockito.when(processDefinitionLogMapper.insert(Mockito.any())).thenReturn(1); exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService .updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); Assertions.assertEquals(Status.UPDATE_PROCESS_DEFINITION_ERROR.getCode(), ((ServiceException) exception).getCode()); Mockito.when(processDefinitionMapper.updateById(isA(ProcessDefinition.class))).thenReturn(1); ProcessDefinition processDefinitionUpdate = processDefinitionService.updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest); Assertions.assertEquals(processDefinition, processDefinitionUpdate); } /** * get mock processDefinition * * @return ProcessDefinition */ private ProcessDefinition getProcessDefinition() { ProcessDefinition processDefinition = new ProcessDefinition(); processDefinition.setId(46); processDefinition.setProjectCode(1L); processDefinition.setName("test_pdf"); processDefinition.setTenantId(1); processDefinition.setDescription(""); processDefinition.setCode(processDefinitionCode); processDefinition.setProjectCode(projectCode); processDefinition.setVersion(1); return processDefinition; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
* get mock Project * * @param projectCode projectCode * @return Project */ private Project getProject(long projectCode) { Project project = new Project(); project.setCode(projectCode); project.setId(1); project.setName("test"); project.setUserId(1); return project; } private List<ProcessTaskRelation> getProcessTaskRelation() { List<ProcessTaskRelation> processTaskRelations = new ArrayList<>(); ProcessTaskRelation processTaskRelation = new ProcessTaskRelation(); processTaskRelation.setProjectCode(projectCode); processTaskRelation.setProcessDefinitionCode(46L); processTaskRelation.setProcessDefinitionVersion(1); processTaskRelations.add(processTaskRelation); return processTaskRelations; } /** * get mock schedule * * @return schedule */ private Schedule getSchedule() { Date date = new Date(); Schedule schedule = new Schedule();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,678
[Improvement][API] Improvement the error message when batch delete workflow
### 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 I batch delete workflows, any workflow fails, I get not friendly error message. - We should display the workflow name rather then code - We should display the reason why it delete failed link #11554 ### 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/11678
https://github.com/apache/dolphinscheduler/pull/11682
962fa6dbd51c232b3b45243b408c5f19c1913879
1a4d7a842663574752bcabc222d2d0d778089fb7
2022-08-27T11:14:31Z
java
2022-09-29T11:08:26Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
schedule.setId(46); schedule.setProcessDefinitionCode(1); schedule.setStartTime(date); schedule.setEndTime(date); schedule.setCrontab("0 0 5 * * ? *"); schedule.setFailureStrategy(FailureStrategy.END); schedule.setUserId(1); schedule.setReleaseState(ReleaseState.OFFLINE); schedule.setProcessInstancePriority(Priority.MEDIUM); schedule.setWarningType(WarningType.NONE); schedule.setWarningGroupId(1); schedule.setWorkerGroup(Constants.DEFAULT_WORKER_GROUP); return schedule; } /** * get mock task main info * * @return schedule */ private List<TaskMainInfo> getTaskMainInfo() { List<TaskMainInfo> taskMainInfos = new ArrayList<>(); TaskMainInfo taskMainInfo = new TaskMainInfo(); taskMainInfo.setId(1); taskMainInfo.setProcessDefinitionName("process"); taskMainInfo.setTaskName("task"); taskMainInfos.add(taskMainInfo); return taskMainInfos; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.service.impl; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.USER_MANAGER; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.UsersService; import org.apache.dolphinscheduler.api.utils.CheckUtils; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.storage.StorageOperate;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
import org.apache.dolphinscheduler.common.utils.EncryptionUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.dolphinscheduler.dao.entity.DatasourceUser; import org.apache.dolphinscheduler.dao.entity.K8sNamespaceUser; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.ResourcesUser; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UDFUser; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.K8sNamespaceUserMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.text.MessageFormat; import java.util.ArrayList;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
import java.util.Arrays; 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.TimeZone; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * users service impl */ @Service public class UsersServiceImpl extends BaseServiceImpl implements UsersService { private static final Logger logger = LoggerFactory.getLogger(UsersServiceImpl.class); @Autowired private AccessTokenMapper accessTokenMapper; @Autowired private UserMapper userMapper; @Autowired private TenantMapper tenantMapper; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
private ProjectUserMapper projectUserMapper; @Autowired private ResourceUserMapper resourceUserMapper; @Autowired private ResourceMapper resourceMapper; @Autowired private DataSourceUserMapper datasourceUserMapper; @Autowired private UDFUserMapper udfUserMapper; @Autowired private AlertGroupMapper alertGroupMapper; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private ProjectMapper projectMapper; @Autowired(required = false) private StorageOperate storageOperate; @Autowired private K8sNamespaceUserMapper k8sNamespaceUserMapper; /** * create user, only system admin have permission * * @param loginUser login user * @param userName user name * @param userPassword user password * @param email email * @param tenantId tenant id * @param phone phone * @param queue queue * @return create result code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* @throws Exception exception */ @Override @Transactional public Map<String, Object> createUser(User loginUser, String userName, String userPassword, String email, int tenantId, String phone, String queue, int state) throws Exception { Map<String, Object> result = new HashMap<>(); String msg = this.checkUserParams(userName, userPassword, email, phone); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED, msg); return result; } if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (!StringUtils.isEmpty(msg)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg); return result; } if (!checkTenantExists(tenantId)) { logger.warn("Tenant does not exist, tenantId:{}.", tenantId); putMsg(result, Status.TENANT_NOT_EXIST);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
return result; } User user = createUser(userName, userPassword, email, tenantId, phone, queue, state); Tenant tenant = tenantMapper.queryById(tenantId); if (PropertyUtils.getResUploadStartupState()) { storageOperate.createTenantDirIfNotExists(tenant.getTenantCode()); } logger.info("User is created and id is {}.", user.getId()); result.put(Constants.DATA_LIST, user); putMsg(result, Status.SUCCESS); return result; } @Override @Transactional public User createUser(String userName, String userPassword, String email, int tenantId, String phone, String queue, int state) { User user = new User(); Date now = new Date(); user.setUserName(userName); user.setUserPassword(EncryptionUtils.getMd5(userPassword)); user.setEmail(email); user.setTenantId(tenantId); user.setPhone(phone); user.setState(state);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
user.setUserType(UserType.GENERAL_USER); user.setCreateTime(now); user.setUpdateTime(now); if (StringUtils.isEmpty(queue)) { queue = ""; } user.setQueue(queue); userMapper.insert(user); return user; } /*** * create User for ldap login */ @Override @Transactional public User createUser(UserType userType, String userId, String email) { User user = new User(); Date now = new Date(); user.setUserName(userId); user.setEmail(email); user.setUserType(userType); user.setCreateTime(now); user.setUpdateTime(now); user.setQueue(""); user.setState(Flag.YES.getCode()); userMapper.insert(user);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
return user; } /** * get user by user name * * @param userName user name * @return exist user or null */ @Override public User getUserByUserName(String userName) { return userMapper.queryByUserNameAccurately(userName); } /** * query user by id * * @param id id * @return user info */ @Override public User queryUser(int id) { return userMapper.selectById(id); } @Override public List<User> queryUser(List<Integer> ids) { if (CollectionUtils.isEmpty(ids)) { return new ArrayList<>(); } return userMapper.selectByIds(ids); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* query user * * @param name name * @return user info */ @Override public User queryUser(String name) { return userMapper.queryByUserNameAccurately(name); } /** * query user * * @param name name * @param password password * @return user info */ @Override public User queryUser(String name, String password) { String md5 = EncryptionUtils.getMd5(password); return userMapper.queryUserByNamePassword(name, md5); } /** * get user id by user name * * @param name user name * @return if name empty 0, user not exists -1, user exist user id */ @Override public int getUserIdByName(String name) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
int executorId = 0; if (StringUtils.isNotEmpty(name)) { User executor = queryUser(name); if (null != executor) { executorId = executor.getId(); } else { executorId = -1; } } return executorId; } /** * query user list * * @param loginUser login user * @param pageNo page number * @param searchVal search value * @param pageSize page size * @return user list page */ @Override public Result<Object> queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { Result<Object> result = new Result<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } if (!isAdmin(loginUser)) { logger.warn("User does not have permission for this feature, userId:{}, userName:{}.", loginUser.getId(), loginUser.getUserName()); putMsg(result, Status.USER_NO_OPERATION_PERM);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
return result; } Page<User> page = new Page<>(pageNo, pageSize); IPage<User> scheduleList = userMapper.queryUserPaging(page, searchVal); PageInfo<User> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotal((int) scheduleList.getTotal()); pageInfo.setTotalList(scheduleList.getRecords()); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * updateProcessInstance user * * @param userId user id * @param userName user name * @param userPassword user password * @param email email * @param tenantId tenant id * @param phone phone * @param queue queue * @param state state * @param timeZone timeZone * @return update result code * @throws Exception exception */ @Override public Map<String, Object> updateUser(User loginUser, int userId, String userName, String userPassword,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
String email, int tenantId, String phone, String queue, int state, String timeZone) throws IOException { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } if (check(result, !canOperator(loginUser, userId), Status.USER_NO_OPERATION_PERM)) { logger.warn("User does not have permission for this feature, userId:{}, userName:{}.", loginUser.getId(), loginUser.getUserName()); return result; } User user = userMapper.selectById(userId); if (user == null) { logger.error("User does not exist, userId:{}.", userId); putMsg(result, Status.USER_NOT_EXIST, userId); return result; } if (StringUtils.isNotEmpty(userName)) { if (!CheckUtils.checkUserName(userName)) { logger.warn("Parameter userName check failed."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName); return result; } User tempUser = userMapper.queryByUserNameAccurately(userName); if (tempUser != null && tempUser.getId() != userId) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
logger.warn("User name already exists, userName:{}.", tempUser.getUserName()); putMsg(result, Status.USER_NAME_EXIST); return result; } user.setUserName(userName); } if (StringUtils.isNotEmpty(userPassword)) { if (!CheckUtils.checkPasswordLength(userPassword)) { logger.warn("Parameter userPassword check failed."); putMsg(result, Status.USER_PASSWORD_LENGTH_ERROR); return result; } user.setUserPassword(EncryptionUtils.getMd5(userPassword)); } if (StringUtils.isNotEmpty(email)) { if (!CheckUtils.checkEmail(email)) { logger.warn("Parameter email check failed."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, email); return result; } user.setEmail(email); } if (StringUtils.isNotEmpty(phone) && !CheckUtils.checkPhone(phone)) { logger.warn("Parameter phone check failed."); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, phone); return result; } if (state == 0 && user.getState() != state && Objects.equals(loginUser.getId(), user.getId())) { logger.warn("Not allow to disable your own account, userId:{}, userName:{}.", user.getId(), user.getUserName()); putMsg(result, Status.NOT_ALLOW_TO_DISABLE_OWN_ACCOUNT);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
return result; } if (StringUtils.isNotEmpty(timeZone)) { if (!CheckUtils.checkTimeZone(timeZone)) { logger.warn("Parameter time zone is illegal."); putMsg(result, Status.TIME_ZONE_ILLEGAL, timeZone); return result; } user.setTimeZone(timeZone); } user.setPhone(phone); user.setQueue(queue); user.setState(state); Date now = new Date(); user.setUpdateTime(now); user.setTenantId(tenantId); int update = userMapper.updateById(user); if (update > 0) { logger.info("User is updated and id is :{}.", userId); putMsg(result, Status.SUCCESS); } else { logger.error("User update error, userId:{}.", userId); putMsg(result, Status.UPDATE_USER_ERROR); } return result; } /** * delete user *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* @param loginUser login user * @param id user id * @return delete result code * @throws Exception exception when operate hdfs */ @Override @Transactional public Map<String, Object> deleteUserById(User loginUser, int id) throws IOException { Map<String, Object> result = new HashMap<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } if (!isAdmin(loginUser)) { logger.warn("User does not have permission for this feature, userId:{}, userName:{}.", loginUser.getId(), loginUser.getUserName()); putMsg(result, Status.USER_NO_OPERATION_PERM, id); return result; } User tempUser = userMapper.selectById(id); if (tempUser == null) { logger.error("User does not exist, userId:{}.", id); putMsg(result, Status.USER_NOT_EXIST, id); return result; } List<Project> projects = projectMapper.queryProjectCreatedByUser(id); if (CollectionUtils.isNotEmpty(projects)) { String projectNames = projects.stream().map(Project::getName).collect(Collectors.joining(","));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
putMsg(result, Status.TRANSFORM_PROJECT_OWNERSHIP, projectNames); logger.warn("Please transfer the project ownership before deleting the user, userId:{}, projects:{}.", id, projectNames); return result; } userMapper.queryTenantCodeByUserId(id); accessTokenMapper.deleteAccessTokenByUserId(id); if (userMapper.deleteById(id) > 0) { logger.info("User is deleted and id is :{}.", id); putMsg(result, Status.SUCCESS); return result; } else { logger.error("User delete error, userId:{}.", id); putMsg(result, Status.DELETE_USER_BY_ID_ERROR); return result; } } /** * grant project * * @param loginUser login user * @param userId user id * @param projectIds project id array * @return grant result code */ @Override @Transactional public Map<String, Object> grantProject(User loginUser, int userId, String projectIds) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } User tempUser = userMapper.selectById(userId); if (tempUser == null) { logger.error("User does not exist, userId:{}.", userId); putMsg(result, Status.USER_NOT_EXIST, userId); return result; } projectUserMapper.deleteProjectRelation(0, userId); if (check(result, StringUtils.isEmpty(projectIds), Status.SUCCESS)) { logger.warn("Parameter projectIds is empty."); return result; } Arrays.stream(projectIds.split(",")).distinct().forEach(projectId -> { Date now = new Date(); ProjectUser projectUser = new ProjectUser(); projectUser.setUserId(userId); projectUser.setProjectId(Integer.parseInt(projectId)); projectUser.setPerm(Constants.AUTHORIZE_WRITABLE_PERM); projectUser.setCreateTime(now); projectUser.setUpdateTime(now); projectUserMapper.insert(projectUser); }); putMsg(result, Status.SUCCESS); return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* grant project by code * * @param loginUser login user * @param userId user id * @param projectCode project code * @return grant result code */ @Override public Map<String, Object> grantProjectByCode(final User loginUser, final int userId, final long projectCode) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } User tempUser = this.userMapper.selectById(userId); if (tempUser == null) { logger.error("User does not exist, userId:{}.", userId); this.putMsg(result, Status.USER_NOT_EXIST, userId); return result; } Project project = this.projectMapper.queryByCode(projectCode); if (project == null) { logger.error("Project does not exist, projectCode:{}.", projectCode); this.putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
if (!this.canOperator(loginUser, project.getUserId())) { logger.warn("User does not have permission for project, userId:{}, userName:{}, projectCode:{}.", loginUser.getId(), loginUser.getUserName(), projectCode); this.putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } ProjectUser projectUser = projectUserMapper.queryProjectRelation(project.getId(), userId); if (projectUser == null) { Date today = new Date(); projectUser = new ProjectUser(); projectUser.setUserId(userId); projectUser.setProjectId(project.getId()); projectUser.setPerm(7); projectUser.setCreateTime(today); projectUser.setUpdateTime(today); this.projectUserMapper.insert(projectUser); } logger.info("User is granted permission for projects, userId:{}, projectCode:{}.", userId, projectCode); this.putMsg(result, Status.SUCCESS); return result; } /** * revoke the project permission for specified user. * * @param loginUser Login user * @param userId User id * @param projectCode Project Code * @return */ @Override
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
public Map<String, Object> revokeProject(User loginUser, int userId, long projectCode) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } if (this.check(result, !this.isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { logger.warn("Only admin can revoke the project permission."); return result; } User user = this.userMapper.selectById(userId); if (user == null) { logger.error("User does not exist, userId:{}.", userId); this.putMsg(result, Status.USER_NOT_EXIST, userId); return result; } Project project = this.projectMapper.queryByCode(projectCode); if (project == null) { logger.error("Project does not exist, projectCode:{}.", projectCode); this.putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); return result; } this.projectUserMapper.deleteProjectRelation(project.getId(), user.getId()); logger.info("User is revoked permission for projects, userId:{}, projectCode:{}.", userId, projectCode); this.putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
return result; } /** * grant resource * * @param loginUser login user * @param userId user id * @param resourceIds resource id array * @return grant result code */ @Override @Transactional public Map<String, Object> grantResources(User loginUser, int userId, String resourceIds) { Map<String, Object> result = new HashMap<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } User user = userMapper.selectById(userId); if (user == null) { logger.error("User does not exist, userId:{}.", userId); putMsg(result, Status.USER_NOT_EXIST, userId); return result; } Set<Integer> needAuthorizeResIds = new HashSet<>(); if (StringUtils.isNotBlank(resourceIds)) { String[] resourceFullIdArr = resourceIds.split(","); for (String resourceFullId : resourceFullIdArr) { String[] resourceIdArr = resourceFullId.split("-");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
for (int i = 0; i <= resourceIdArr.length - 1; i++) { int resourceIdValue = Integer.parseInt(resourceIdArr[i]); needAuthorizeResIds.add(resourceIdValue); } } } List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, Constants.AUTHORIZE_WRITABLE_PERM); List<Resource> oldAuthorizedRes = CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourceMapper.queryResourceListById(resIds); Set<Integer> oldAuthorizedResIds = oldAuthorizedRes.stream().map(Resource::getId).collect(Collectors.toSet()); oldAuthorizedResIds.removeAll(needAuthorizeResIds); if (CollectionUtils.isNotEmpty(oldAuthorizedResIds)) { List<Map<String, Object>> list = processDefinitionMapper.listResourcesByUser(userId); Map<Integer, Set<Long>> resourceProcessMap = ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(list); Set<Integer> resourceIdSet = resourceProcessMap.keySet(); resourceIdSet.retainAll(oldAuthorizedResIds); if (CollectionUtils.isNotEmpty(resourceIdSet)) { for (Integer resId : resourceIdSet) { logger.error("Resource id:{} is used by process definition {}", resId, resourceProcessMap.get(resId)); } putMsg(result, Status.RESOURCE_IS_USED); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
} resourceUserMapper.deleteResourceUser(userId, 0); if (check(result, StringUtils.isEmpty(resourceIds), Status.SUCCESS)) { logger.warn("Parameter resourceIds is empty."); return result; } for (int resourceIdValue : needAuthorizeResIds) { Resource resource = resourceMapper.selectById(resourceIdValue); if (resource == null) { logger.error("Resource does not exist, resourceId:{}.", resourceIdValue); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } Date now = new Date(); ResourcesUser resourcesUser = new ResourcesUser(); resourcesUser.setUserId(userId); resourcesUser.setResourcesId(resourceIdValue); if (resource.isDirectory()) { resourcesUser.setPerm(Constants.AUTHORIZE_READABLE_PERM); } else { resourcesUser.setPerm(Constants.AUTHORIZE_WRITABLE_PERM); } resourcesUser.setCreateTime(now); resourcesUser.setUpdateTime(now); resourceUserMapper.insert(resourcesUser); } logger.info("User is granted permission for resources, userId:{}, resourceIds:{}.", user.getId(), needAuthorizeResIds); putMsg(result, Status.SUCCESS); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
/** * grant udf function * * @param loginUser login user * @param userId user id * @param udfIds udf id array * @return grant result code */ @Override @Transactional public Map<String, Object> grantUDFFunction(User loginUser, int userId, String udfIds) { Map<String, Object> result = new HashMap<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } User user = userMapper.selectById(userId); if (user == null) { logger.error("User does not exist, userId:{}.", userId); putMsg(result, Status.USER_NOT_EXIST, userId); return result; } udfUserMapper.deleteByUserId(userId); if (check(result, StringUtils.isEmpty(udfIds), Status.SUCCESS)) { logger.warn("Parameter udfIds is empty."); return result; } String[] resourcesIdArr = udfIds.split(","); for (String udfId : resourcesIdArr) { Date now = new Date();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
UDFUser udfUser = new UDFUser(); udfUser.setUserId(userId); udfUser.setUdfId(Integer.parseInt(udfId)); udfUser.setPerm(Constants.AUTHORIZE_WRITABLE_PERM); udfUser.setCreateTime(now); udfUser.setUpdateTime(now); udfUserMapper.insert(udfUser); } logger.info("User is granted permission for UDF, userName:{}.", user.getUserName()); putMsg(result, Status.SUCCESS); return result; } /** * grant namespace * * @param loginUser login user * @param userId user id * @param namespaceIds namespace id array * @return grant result code */ @Override @Transactional public Map<String, Object> grantNamespaces(User loginUser, int userId, String namespaceIds) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
if (this.check(result, !this.isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { logger.warn("Only admin can grant namespaces."); return result; } User tempUser = userMapper.selectById(userId); if (tempUser == null) { logger.error("User does not exist, userId:{}.", userId); putMsg(result, Status.USER_NOT_EXIST, userId); return result; } k8sNamespaceUserMapper.deleteNamespaceRelation(0, userId); if (StringUtils.isNotEmpty(namespaceIds)) { String[] namespaceIdArr = namespaceIds.split(","); for (String namespaceId : namespaceIdArr) { Date now = new Date(); K8sNamespaceUser namespaceUser = new K8sNamespaceUser(); namespaceUser.setUserId(userId); namespaceUser.setNamespaceId(Integer.parseInt(namespaceId)); namespaceUser.setPerm(7); namespaceUser.setCreateTime(now); namespaceUser.setUpdateTime(now); k8sNamespaceUserMapper.insert(namespaceUser); } } logger.info("User is granted permission for namespace, userId:{}.", tempUser.getId()); putMsg(result, Status.SUCCESS); return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* grant datasource * * @param loginUser login user * @param userId user id * @param datasourceIds data source id array * @return grant result code */ @Override @Transactional public Map<String, Object> grantDataSource(User loginUser, int userId, String datasourceIds) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } User user = userMapper.selectById(userId); if (user == null) { putMsg(result, Status.USER_NOT_EXIST, userId); return result; } datasourceUserMapper.deleteByUserId(userId); if (check(result, StringUtils.isEmpty(datasourceIds), Status.SUCCESS)) { return result; } String[] datasourceIdArr = datasourceIds.split(","); for (String datasourceId : datasourceIdArr) { Date now = new Date(); DatasourceUser datasourceUser = new DatasourceUser(); datasourceUser.setUserId(userId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
datasourceUser.setDatasourceId(Integer.parseInt(datasourceId)); datasourceUser.setPerm(Constants.AUTHORIZE_WRITABLE_PERM); datasourceUser.setCreateTime(now); datasourceUser.setUpdateTime(now); datasourceUserMapper.insert(datasourceUser); } putMsg(result, Status.SUCCESS); return result; } /** * query user info * * @param loginUser login user * @return user info */ @Override public Map<String, Object> getUserInfo(User loginUser) { Map<String, Object> result = new HashMap<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } User user = null; if (loginUser.getUserType() == UserType.ADMIN_USER) { user = loginUser; } else { user = userMapper.queryDetailsById(loginUser.getId()); List<AlertGroup> alertGroups = alertGroupMapper.queryByUserId(loginUser.getId()); StringBuilder sb = new StringBuilder(); if (alertGroups != null && !alertGroups.isEmpty()) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
for (int i = 0; i < alertGroups.size() - 1; i++) { sb.append(alertGroups.get(i).getGroupName()).append(","); } sb.append(alertGroups.get(alertGroups.size() - 1)); user.setAlertGroup(sb.toString()); } } if (StringUtils.isEmpty(user.getTimeZone())) { user.setTimeZone(TimeZone.getDefault().toZoneId().getId()); } result.put(Constants.DATA_LIST, user); putMsg(result, Status.SUCCESS); return result; } /** * query user list * * @param loginUser login user * @return user list */ @Override public Map<String, Object> queryAllGeneralUsers(User loginUser) { Map<String, Object> result = new HashMap<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
logger.warn("Only admin can query all general users."); return result; } List<User> userList = userMapper.queryAllGeneralUser(); result.put(Constants.DATA_LIST, userList); putMsg(result, Status.SUCCESS); return result; } /** * query user list * * @param loginUser login user * @return user list */ @Override public Map<String, Object> queryUserList(User loginUser) { Map<String, Object> result = new HashMap<>(); if (!canOperatorPermissions(loginUser, null, AuthorizationType.ACCESS_TOKEN, USER_MANAGER)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } List<User> userList = userMapper.queryEnabledUsers(); result.put(Constants.DATA_LIST, userList); putMsg(result, Status.SUCCESS); return result; } /** * verify user name exists *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* @param userName user name * @return true if user name not exists, otherwise return false */ @Override public Result<Object> verifyUserName(String userName) { Result<Object> result = new Result<>(); User user = userMapper.queryByUserNameAccurately(userName); if (user != null) { putMsg(result, Status.USER_NAME_EXIST); } else { putMsg(result, Status.SUCCESS); } return result; } /** * unauthorized user * * @param loginUser login user * @param alertgroupId alert group id * @return unauthorize result code */ @Override public Map<String, Object> unauthorizedUser(User loginUser, Integer alertgroupId) { Map<String, Object> result = new HashMap<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
logger.warn("Only admin can deauthorize user."); return result; } List<User> userList = userMapper.selectList(null); List<User> resultUsers = new ArrayList<>(); Set<User> userSet = null; if (userList != null && !userList.isEmpty()) { userSet = new HashSet<>(userList); List<User> authedUserList = userMapper.queryUserListByAlertGroupId(alertgroupId); Set<User> authedUserSet = null; if (authedUserList != null && !authedUserList.isEmpty()) { authedUserSet = new HashSet<>(authedUserList); userSet.removeAll(authedUserSet); } resultUsers = new ArrayList<>(userSet); } result.put(Constants.DATA_LIST, resultUsers); putMsg(result, Status.SUCCESS); return result; } /** * authorized user * * @param loginUser login user * @param alertGroupId alert group id * @return authorized result code */ @Override public Map<String, Object> authorizedUser(User loginUser, Integer alertGroupId) { Map<String, Object> result = new HashMap<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { logger.warn("Only admin can authorize user."); return result; } List<User> userList = userMapper.queryUserListByAlertGroupId(alertGroupId); result.put(Constants.DATA_LIST, userList); putMsg(result, Status.SUCCESS); return result; } /** * @param tenantId tenant id * @return true if tenant exists, otherwise return false */ private boolean checkTenantExists(int tenantId) { return tenantMapper.queryById(tenantId) != null; } /** * @return if check failed return the field, otherwise return null */ private String checkUserParams(String userName, String password, String email, String phone) { String msg = null; if (!CheckUtils.checkUserName(userName)) { logger.warn("Parameter userName check failed."); msg = userName; } else if (!CheckUtils.checkPassword(password)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
logger.warn("Parameter password check failed."); msg = password; } else if (!CheckUtils.checkEmail(email)) { logger.warn("Parameter email check failed."); msg = email; } else if (!CheckUtils.checkPhone(phone)) { logger.warn("Parameter phone check failed."); msg = phone; } return msg; } /** * copy resource files * xxx unchecked * * @param resourceComponent resource component * @param srcBasePath src base path * @param dstBasePath dst base path * @throws IOException io exception */ private void copyResourceFiles(String oldTenantCode, String newTenantCode, ResourceComponent resourceComponent, String srcBasePath, String dstBasePath) { List<ResourceComponent> components = resourceComponent.getChildren(); try { if (CollectionUtils.isNotEmpty(components)) { for (ResourceComponent component : components) { if (!storageOperate.exists(oldTenantCode, String.format(Constants.FORMAT_S_S, srcBasePath, component.getFullName()))) { logger.error("Resource file: {} does not exist, copy error.", component.getFullName());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
throw new ServiceException(Status.RESOURCE_NOT_EXIST); } if (!component.isDirctory()) { storageOperate.copy(String.format(Constants.FORMAT_S_S, srcBasePath, component.getFullName()), String.format(Constants.FORMAT_S_S, dstBasePath, component.getFullName()), false, true); continue; } if (CollectionUtils.isEmpty(component.getChildren())) { if (!storageOperate.exists(oldTenantCode, String.format(Constants.FORMAT_S_S, dstBasePath, component.getFullName()))) { storageOperate.mkdir(newTenantCode, String.format(Constants.FORMAT_S_S, dstBasePath, component.getFullName())); } } else { copyResourceFiles(oldTenantCode, newTenantCode, component, srcBasePath, dstBasePath); } } } } catch (IOException e) { logger.error("copy the resources failed,the error message is {}", e.getMessage()); } } /** * registry user, default state is 0, default tenant_id is 1, no phone, no queue * * @param userName user name * @param userPassword user password * @param repeatPassword repeat password
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* @param email email * @return registry result code * @throws Exception exception */ @Override @Transactional public Map<String, Object> registerUser(String userName, String userPassword, String repeatPassword, String email) { Map<String, Object> result = new HashMap<>(); String msg = this.checkUserParams(userName, userPassword, email, ""); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } if (!StringUtils.isEmpty(msg)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg); return result; } if (!userPassword.equals(repeatPassword)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "two passwords are not same"); return result; } User user = createUser(userName, userPassword, email, 1, "", "", Flag.NO.ordinal()); putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, user); return result; } /** * activate user, only system admin have permission, change user state code 0 to 1 *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* @param loginUser login user * @param userName user name * @return create result code */ @Override public Map<String, Object> activateUser(User loginUser, String userName) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (!CheckUtils.checkUserName(userName)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName); return result; } User user = userMapper.queryByUserNameAccurately(userName); if (user == null) { putMsg(result, Status.USER_NOT_EXIST, userName); return result; } if (user.getState() != Flag.NO.ordinal()) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName); return result; } user.setState(Flag.YES.ordinal());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
Date now = new Date(); user.setUpdateTime(now); userMapper.updateById(user); User responseUser = userMapper.queryByUserNameAccurately(userName); putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, responseUser); return result; } /** * activate user, only system admin have permission, change users state code 0 to 1 * * @param loginUser login user * @param userNames user name * @return create result code */ @Override public Map<String, Object> batchActivateUser(User loginUser, List<String> userNames) { Map<String, Object> result = new HashMap<>(); if (resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } int totalSuccess = 0; List<String> successUserNames = new ArrayList<>(); Map<String, Object> successRes = new HashMap<>(); int totalFailed = 0;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
List<Map<String, String>> failedInfo = new ArrayList<>(); Map<String, Object> failedRes = new HashMap<>(); for (String userName : userNames) { Map<String, Object> tmpResult = activateUser(loginUser, userName); if (tmpResult.get(Constants.STATUS) != Status.SUCCESS) { totalFailed++; Map<String, String> failedBody = new HashMap<>(); failedBody.put("userName", userName); Status status = (Status) tmpResult.get(Constants.STATUS); String errorMessage = MessageFormat.format(status.getMsg(), userName); failedBody.put("msg", errorMessage); failedInfo.add(failedBody); } else { totalSuccess++; successUserNames.add(userName); } } successRes.put("sum", totalSuccess); successRes.put("userName", successUserNames); failedRes.put("sum", totalFailed); failedRes.put("info", failedInfo); Map<String, Object> res = new HashMap<>(); res.put("success", successRes); res.put("failed", failedRes); putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, res); return result; } /** * Make sure user with given name exists, and create the user if not exists
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* <p> * ONLY for python gateway server, and should not use this in web ui function * * @param userName user name * @param userPassword user password * @param email user email * @param phone user phone * @param tenantCode tenant code * @param queue queue * @param state state * @return create result code */ @Override @Transactional public User createUserIfNotExists(String userName, String userPassword, String email, String phone, String tenantCode, String queue, int state) throws IOException { User user = userMapper.queryByUserNameAccurately(userName); if (Objects.isNull(user)) { Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); user = createUser(userName, userPassword, email, tenant.getId(), phone, queue, state); return user; } updateUser(user, user.getId(), userName, userPassword, email, user.getTenantId(), phone, queue, state, null); user = userMapper.queryDetailsById(user.getId()); return user; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/config/StoreConfiguration.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.common.config; import static org.apache.dolphinscheduler.common.Constants.RESOURCE_STORAGE_TYPE; import static org.apache.dolphinscheduler.common.Constants.STORAGE_HDFS; import static org.apache.dolphinscheduler.common.Constants.STORAGE_OSS; import static org.apache.dolphinscheduler.common.Constants.STORAGE_S3; import org.apache.dolphinscheduler.common.storage.StorageOperate; import org.apache.dolphinscheduler.common.utils.HadoopUtils; import org.apache.dolphinscheduler.common.utils.OssOperator;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,279
[Bug] [API] When creating a user and throwing an exception the user can be created successfully.
### 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 Currently when creating a user in DolphinScheduler the API will create the resource directory at the same time. Sometimes the settings of storage is not correct, so the process of creating the resource file will throw an exception. But the strategy of rollback didn't work. It's because that the annotation of '@Transactional' just deal with the exception of the RuntimeException type by default. ![image](https://user-images.githubusercontent.com/4928204/194749641-ce531436-5cb8-4a3a-b46e-6c633e85aecd.png) ![image](https://user-images.githubusercontent.com/4928204/194747885-74de5537-2afe-4e48-8a61-80e0ea25ef9c.png) ### What you expected to happen When creating a user and throwing an exception the user shouldn't be created successfully. ### How to reproduce First of all you should modify the file of 'common.properties' to set a few settings of resource storage like: ``` resource.storage.type=HDFS resource.storage.upload.base.path=/dolphinscheduler resource.hdfs.root.user=calvin resource.hdfs.fs.defaultFS=hdfs://xxxxxx:8020 ``` To make sure the user 'calvin' has no permissions to access the resource file '/dolphinscheduler'. And then to create a new user you will see this problem. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12279
https://github.com/apache/dolphinscheduler/pull/12281
7bf49a71795c4aa7e9544ce794e99b74950ccbf2
b4947b471cad5d4b939f5a5f4a978c786c4decdc
2022-10-09T09:58:03Z
java
2022-10-10T01:34:32Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/config/StoreConfiguration.java
import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.common.utils.S3Utils; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; /** * choose the impl of storage by RESOURCE_STORAGE_TYPE */ @Component @Configuration public class StoreConfiguration { @Bean public StorageOperate storageOperate() { switch (PropertyUtils.getString(RESOURCE_STORAGE_TYPE)) { case STORAGE_OSS: OssOperator ossOperator = new OssOperator(); ossOperator.init(); return ossOperator; case STORAGE_S3: return S3Utils.getInstance(); case STORAGE_HDFS: return HadoopUtils.getInstance(); default: return null; } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,231
[Bug] [service] Some scheduled tasks are not triggered on time
### 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 数仓同学凌晨报告昨日新增任务未按时触发,问题非常严重,严重影响生产,经排查quartz插件默认参数及cronTrigger对象初始化参数在调度平台同一时刻触发大量任务时会导致调度任务超过触发等待阈值从而导致任务未触发。首先默认参数为org.quartz.threadPool.threadCount = 25、org.quartz.jobStore.misfireThreshold = 60000,cronTrigger错失触发处理策略为MISFIRE_INSTRUCTION_DO_NOTHING,即直接抛弃该定时任务。触发任务丢失的条件为同一时刻同时调度大量任务,数仓同学某一时刻批量提交近4000任务(线上2个master)。在调大org.quartz.threadPool.threadCount参数和增加master个数后60s内处理的任务数并没有较大变化(经查看quartz源码,其使用数据库悲观锁来保证并发安全)。因此建议cronTrigger错失触发的处理策略改为直接触发策略(保证系统在处理不过来时任务不丢失,可延迟执行),即处理misfire api由withMisfireHandlingInstructionDoNothing改为withMisfireHandlingInstructionFireAndProceed。 In the early morning, the co-worker from data warehouse reported that the newly added tasks were not triggered on time. The problem was very serious and seriously affected production. After investigation, the default parameters of the quartz plugin and the initialization parameters of the cronTrigger object will cause the scheduling tasks to exceed the trigger waiting threshold when a large number of tasks are triggered at the same time on the scheduling platform. Causes the task not to trigger. First, the default parameters are org.quartz.threadPool.threadCount = 25, org.quartz.jobStore.misfireThreshold = 60000, and the cronTrigger miss trigger processing strategy is MISFIRE_INSTRUCTION_DO_NOTHING, that is, the timing task is directly abandoned. The condition for triggering the loss of tasks is to schedule a large number of tasks at the same time, and the co-worker from data warehouse submit nearly 4,000 tasks in batches (2 online masters) at a certain time. After increasing the org.quartz.threadPool.threadCount parameter and increasing the number of masters, the number of tasks processed within 60s does not change significantly (after viewing the quartz source code, it uses database pessimistic locks to ensure concurrency safety). Therefore, it is recommended that the processing strategy of cronTrigger's missed trigger be changed to a direct trigger strategy (to ensure that the task is not lost when the system cannot handle it, and the execution can be delayed), that is, the processing of misfire api is changed from withMisfireHandlingInstructionDoNothing to withMisfireHandlingInstructionFireAndProceed. ![image](https://user-images.githubusercontent.com/6930421/193210955-123a5348-e45a-46dc-b3cb-d55fd9ba933b.png) ### What you expected to happen Change a default strategy, at least ensure that the task is not lost. ### How to reproduce A large number of scheduling tasks are triggered at the same time. ### Anything else Every version of the project has this probelm. ### Version 3.0.x ### 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/12231
https://github.com/apache/dolphinscheduler/pull/12233
c8bd106604ea4136c91f5592265b270cb9e7e092
d9ac1fa0f70322de4985285231058f6a2e353325
2022-09-30T07:20:00Z
java
2022-10-10T06:01:02Z
dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/QuartzScheduler.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.scheduler.quartz; import static org.quartz.CronScheduleBuilder.cronSchedule; import static org.quartz.JobBuilder.newJob; import static org.quartz.TriggerBuilder.newTrigger; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.scheduler.api.SchedulerApi;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,231
[Bug] [service] Some scheduled tasks are not triggered on time
### 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 数仓同学凌晨报告昨日新增任务未按时触发,问题非常严重,严重影响生产,经排查quartz插件默认参数及cronTrigger对象初始化参数在调度平台同一时刻触发大量任务时会导致调度任务超过触发等待阈值从而导致任务未触发。首先默认参数为org.quartz.threadPool.threadCount = 25、org.quartz.jobStore.misfireThreshold = 60000,cronTrigger错失触发处理策略为MISFIRE_INSTRUCTION_DO_NOTHING,即直接抛弃该定时任务。触发任务丢失的条件为同一时刻同时调度大量任务,数仓同学某一时刻批量提交近4000任务(线上2个master)。在调大org.quartz.threadPool.threadCount参数和增加master个数后60s内处理的任务数并没有较大变化(经查看quartz源码,其使用数据库悲观锁来保证并发安全)。因此建议cronTrigger错失触发的处理策略改为直接触发策略(保证系统在处理不过来时任务不丢失,可延迟执行),即处理misfire api由withMisfireHandlingInstructionDoNothing改为withMisfireHandlingInstructionFireAndProceed。 In the early morning, the co-worker from data warehouse reported that the newly added tasks were not triggered on time. The problem was very serious and seriously affected production. After investigation, the default parameters of the quartz plugin and the initialization parameters of the cronTrigger object will cause the scheduling tasks to exceed the trigger waiting threshold when a large number of tasks are triggered at the same time on the scheduling platform. Causes the task not to trigger. First, the default parameters are org.quartz.threadPool.threadCount = 25, org.quartz.jobStore.misfireThreshold = 60000, and the cronTrigger miss trigger processing strategy is MISFIRE_INSTRUCTION_DO_NOTHING, that is, the timing task is directly abandoned. The condition for triggering the loss of tasks is to schedule a large number of tasks at the same time, and the co-worker from data warehouse submit nearly 4,000 tasks in batches (2 online masters) at a certain time. After increasing the org.quartz.threadPool.threadCount parameter and increasing the number of masters, the number of tasks processed within 60s does not change significantly (after viewing the quartz source code, it uses database pessimistic locks to ensure concurrency safety). Therefore, it is recommended that the processing strategy of cronTrigger's missed trigger be changed to a direct trigger strategy (to ensure that the task is not lost when the system cannot handle it, and the execution can be delayed), that is, the processing of misfire api is changed from withMisfireHandlingInstructionDoNothing to withMisfireHandlingInstructionFireAndProceed. ![image](https://user-images.githubusercontent.com/6930421/193210955-123a5348-e45a-46dc-b3cb-d55fd9ba933b.png) ### What you expected to happen Change a default strategy, at least ensure that the task is not lost. ### How to reproduce A large number of scheduling tasks are triggered at the same time. ### Anything else Every version of the project has this probelm. ### Version 3.0.x ### 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/12231
https://github.com/apache/dolphinscheduler/pull/12233
c8bd106604ea4136c91f5592265b270cb9e7e092
d9ac1fa0f70322de4985285231058f6a2e353325
2022-09-30T07:20:00Z
java
2022-10-10T06:01:02Z
dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/QuartzScheduler.java
import org.apache.dolphinscheduler.scheduler.api.SchedulerException; import org.apache.dolphinscheduler.scheduler.quartz.utils.QuartzTaskUtils; import java.util.Date; import java.util.Map; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.quartz.CronTrigger; import org.quartz.JobDetail; import org.quartz.JobKey; import org.quartz.Scheduler; import org.quartz.TriggerKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import com.google.common.base.Strings; public class QuartzScheduler implements SchedulerApi { private static final Logger logger = LoggerFactory.getLogger(QuartzScheduler.class); @Autowired private Scheduler scheduler; private final ReadWriteLock lock = new ReentrantReadWriteLock(); @Override public void start() throws SchedulerException { try { scheduler.start(); } catch (Exception e) { throw new SchedulerException("Failed to start quartz scheduler ", e); } } @Override public void insertOrUpdateScheduleTask(int projectId, Schedule schedule) throws SchedulerException {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,231
[Bug] [service] Some scheduled tasks are not triggered on time
### 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 数仓同学凌晨报告昨日新增任务未按时触发,问题非常严重,严重影响生产,经排查quartz插件默认参数及cronTrigger对象初始化参数在调度平台同一时刻触发大量任务时会导致调度任务超过触发等待阈值从而导致任务未触发。首先默认参数为org.quartz.threadPool.threadCount = 25、org.quartz.jobStore.misfireThreshold = 60000,cronTrigger错失触发处理策略为MISFIRE_INSTRUCTION_DO_NOTHING,即直接抛弃该定时任务。触发任务丢失的条件为同一时刻同时调度大量任务,数仓同学某一时刻批量提交近4000任务(线上2个master)。在调大org.quartz.threadPool.threadCount参数和增加master个数后60s内处理的任务数并没有较大变化(经查看quartz源码,其使用数据库悲观锁来保证并发安全)。因此建议cronTrigger错失触发的处理策略改为直接触发策略(保证系统在处理不过来时任务不丢失,可延迟执行),即处理misfire api由withMisfireHandlingInstructionDoNothing改为withMisfireHandlingInstructionFireAndProceed。 In the early morning, the co-worker from data warehouse reported that the newly added tasks were not triggered on time. The problem was very serious and seriously affected production. After investigation, the default parameters of the quartz plugin and the initialization parameters of the cronTrigger object will cause the scheduling tasks to exceed the trigger waiting threshold when a large number of tasks are triggered at the same time on the scheduling platform. Causes the task not to trigger. First, the default parameters are org.quartz.threadPool.threadCount = 25, org.quartz.jobStore.misfireThreshold = 60000, and the cronTrigger miss trigger processing strategy is MISFIRE_INSTRUCTION_DO_NOTHING, that is, the timing task is directly abandoned. The condition for triggering the loss of tasks is to schedule a large number of tasks at the same time, and the co-worker from data warehouse submit nearly 4,000 tasks in batches (2 online masters) at a certain time. After increasing the org.quartz.threadPool.threadCount parameter and increasing the number of masters, the number of tasks processed within 60s does not change significantly (after viewing the quartz source code, it uses database pessimistic locks to ensure concurrency safety). Therefore, it is recommended that the processing strategy of cronTrigger's missed trigger be changed to a direct trigger strategy (to ensure that the task is not lost when the system cannot handle it, and the execution can be delayed), that is, the processing of misfire api is changed from withMisfireHandlingInstructionDoNothing to withMisfireHandlingInstructionFireAndProceed. ![image](https://user-images.githubusercontent.com/6930421/193210955-123a5348-e45a-46dc-b3cb-d55fd9ba933b.png) ### What you expected to happen Change a default strategy, at least ensure that the task is not lost. ### How to reproduce A large number of scheduling tasks are triggered at the same time. ### Anything else Every version of the project has this probelm. ### Version 3.0.x ### 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/12231
https://github.com/apache/dolphinscheduler/pull/12233
c8bd106604ea4136c91f5592265b270cb9e7e092
d9ac1fa0f70322de4985285231058f6a2e353325
2022-09-30T07:20:00Z
java
2022-10-10T06:01:02Z
dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/QuartzScheduler.java
JobKey jobKey = QuartzTaskUtils.getJobKey(schedule.getId(), projectId); Map<String, Object> jobDataMap = QuartzTaskUtils.buildDataMap(projectId, schedule); String cronExpression = schedule.getCrontab(); String timezoneId = schedule.getTimezoneId(); /** * transform from server default timezone to schedule timezone * e.g. server default timezone is `UTC` * user set a schedule with startTime `2022-04-28 10:00:00`, timezone is `Asia/Shanghai`, * api skip to transform it and save into databases directly, startTime `2022-04-28 10:00:00`, timezone is `UTC`, which actually added 8 hours, * so when add job to quartz, it should recover by transform timezone */ Date startDate = DateUtils.transformTimezoneDate(schedule.getStartTime(), timezoneId); Date endDate = DateUtils.transformTimezoneDate(schedule.getEndTime(), timezoneId); lock.writeLock().lock(); try { JobDetail jobDetail; if (scheduler.checkExists(jobKey)) { jobDetail = scheduler.getJobDetail(jobKey); jobDetail.getJobDataMap().putAll(jobDataMap); } else { jobDetail = newJob(ProcessScheduleTask.class).withIdentity(jobKey).build(); jobDetail.getJobDataMap().putAll(jobDataMap); scheduler.addJob(jobDetail, false, true); logger.info("Add job, job name: {}, group name: {}", jobKey.getName(), jobKey.getGroup()); } TriggerKey triggerKey = new TriggerKey(jobKey.getName(), jobKey.getGroup()); /* * Instructs the Scheduler that upon a mis-fire * situation, the CronTrigger wants to have it's
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,231
[Bug] [service] Some scheduled tasks are not triggered on time
### 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 数仓同学凌晨报告昨日新增任务未按时触发,问题非常严重,严重影响生产,经排查quartz插件默认参数及cronTrigger对象初始化参数在调度平台同一时刻触发大量任务时会导致调度任务超过触发等待阈值从而导致任务未触发。首先默认参数为org.quartz.threadPool.threadCount = 25、org.quartz.jobStore.misfireThreshold = 60000,cronTrigger错失触发处理策略为MISFIRE_INSTRUCTION_DO_NOTHING,即直接抛弃该定时任务。触发任务丢失的条件为同一时刻同时调度大量任务,数仓同学某一时刻批量提交近4000任务(线上2个master)。在调大org.quartz.threadPool.threadCount参数和增加master个数后60s内处理的任务数并没有较大变化(经查看quartz源码,其使用数据库悲观锁来保证并发安全)。因此建议cronTrigger错失触发的处理策略改为直接触发策略(保证系统在处理不过来时任务不丢失,可延迟执行),即处理misfire api由withMisfireHandlingInstructionDoNothing改为withMisfireHandlingInstructionFireAndProceed。 In the early morning, the co-worker from data warehouse reported that the newly added tasks were not triggered on time. The problem was very serious and seriously affected production. After investigation, the default parameters of the quartz plugin and the initialization parameters of the cronTrigger object will cause the scheduling tasks to exceed the trigger waiting threshold when a large number of tasks are triggered at the same time on the scheduling platform. Causes the task not to trigger. First, the default parameters are org.quartz.threadPool.threadCount = 25, org.quartz.jobStore.misfireThreshold = 60000, and the cronTrigger miss trigger processing strategy is MISFIRE_INSTRUCTION_DO_NOTHING, that is, the timing task is directly abandoned. The condition for triggering the loss of tasks is to schedule a large number of tasks at the same time, and the co-worker from data warehouse submit nearly 4,000 tasks in batches (2 online masters) at a certain time. After increasing the org.quartz.threadPool.threadCount parameter and increasing the number of masters, the number of tasks processed within 60s does not change significantly (after viewing the quartz source code, it uses database pessimistic locks to ensure concurrency safety). Therefore, it is recommended that the processing strategy of cronTrigger's missed trigger be changed to a direct trigger strategy (to ensure that the task is not lost when the system cannot handle it, and the execution can be delayed), that is, the processing of misfire api is changed from withMisfireHandlingInstructionDoNothing to withMisfireHandlingInstructionFireAndProceed. ![image](https://user-images.githubusercontent.com/6930421/193210955-123a5348-e45a-46dc-b3cb-d55fd9ba933b.png) ### What you expected to happen Change a default strategy, at least ensure that the task is not lost. ### How to reproduce A large number of scheduling tasks are triggered at the same time. ### Anything else Every version of the project has this probelm. ### Version 3.0.x ### 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/12231
https://github.com/apache/dolphinscheduler/pull/12233
c8bd106604ea4136c91f5592265b270cb9e7e092
d9ac1fa0f70322de4985285231058f6a2e353325
2022-09-30T07:20:00Z
java
2022-10-10T06:01:02Z
dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/QuartzScheduler.java
* next-fire-time updated to the next time in the schedule after the * current time (taking into account any associated Calendar), * but it does not want to be fired now. */ CronTrigger cronTrigger = newTrigger() .withIdentity(triggerKey) .startAt(startDate) .endAt(endDate) .withSchedule( cronSchedule(cronExpression) .withMisfireHandlingInstructionDoNothing() .inTimeZone(DateUtils.getTimezone(timezoneId)) ) .forJob(jobDetail).build(); if (scheduler.checkExists(triggerKey)) { CronTrigger oldCronTrigger = (CronTrigger) scheduler.getTrigger(triggerKey); String oldCronExpression = oldCronTrigger.getCronExpression(); if (!Strings.nullToEmpty(cronExpression).equalsIgnoreCase(Strings.nullToEmpty(oldCronExpression))) { scheduler.rescheduleJob(triggerKey, cronTrigger); logger.info("reschedule job trigger, triggerName: {}, triggerGroupName: {}, cronExpression: {}, startDate: {}, endDate: {}", triggerKey.getName(), triggerKey.getGroup(), cronExpression, startDate, endDate); } } else { scheduler.scheduleJob(cronTrigger); logger.info("schedule job trigger, triggerName: {}, triggerGroupName: {}, cronExpression: {}, startDate: {}, endDate: {}", triggerKey.getName(), triggerKey.getGroup(), cronExpression, startDate, endDate); } } catch (Exception e) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,231
[Bug] [service] Some scheduled tasks are not triggered on time
### 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 数仓同学凌晨报告昨日新增任务未按时触发,问题非常严重,严重影响生产,经排查quartz插件默认参数及cronTrigger对象初始化参数在调度平台同一时刻触发大量任务时会导致调度任务超过触发等待阈值从而导致任务未触发。首先默认参数为org.quartz.threadPool.threadCount = 25、org.quartz.jobStore.misfireThreshold = 60000,cronTrigger错失触发处理策略为MISFIRE_INSTRUCTION_DO_NOTHING,即直接抛弃该定时任务。触发任务丢失的条件为同一时刻同时调度大量任务,数仓同学某一时刻批量提交近4000任务(线上2个master)。在调大org.quartz.threadPool.threadCount参数和增加master个数后60s内处理的任务数并没有较大变化(经查看quartz源码,其使用数据库悲观锁来保证并发安全)。因此建议cronTrigger错失触发的处理策略改为直接触发策略(保证系统在处理不过来时任务不丢失,可延迟执行),即处理misfire api由withMisfireHandlingInstructionDoNothing改为withMisfireHandlingInstructionFireAndProceed。 In the early morning, the co-worker from data warehouse reported that the newly added tasks were not triggered on time. The problem was very serious and seriously affected production. After investigation, the default parameters of the quartz plugin and the initialization parameters of the cronTrigger object will cause the scheduling tasks to exceed the trigger waiting threshold when a large number of tasks are triggered at the same time on the scheduling platform. Causes the task not to trigger. First, the default parameters are org.quartz.threadPool.threadCount = 25, org.quartz.jobStore.misfireThreshold = 60000, and the cronTrigger miss trigger processing strategy is MISFIRE_INSTRUCTION_DO_NOTHING, that is, the timing task is directly abandoned. The condition for triggering the loss of tasks is to schedule a large number of tasks at the same time, and the co-worker from data warehouse submit nearly 4,000 tasks in batches (2 online masters) at a certain time. After increasing the org.quartz.threadPool.threadCount parameter and increasing the number of masters, the number of tasks processed within 60s does not change significantly (after viewing the quartz source code, it uses database pessimistic locks to ensure concurrency safety). Therefore, it is recommended that the processing strategy of cronTrigger's missed trigger be changed to a direct trigger strategy (to ensure that the task is not lost when the system cannot handle it, and the execution can be delayed), that is, the processing of misfire api is changed from withMisfireHandlingInstructionDoNothing to withMisfireHandlingInstructionFireAndProceed. ![image](https://user-images.githubusercontent.com/6930421/193210955-123a5348-e45a-46dc-b3cb-d55fd9ba933b.png) ### What you expected to happen Change a default strategy, at least ensure that the task is not lost. ### How to reproduce A large number of scheduling tasks are triggered at the same time. ### Anything else Every version of the project has this probelm. ### Version 3.0.x ### 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/12231
https://github.com/apache/dolphinscheduler/pull/12233
c8bd106604ea4136c91f5592265b270cb9e7e092
d9ac1fa0f70322de4985285231058f6a2e353325
2022-09-30T07:20:00Z
java
2022-10-10T06:01:02Z
dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/QuartzScheduler.java
logger.error("Failed to add scheduler task, projectId: {}, scheduler: {}", projectId, schedule, e); throw new SchedulerException("Add schedule job failed", e); } finally { lock.writeLock().unlock(); } } @Override public void deleteScheduleTask(int projectId, int scheduleId) throws SchedulerException { JobKey jobKey = QuartzTaskUtils.getJobKey(scheduleId, projectId); try { if (scheduler.checkExists(jobKey)) { logger.info("Try to delete scheduler task, projectId: {}, schedulerId: {}", projectId, scheduleId); scheduler.deleteJob(jobKey); } } catch (Exception e) { logger.error("Failed to delete scheduler task, projectId: {}, schedulerId: {}", projectId, scheduleId, e); throw new SchedulerException("Failed to delete scheduler task"); } } @Override public void close() { try { scheduler.shutdown(); } catch (org.quartz.SchedulerException e) { throw new SchedulerException("Failed to shutdown scheduler", e); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
* the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.service.impl; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.TASK_DEFINITION_MOVE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_DELETE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_LIST; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_BATCH_COPY; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_CREATE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION_DELETE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION_EXPORT; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_EXPORT; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_IMPORT; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_ONLINE_OFFLINE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_SWITCH_TO_THIS_VERSION; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_TREE_VIEW; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_UPDATE; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE; import static org.apache.dolphinscheduler.common.Constants.COPY_SUFFIX; import static org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP; import static org.apache.dolphinscheduler.common.Constants.EMPTY_STRING; import static org.apache.dolphinscheduler.common.Constants.IMPORT_SUFFIX;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.COMPLEX_TASK_TYPES; import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SQL; import org.apache.dolphinscheduler.api.dto.DagDataSchedule; import org.apache.dolphinscheduler.api.dto.ScheduleParam; import org.apache.dolphinscheduler.api.dto.treeview.Instance; import org.apache.dolphinscheduler.api.dto.treeview.TreeViewDto; import org.apache.dolphinscheduler.api.dto.workflow.WorkflowCreateRequest; import org.apache.dolphinscheduler.api.dto.workflow.WorkflowFilterRequest; import org.apache.dolphinscheduler.api.dto.workflow.WorkflowUpdateRequest; 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.ProcessInstanceService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.SchedulerService; import org.apache.dolphinscheduler.api.service.WorkFlowLineageService; import org.apache.dolphinscheduler.api.utils.CheckUtils; import org.apache.dolphinscheduler.api.utils.FileUtils; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.ConditionType; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ProcessExecutionTypeEnum; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.WarningType;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
import org.apache.dolphinscheduler.common.graph.DAG; import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager; import org.apache.dolphinscheduler.common.model.TaskNode; import org.apache.dolphinscheduler.common.model.TaskNodeRelation; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.DagData; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.DependentSimplifyDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.TaskMainInfo; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationLogMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.model.PageListingResult; import org.apache.dolphinscheduler.dao.repository.ProcessDefinitionDao; import org.apache.dolphinscheduler.plugin.task.api.enums.SqlType; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; import org.apache.dolphinscheduler.plugin.task.api.parameters.SqlParameters; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import lombok.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.collect.Lists; /** * process definition service impl */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements ProcessDefinitionService { private static final Logger logger = LoggerFactory.getLogger(ProcessDefinitionServiceImpl.class); private static final String RELEASESTATE = "releaseState"; @Autowired private ProjectMapper projectMapper; @Autowired private ProjectService projectService; @Autowired private UserMapper userMapper; @Autowired private ProcessDefinitionLogMapper processDefinitionLogMapper; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private ProcessDefinitionDao processDefinitionDao; @Lazy @Autowired private ProcessInstanceService processInstanceService; @Autowired private TaskInstanceMapper taskInstanceMapper; @Autowired private ScheduleMapper scheduleMapper; @Autowired private ProcessService processService; @Autowired private ProcessTaskRelationMapper processTaskRelationMapper; @Autowired private ProcessTaskRelationLogMapper processTaskRelationLogMapper; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
TaskDefinitionLogMapper taskDefinitionLogMapper; @Autowired private TaskDefinitionMapper taskDefinitionMapper; @Autowired private SchedulerService schedulerService; @Autowired private TenantMapper tenantMapper; @Autowired private DataSourceMapper dataSourceMapper; @Autowired private TaskPluginManager taskPluginManager; @Autowired private WorkFlowLineageService workFlowLineageService; /** * create process definition * * @param loginUser login user * @param projectCode project code * @param name process definition name * @param description description * @param globalParams global params * @param locations locations for nodes * @param timeout timeout * @param tenantCode tenantCode * @param taskRelationJson relation json for nodes * @param taskDefinitionJson taskDefinitionJson * @return create result code */ @Override @Transactional
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
public Map<String, Object> createProcessDefinition(User loginUser, long projectCode, String name, String description, String globalParams, String locations, int timeout, String tenantCode, String taskRelationJson, String taskDefinitionJson, String otherParamsJson, ProcessExecutionTypeEnum executionType) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_CREATE); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (checkDescriptionLength(description)) { logger.warn("Parameter description is too long."); throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR); } ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); if (definition != null) { logger.warn("Process definition with the same name {} already exists, processDefinitionCode:{}.", definition.getName(), definition.getCode()); throw new ServiceException(Status.PROCESS_DEFINITION_NAME_EXIST, name); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
List<TaskDefinitionLog> taskDefinitionLogs = generateTaskDefinitionList(taskDefinitionJson); List<ProcessTaskRelationLog> taskRelationList = generateTaskRelationList(taskRelationJson, taskDefinitionLogs); int tenantId = -1; if (!Constants.DEFAULT.equals(tenantCode)) { Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); if (tenant == null) { logger.error("Tenant does not exist."); throw new ServiceException(Status.TENANT_NOT_EXIST); } tenantId = tenant.getId(); } long processDefinitionCode = CodeGenerateUtils.getInstance().genCode(); ProcessDefinition processDefinition = new ProcessDefinition(projectCode, name, processDefinitionCode, description, globalParams, locations, timeout, loginUser.getId(), tenantId); processDefinition.setExecutionType(executionType); return createDagDefine(loginUser, taskRelationList, processDefinition, taskDefinitionLogs, otherParamsJson); } private void createWorkflowValid(User user, ProcessDefinition processDefinition) { Project project = projectMapper.queryByCode(processDefinition.getProjectCode()); if (project == null) { throw new ServiceException(Status.PROJECT_NOT_FOUND, processDefinition.getProjectCode()); } projectService.checkProjectAndAuthThrowException(user, project, WORKFLOW_CREATE); if (checkDescriptionLength(processDefinition.getDescription())) { throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR); } ProcessDefinition definition =
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
processDefinitionMapper.verifyByDefineName(project.getCode(), processDefinition.getName()); if (definition != null) { throw new ServiceException(Status.PROCESS_DEFINITION_NAME_EXIST, processDefinition.getName()); } this.getTenantId(processDefinition); } private int getTenantId(ProcessDefinition processDefinition) { int tenantId = -1; if (!Constants.DEFAULT.equals(processDefinition.getTenantCode())) { Tenant tenant = tenantMapper.queryByTenantCode(processDefinition.getTenantCode()); if (tenant == null) { throw new ServiceException(Status.TENANT_NOT_EXIST); } tenantId = tenant.getId(); } return tenantId; } private void syncObj2Log(User user, ProcessDefinition processDefinition) { ProcessDefinitionLog processDefinitionLog = new ProcessDefinitionLog(processDefinition); processDefinitionLog.setOperator(user.getId()); int result = processDefinitionLogMapper.insert(processDefinitionLog); if (result <= 0) { throw new ServiceException(Status.CREATE_PROCESS_DEFINITION_LOG_ERROR); } } /** * create single process definition * * @param loginUser login user * @param workflowCreateRequest the new workflow object will be created
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
* @return New ProcessDefinition object created just now */ @Override @Transactional public ProcessDefinition createSingleProcessDefinition(User loginUser, WorkflowCreateRequest workflowCreateRequest) { ProcessDefinition processDefinition = workflowCreateRequest.convert2ProcessDefinition(); this.createWorkflowValid(loginUser, processDefinition); long processDefinitionCode; try { processDefinitionCode = CodeGenerateUtils.getInstance().genCode(); } catch (CodeGenerateException e) { throw new ServiceException(Status.INTERNAL_SERVER_ERROR_ARGS); } processDefinition.setTenantId(this.getTenantId(processDefinition)); processDefinition.setCode(processDefinitionCode); processDefinition.setUserId(loginUser.getId()); int create = processDefinitionMapper.insert(processDefinition); if (create <= 0) { throw new ServiceException(Status.CREATE_PROCESS_DEFINITION_ERROR); } this.syncObj2Log(loginUser, processDefinition); return processDefinition; } protected Map<String, Object> createDagDefine(User loginUser, List<ProcessTaskRelationLog> taskRelationList, ProcessDefinition processDefinition, List<TaskDefinitionLog> taskDefinitionLogs, String otherParamsJson) { Map<String, Object> result = new HashMap<>(); int saveTaskResult = processService.saveTaskDefine(loginUser, processDefinition.getProjectCode(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
taskDefinitionLogs, Boolean.TRUE); if (saveTaskResult == Constants.EXIT_CODE_SUCCESS) { logger.info("The task has not changed, so skip"); } if (saveTaskResult == Constants.DEFINITION_FAILURE) { logger.error("Save task definition error."); throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR); } int insertVersion = processService.saveProcessDefine(loginUser, processDefinition, Boolean.TRUE, Boolean.TRUE); if (insertVersion == 0) { logger.error("Save process definition error, processCode:{}.", processDefinition.getCode()); throw new ServiceException(Status.CREATE_PROCESS_DEFINITION_ERROR); } else logger.info("Save process definition complete, processCode:{}, processVersion:{}.", processDefinition.getCode(), insertVersion); int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs, Boolean.TRUE); if (insertResult != Constants.EXIT_CODE_SUCCESS) { logger.error("Save process task relations error, projectCode:{}, processCode:{}, processVersion:{}.", processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); throw new ServiceException(Status.CREATE_PROCESS_TASK_RELATION_ERROR); } else logger.info("Save process task relations complete, projectCode:{}, processCode:{}, processVersion:{}.", processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); saveOtherRelation(loginUser, processDefinition, result, otherParamsJson); putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, processDefinition); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,274
[Bug] [Workflow Definition] copy workflow error
### 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 press copy workflow button get an error. here's log ![Screen Shot 2022-10-09 at 14 18 46](https://user-images.githubusercontent.com/4263914/194741387-8e829736-54a7-4b40-af3b-5d4fd6a6c5f2.png) `[ERROR] 2022-10-09 06:18:41.012 +0000 org.apache.dolphinscheduler.api.exceptions.ApiExceptionHandler:[53] - 复制工作流错误 org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ### The error may exist in org/apache/dolphinscheduler/dao/mapper/ScheduleMapper.java (best guess) ### The error may involve org.apache.dolphinscheduler.dao.mapper.ScheduleMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO t_ds_schedules ( id, process_definition_code, start_time, end_time, timezone_id, crontab, failure_strategy, warning_type, create_time, update_time, user_id, release_state, warning_group_id, process_instance_priority, worker_group, environment_code ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. ; ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "t_ds_schedules_pkey" Detail: Key (id)=(2) already exists. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:247) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy138.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)` ### What you expected to happen successfully copy workflow ### How to reproduce just press copy workflow ### Anything else user pg as database ### Version 3.1.x ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12274
https://github.com/apache/dolphinscheduler/pull/12280
98a8b5383edf695811b64f6d871e8783e4a60003
18ef0a66cb91d9dfe6406f8ade6cfb2cff36492e
2022-10-09T06:23:55Z
java
2022-10-11T02:53:25Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
private List<TaskDefinitionLog> generateTaskDefinitionList(String taskDefinitionJson) { try { List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); if (CollectionUtils.isEmpty(taskDefinitionLogs)) { logger.error("Generate task definition list failed, the given taskDefinitionJson is invalided: {}", taskDefinitionJson); throw new ServiceException(Status.DATA_IS_NOT_VALID, taskDefinitionJson); } for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() .taskType(taskDefinitionLog.getTaskType()) .taskParams(taskDefinitionLog.getTaskParams()) .dependence(taskDefinitionLog.getDependence()) .build())) { logger.error( "Generate task definition list failed, the given task definition parameter is invalided, taskName: {}, taskDefinition: {}", taskDefinitionLog.getName(), taskDefinitionLog); throw new ServiceException(Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName()); } } return taskDefinitionLogs; } catch (ServiceException ex) { throw ex; } catch (Exception e) { logger.error("Generate task definition list failed, meet an unknown exception", e); throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR); } } private List<ProcessTaskRelationLog> generateTaskRelationList(String taskRelationJson, List<TaskDefinitionLog> taskDefinitionLogs) {