From 04ea8f7e288a1823fb15e9d1ab04de4936491aa7 Mon Sep 17 00:00:00 2001 From: Wenjun Ruan Date: Wed, 28 Dec 2022 22:02:48 +0800 Subject: [PATCH] Revert "[Bug] [Server] Once click online schedule time, task will be automatically scheduled (#13092)" (#13295) This reverts commit 7497b26979ec1ba5c473c99d8e51a97c91250f25. --- .../dolphinscheduler/api/enums/Status.java | 1 - .../service/impl/SchedulerServiceImpl.java | 25 +----------- .../api/service/SchedulerServiceTest.java | 38 +++++-------------- .../definition/components/use-form.ts | 2 +- 4 files changed, 13 insertions(+), 53 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java index 842e5766a6..cb1941b2a0 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java @@ -408,7 +408,6 @@ public enum Status { COMMAND_STATE_COUNT_ERROR(80001, "task instance state count error", "查询各状态任务实例数错误"), NEGTIVE_SIZE_NUMBER_ERROR(80002, "query size number error", "查询size错误"), START_TIME_BIGGER_THAN_END_TIME_ERROR(80003, "start time bigger than end time error", "开始时间在结束时间之后错误"), - START_TIME_BEFORE_CURRENT_TIME_ERROR(80004, "start time before current time error", "开始时间在当前时间之前错误"), QUEUE_COUNT_ERROR(90001, "queue count error", "查询队列数据错误"), KERBEROS_STARTUP_STATE(100001, "get kerberos startup state error", "获取kerberos启动状态错误"), diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java index 23adae0640..d12216c05a 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java @@ -171,18 +171,13 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe scheduleObj.setProcessDefinitionName(processDefinition.getName()); ScheduleParam scheduleParam = JSONUtils.parseObject(schedule, ScheduleParam.class); - if (now.after(scheduleParam.getStartTime())) { - logger.warn("The start time must be later than current time."); - putMsg(result, Status.START_TIME_BEFORE_CURRENT_TIME_ERROR); - return result; - } if (DateUtils.differSec(scheduleParam.getStartTime(), scheduleParam.getEndTime()) == 0) { logger.warn("The start time must not be the same as the end or time can not be null."); putMsg(result, Status.SCHEDULE_START_TIME_END_TIME_SAME); return result; } if (scheduleParam.getStartTime().getTime() > scheduleParam.getEndTime().getTime()) { - logger.warn("The start time must be smaller than end time."); + logger.warn("The start time must smaller than end time"); putMsg(result, Status.START_TIME_BIGGER_THAN_END_TIME_ERROR); return result; } @@ -239,10 +234,6 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe if (scheduleParam == null) { throw new ServiceException(Status.PARSE_SCHEDULE_PARAM_ERROR, scheduleParamStr); } - Date now = new Date(); - if (now.after(scheduleParam.getStartTime())) { - throw new ServiceException(Status.START_TIME_BEFORE_CURRENT_TIME_ERROR); - } if (DateUtils.differSec(scheduleParam.getStartTime(), scheduleParam.getEndTime()) == 0) { throw new ServiceException(Status.SCHEDULE_START_TIME_END_TIME_SAME); } @@ -480,13 +471,6 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe return result; } if (scheduleStatus == ReleaseState.ONLINE) { - // check schedule start time - Date now = new Date(); - if (now.after(scheduleObj.getStartTime())) { - logger.warn("The start time must be later than current time."); - putMsg(result, Status.START_TIME_BEFORE_CURRENT_TIME_ERROR); - return result; - } // check process definition release state if (processDefinition.getReleaseState() != ReleaseState.ONLINE) { logger.warn("Only process definition state is {} can change schedule state, processDefinitionCode:{}.", @@ -849,18 +833,13 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe putMsg(result, Status.PARSE_TO_CRON_EXPRESSION_ERROR); return; } - if (now.after(scheduleParam.getStartTime())) { - logger.warn("The start time must be later than current time."); - putMsg(result, Status.START_TIME_BEFORE_CURRENT_TIME_ERROR); - return; - } if (DateUtils.differSec(scheduleParam.getStartTime(), scheduleParam.getEndTime()) == 0) { logger.warn("The start time must not be the same as the end or time can not be null."); putMsg(result, Status.SCHEDULE_START_TIME_END_TIME_SAME); return; } if (scheduleParam.getStartTime().getTime() > scheduleParam.getEndTime().getTime()) { - logger.warn("The start time must be smaller than end time."); + logger.warn("The start time must smaller than end time"); putMsg(result, Status.START_TIME_BIGGER_THAN_END_TIME_ERROR); return; } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/SchedulerServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/SchedulerServiceTest.java index 0075e15b2c..4de90a8a77 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/SchedulerServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/SchedulerServiceTest.java @@ -105,8 +105,8 @@ public class SchedulerServiceTest extends BaseServiceTestTool { private static final int processDefinitionVersion = 3; private static final int scheduleId = 3; private static final long environmentCode = 4L; - private static final String startTime = "2220-01-01 12:13:14"; - private static final String endTime = "2220-02-01 12:13:14"; + private static final String startTime = "2020-01-01 12:13:14"; + private static final String endTime = "2020-02-01 12:13:14"; private static final String crontab = "0 0 * * * ? *"; @BeforeEach @@ -175,8 +175,6 @@ public class SchedulerServiceTest extends BaseServiceTestTool { ScheduleCreateRequest scheduleCreateRequest = new ScheduleCreateRequest(); scheduleCreateRequest.setProcessDefinitionCode(processDefinitionCode); scheduleCreateRequest.setEnvironmentCode(environmentCode); - scheduleCreateRequest.setStartTime(startTime); - scheduleCreateRequest.setEndTime(endTime); // error process definition not exists exception = Assertions.assertThrows(ServiceException.class, @@ -210,24 +208,16 @@ public class SchedulerServiceTest extends BaseServiceTestTool { Assertions.assertEquals(Status.QUERY_ENVIRONMENT_BY_CODE_ERROR.getCode(), ((ServiceException) exception).getCode()); - // error schedule parameter start time before current time - String badStartTime = "2020-01-01 12:13:14"; - scheduleCreateRequest.setStartTime(badStartTime); - Mockito.when(environmentMapper.queryByEnvironmentCode(environmentCode)).thenReturn(this.getEnvironment()); - exception = Assertions.assertThrows(ServiceException.class, - () -> schedulerService.createSchedulesV2(user, scheduleCreateRequest)); - Assertions.assertEquals(Status.START_TIME_BEFORE_CURRENT_TIME_ERROR.getCode(), - ((ServiceException) exception).getCode()); - // error schedule parameter same start time and end time - scheduleCreateRequest.setStartTime(endTime); + Mockito.when(environmentMapper.queryByEnvironmentCode(environmentCode)).thenReturn(this.getEnvironment()); exception = Assertions.assertThrows(ServiceException.class, () -> schedulerService.createSchedulesV2(user, scheduleCreateRequest)); Assertions.assertEquals(Status.SCHEDULE_START_TIME_END_TIME_SAME.getCode(), ((ServiceException) exception).getCode()); - // error schedule parameter start time after than end time - badStartTime = "2222-01-01 12:13:14"; + // error schedule parameter same start time after than end time + scheduleCreateRequest.setEndTime(endTime); + String badStartTime = "2022-01-01 12:13:14"; scheduleCreateRequest.setStartTime(badStartTime); exception = Assertions.assertThrows(ServiceException.class, () -> schedulerService.createSchedulesV2(user, scheduleCreateRequest)); @@ -371,25 +361,17 @@ public class SchedulerServiceTest extends BaseServiceTestTool { () -> schedulerService.updateSchedulesV2(user, scheduleId, scheduleUpdateRequest)); Assertions.assertEquals(Status.SCHEDULE_NOT_EXISTS.getCode(), ((ServiceException) exception).getCode()); - // error schedule parameter start time before current time - String badStartTime = "2020-01-01 12:13:14"; - scheduleUpdateRequest.setStartTime(badStartTime); - scheduleUpdateRequest.setEndTime(endTime); - Mockito.when(scheduleMapper.selectById(scheduleId)).thenReturn(this.getSchedule()); - exception = Assertions.assertThrows(ServiceException.class, - () -> schedulerService.updateSchedulesV2(user, scheduleId, scheduleUpdateRequest)); - Assertions.assertEquals(Status.START_TIME_BEFORE_CURRENT_TIME_ERROR.getCode(), - ((ServiceException) exception).getCode()); - // error schedule parameter same start time and end time + scheduleUpdateRequest.setEndTime(endTime); scheduleUpdateRequest.setStartTime(endTime); + Mockito.when(scheduleMapper.selectById(scheduleId)).thenReturn(this.getSchedule()); exception = Assertions.assertThrows(ServiceException.class, () -> schedulerService.updateSchedulesV2(user, scheduleId, scheduleUpdateRequest)); Assertions.assertEquals(Status.SCHEDULE_START_TIME_END_TIME_SAME.getCode(), ((ServiceException) exception).getCode()); - // error schedule parameter start time after than end time - badStartTime = "2222-01-01 12:13:14"; + // error schedule parameter same start time after than end time + String badStartTime = "2022-01-01 12:13:14"; scheduleUpdateRequest.setStartTime(badStartTime); exception = Assertions.assertThrows(ServiceException.class, () -> schedulerService.updateSchedulesV2(user, scheduleId, scheduleUpdateRequest)); diff --git a/dolphinscheduler-ui/src/views/projects/workflow/definition/components/use-form.ts b/dolphinscheduler-ui/src/views/projects/workflow/definition/components/use-form.ts index 9e50550031..0e4521c24e 100644 --- a/dolphinscheduler-ui/src/views/projects/workflow/definition/components/use-form.ts +++ b/dolphinscheduler-ui/src/views/projects/workflow/definition/components/use-form.ts @@ -95,7 +95,7 @@ export const useForm = () => { timingFormRef: ref(), timingForm: { startEndTime: [ - new Date(year, month, day + 1), + new Date(year, month, day), new Date(year + 100, month, day) ], crontab: '0 0 * * * ? *',