feat:新增jupyter查询状态接口

This commit is contained in:
西大锐 2024-06-17 10:22:49 +08:00
parent 55eeb0a126
commit 350bff0c46
3 changed files with 10 additions and 6 deletions

View File

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

View File

@ -89,10 +89,12 @@ public class JupyterServiceImpl implements JupyterService {
String modelPath = (String) model.get("path");
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";
V1PersistentVolumeClaim pvc = k8sClientUtil.createPvc(namespace, pvcName, storage, storageClassName);
//TODO 设置镜像可配置这里先用默认镜像启动pod
// 调用修改后的 createPod 方法传入额外的参数
@ -110,7 +112,8 @@ public class JupyterServiceImpl implements JupyterService {
}
LoginUser loginUser = SecurityUtils.getLoginUser();
String podName = loginUser.getUsername().toLowerCase() + "-editor-pod";
//手动构造pod名称
String podName = loginUser.getUsername().toLowerCase() + "-" + devEnvironment.getName() +"-editor-pod" + id;
//得到pod
V1Pod pod = k8sClientUtil.getNSPodList(namespace, podName);
if(pod == null){
@ -119,6 +122,7 @@ public class JupyterServiceImpl implements JupyterService {
// 使用 Kubernetes API 删除 Pod
String deleteResult = k8sClientUtil.deletePod(podName, namespace);
return deleteResult + ",编辑器已停止";
}

View File

@ -133,7 +133,9 @@ public class WorkflowServiceImpl implements WorkflowService {
public String removeById(Long id) throws Exception {
//先根据id提取出对应的流水线
Workflow workflow = workflowDao.queryById(id);
if (workflow == null){
throw new Exception("流水线不存在");
}
//判断权限只有admin和创建者本身可以删除该流水线
LoginUser loginUser = SecurityUtils.getLoginUser();
String username = loginUser.getUsername();
@ -142,9 +144,6 @@ public class WorkflowServiceImpl implements WorkflowService {
throw new Exception("无权限删除该流水线");
}
if (workflow == null){
throw new Exception("流水线不存在");
}
//判断这个流水线是否有相关实验存在
List<Experiment> experimentList = experimentService.queryByWorkflowId(id);
if (experimentList!=null&&experimentList.size()>0){