martin 3 éve
szülő
commit
e1a20ce072

+ 2 - 2
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/scheduler/TickScheduler.java

@@ -67,14 +67,14 @@ public class TickScheduler {
                 long difference = now - tickTime;
 //                log.info("------- TickScheduler 任务" + taskId + "心跳时间为:" + tickTime + "最大仿真时间为:" + tickTime + "时间差为:" + difference);
                 if (difference > timeout) {
-                    String podName = redisTemplate.opsForValue().get("podName:" + taskId);
+                    String podName = redisTemplate.opsForValue().get(manualProjectTopic + ":" + projectId + ":" + taskId + ":pod");
                     String podDeleteCommand = "kubectl delete pod " + podName;
                     if (podName != null) {
                         log.info("TickScheduler--tick 修改任务 " + taskId + "已超时,状态修改为 Aborted,pod 名称为:" + podName
                                 + ",并执行删除 pod 命令:" + podDeleteCommand);
                         SshUtil.execute(session, podDeleteCommand);
 //            taskManager.updateFailStateWithStopTime(taskId, state, TimeUtil.getNowForMysql()); // 如果任务 abort 代表项目失败
-                        taskMapper.updateFailStateWithStopTime(taskId, DictConstants.TASK_ABORTED, TimeUtil.getNowForMysql(),DictConstants.TASK_ERROR_REASON_1);
+                        taskMapper.updateFailStateWithStopTime(taskId, DictConstants.TASK_ABORTED, TimeUtil.getNowForMysql(), DictConstants.TASK_ERROR_REASON_1);
                         redisTemplate.delete("podName:" + taskId);
                     }
                 }

+ 2 - 3
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/service/TaskService.java

@@ -108,7 +108,8 @@ public class TaskService {
     @SneakyThrows
     public void taskState(String taskId, String state, String podName) {
 
-        redisTemplate.opsForValue().set("podName:" + taskId, podName);
+        String projectId = taskMapper.selectProjectIdById(taskId);
+        redisTemplate.opsForValue().set(manualProjectTopic + ":" + projectId + ":" + taskId + ":pod", podName);
         String podDeleteCommand = "kubectl delete pod " + podName;
         SshClient client = SshUtil.getClient();
         ClientSession session = SshUtil.getSession(client, hostnameScore, usernameScore, passwordScore);
@@ -122,7 +123,6 @@ public class TaskService {
 //            taskManager.updateFailStateWithStopTime(taskId, state, TimeUtil.getNowForMysql()); // 如果任务 abort 代表项目失败
             redisTemplate.delete("podName:" + taskId);
             //result-path-minio: /project/manual-project/
-            String projectId = taskMapper.selectProjectIdById(taskId);
             String minioPathOfErrorLog = resultPathMinio + projectId + "/" + taskId + "error.log";
             boolean objectExist = MinioUtil.isObjectExist(minioClient, bucketName, minioPathOfErrorLog);
             String targetEvaluate;
@@ -170,7 +170,6 @@ public class TaskService {
             client.stop();
             return;
         }
-        String projectId = projectPO.getId();
         Set<String> keys = redisTemplate.keys("manualProject:" + projectId + "*");
         assert keys != null;
         redisTemplate.delete(keys);