From 1216694204d6e8778a59cc95aefa88ee1605c779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A5=BF=E5=A4=A7=E9=94=90?= <1070211640@qq.com> Date: Wed, 12 Jun 2024 09:12:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9Ejupyter=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=8A=B6=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/aim/AimController.java | 2 +- .../service/impl/JupyterServiceImpl.java | 37 +++++++++++++++++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/aim/AimController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/aim/AimController.java index ae28df8b..cdf9cf7c 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/aim/AimController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/aim/AimController.java @@ -5,7 +5,7 @@ import com.ruoyi.common.core.web.domain.GenericsAjaxResult; import com.ruoyi.platform.service.AimService; import com.ruoyi.platform.service.TensorBoardService; import com.ruoyi.platform.vo.FrameLogPathVo; -import com.ruoyi.platform.vo.TensorboardStatusVo; +import com.ruoyi.platform.vo.PodStatusVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.responses.ApiResponse; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java index 152af376..b3eb4bdf 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java @@ -1,8 +1,10 @@ package com.ruoyi.platform.service.impl; +import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.platform.domain.DevEnvironment; +import com.ruoyi.platform.domain.PodStatus; import com.ruoyi.platform.mapper.DevEnvironmentDao; import com.ruoyi.platform.service.DevEnvironmentService; import com.ruoyi.platform.service.JupyterService; @@ -76,9 +78,9 @@ public class JupyterServiceImpl implements JupyterService { @Override public String runJupyterService(Integer id) { DevEnvironment devEnvironment = this.devEnvironmentDao.queryById(id); - if(devEnvironment == null){ - - } +// if(devEnvironment == null){ +// +// } String envName = devEnvironment.getName(); //TODO 设置环境变量 @@ -124,7 +126,34 @@ public class JupyterServiceImpl implements JupyterService { @Override public PodStatusVo getJupyterStatus(FrameLogPathVo frameLogPathVo) { - return null; + String status = PodStatus.Terminated.getName(); + PodStatusVo JupyterStatusVo = new PodStatusVo(); + JupyterStatusVo.setStatus(status); + if(StringUtils.isEmpty(frameLogPathVo.getPath())){ + return JupyterStatusVo; + } + + LoginUser loginUser = SecurityUtils.getLoginUser(); + String podName = loginUser.getUsername().toLowerCase() + "-editor-pod"; + + try { + // 查询相应pod状态 + String podStatus = k8sClientUtil.getPodStatus(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace()) ? "default" : frameLogPathVo.getNamespace()); + for (PodStatus s : PodStatus.values()) { + if (s.getName().equals(podStatus)) { + status = s.getName(); + break; + } + } + + } catch (Exception e) { + return JupyterStatusVo; + } + String url = redisService.getCacheObject(podName); + JupyterStatusVo.setStatus(status); + JupyterStatusVo.setUrl(url); + return JupyterStatusVo; + } From 6e5fedb103df3bba808c67b3cfe59090a80d8f85 Mon Sep 17 00:00:00 2001 From: fanshuai <1141904845@qq.com> Date: Wed, 12 Jun 2024 09:18:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=BC=94=E5=8C=96?= =?UTF-8?q?=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/managementPlatform/ModelDependencyDaoMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ModelDependencyDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ModelDependencyDaoMapper.xml index 939df96e..1275528f 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ModelDependencyDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ModelDependencyDaoMapper.xml @@ -321,7 +321,7 @@ state = #{state}, - where id = #{id} and state = 1 + where id = #{id}