Browse Source

feat:新增jupyter查询状态接口

pull/83/head
西大锐 1 year ago
parent
commit
350bff0c46
3 changed files with 10 additions and 6 deletions
  1. +1
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DevEnvironmentServiceImpl.java
  2. +6
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java
  3. +3
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java

+ 1
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DevEnvironmentServiceImpl.java View File

@@ -68,6 +68,7 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService {
devEnvironment.setUpdateBy(loginUser.getUsername()); devEnvironment.setUpdateBy(loginUser.getUsername());
devEnvironment.setUpdateTime(new Date()); devEnvironment.setUpdateTime(new Date());
devEnvironment.setCreateTime(new Date()); devEnvironment.setCreateTime(new Date());
devEnvironment.setState(1);
this.devEnvironmentDao.insert(devEnvironment); this.devEnvironmentDao.insert(devEnvironment);
return devEnvironment; return devEnvironment;
} }


+ 6
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java View File

@@ -89,10 +89,12 @@ public class JupyterServiceImpl implements JupyterService {
String modelPath = (String) model.get("path"); String modelPath = (String) model.get("path");


LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
String podName = loginUser.getUsername().toLowerCase() + "-editor-pod";
//手动构造pod名称
String podName = loginUser.getUsername().toLowerCase() + "-" + "-editor-pod" + id;
String pvcName = loginUser.getUsername().toLowerCase() + "-editor-pvc"; String pvcName = loginUser.getUsername().toLowerCase() + "-editor-pvc";
V1PersistentVolumeClaim pvc = k8sClientUtil.createPvc(namespace, pvcName, storage, storageClassName); V1PersistentVolumeClaim pvc = k8sClientUtil.createPvc(namespace, pvcName, storage, storageClassName);



//TODO 设置镜像可配置,这里先用默认镜像启动pod //TODO 设置镜像可配置,这里先用默认镜像启动pod


// 调用修改后的 createPod 方法,传入额外的参数 // 调用修改后的 createPod 方法,传入额外的参数
@@ -110,7 +112,8 @@ public class JupyterServiceImpl implements JupyterService {
} }


LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
String podName = loginUser.getUsername().toLowerCase() + "-editor-pod";
//手动构造pod名称
String podName = loginUser.getUsername().toLowerCase() + "-" + devEnvironment.getName() +"-editor-pod" + id;
//得到pod //得到pod
V1Pod pod = k8sClientUtil.getNSPodList(namespace, podName); V1Pod pod = k8sClientUtil.getNSPodList(namespace, podName);
if(pod == null){ if(pod == null){
@@ -119,6 +122,7 @@ public class JupyterServiceImpl implements JupyterService {
// 使用 Kubernetes API 删除 Pod // 使用 Kubernetes API 删除 Pod
String deleteResult = k8sClientUtil.deletePod(podName, namespace); String deleteResult = k8sClientUtil.deletePod(podName, namespace);



return deleteResult + ",编辑器已停止"; return deleteResult + ",编辑器已停止";
} }




+ 3
- 4
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java View File

@@ -133,7 +133,9 @@ public class WorkflowServiceImpl implements WorkflowService {
public String removeById(Long id) throws Exception { public String removeById(Long id) throws Exception {
//先根据id提取出对应的流水线 //先根据id提取出对应的流水线
Workflow workflow = workflowDao.queryById(id); Workflow workflow = workflowDao.queryById(id);

if (workflow == null){
throw new Exception("流水线不存在");
}
//判断权限,只有admin和创建者本身可以删除该流水线 //判断权限,只有admin和创建者本身可以删除该流水线
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
String username = loginUser.getUsername(); String username = loginUser.getUsername();
@@ -142,9 +144,6 @@ public class WorkflowServiceImpl implements WorkflowService {
throw new Exception("无权限删除该流水线"); throw new Exception("无权限删除该流水线");
} }


if (workflow == null){
throw new Exception("流水线不存在");
}
//判断这个流水线是否有相关实验存在 //判断这个流水线是否有相关实验存在
List<Experiment> experimentList = experimentService.queryByWorkflowId(id); List<Experiment> experimentList = experimentService.queryByWorkflowId(id);
if (experimentList!=null&&experimentList.size()>0){ if (experimentList!=null&&experimentList.size()>0){


Loading…
Cancel
Save