From e5f21dbb83762918c3e97b4ddc434aff22c93ef6 Mon Sep 17 00:00:00 2001 From: gaoyan Date: Wed, 31 Jan 2024 14:49:23 +0800 Subject: [PATCH] [Fix]Fix deletion task failed when the job instance does not exist (#3107) Co-authored-by: gaoyan1998 --- .../dinky/service/impl/CatalogueServiceImpl.java | 13 ++++++++----- .../dinky/service/impl/JobInstanceServiceImpl.java | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/CatalogueServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/CatalogueServiceImpl.java index 57b8cce813..5cab6f6538 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/CatalogueServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/CatalogueServiceImpl.java @@ -31,6 +31,7 @@ import org.dinky.data.model.Catalogue; import org.dinky.data.model.Metrics; import org.dinky.data.model.Task; +import org.dinky.data.model.ext.JobInfoDetail; import org.dinky.data.model.job.History; import org.dinky.data.model.job.JobHistory; import org.dinky.data.model.job.JobInstance; @@ -466,13 +467,15 @@ public Result deleteCatalogueById(Integer catalogueId) { throw new BusException(Status.TASK_IS_PUBLISH_CANNOT_DELETE); } if (task.getJobInstanceId() != null) { - // 获取前 先强制刷新一下, 避免获取任务信息状态不准确 - jobInstanceService.refreshJobInfoDetail(task.getJobInstanceId(), true); // 获取当前 job instance JobInstance currentJobInstance = jobInstanceService.getById(task.getJobInstanceId()); - if (currentJobInstance != null - && currentJobInstance.getStatus().equals(JobStatus.RUNNING.getValue())) { - throw new BusException(Status.TASK_IS_RUNNING_CANNOT_DELETE); + if (currentJobInstance != null) { + // 获取前 先强制刷新一下, 避免获取任务信息状态不准确 + JobInfoDetail jobInfoDetail = + jobInstanceService.refreshJobInfoDetail(task.getJobInstanceId(), true); + if (jobInfoDetail.getInstance().getStatus().equals(JobStatus.RUNNING.getValue())) { + throw new BusException(Status.TASK_IS_RUNNING_CANNOT_DELETE); + } } } } diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/JobInstanceServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/JobInstanceServiceImpl.java index 6239abc66b..0de903ed38 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/JobInstanceServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/JobInstanceServiceImpl.java @@ -170,7 +170,9 @@ public JobInfoDetail getJobInfoDetailInfo(JobInstance jobInstance) { if (Asserts.isNotNull(history.getClusterConfigurationId())) { ClusterConfiguration clusterConfig = clusterConfigurationService.getClusterConfigById(history.getClusterConfigurationId()); - jobInfoDetail.setClusterConfiguration(ClusterConfigurationDTO.fromBean(clusterConfig)); + if (clusterConfig != null) { + jobInfoDetail.setClusterConfiguration(ClusterConfigurationDTO.fromBean(clusterConfig)); + } } }