|
|
|
@@ -10,9 +10,13 @@ import com.ruoyi.platform.utils.JacksonUtil; |
|
|
|
import com.ruoyi.platform.utils.K8sClientUtil; |
|
|
|
import com.ruoyi.platform.utils.MinioUtil; |
|
|
|
import com.ruoyi.platform.utils.MlflowUtil; |
|
|
|
import com.ruoyi.platform.vo.FrameLogPathVo; |
|
|
|
import com.ruoyi.platform.vo.PodStatusVo; |
|
|
|
import com.ruoyi.system.api.model.LoginUser; |
|
|
|
import io.kubernetes.client.openapi.models.V1PersistentVolumeClaim; |
|
|
|
import io.kubernetes.client.openapi.models.V1Pod; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
@@ -49,6 +53,7 @@ public class JupyterServiceImpl implements JupyterService { |
|
|
|
private DevEnvironmentDao devEnvironmentDao; |
|
|
|
|
|
|
|
@Resource |
|
|
|
@Lazy |
|
|
|
private DevEnvironmentService devEnvironmentService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
@@ -71,6 +76,9 @@ public class JupyterServiceImpl implements JupyterService { |
|
|
|
@Override |
|
|
|
public String runJupyterService(Integer id) { |
|
|
|
DevEnvironment devEnvironment = this.devEnvironmentDao.queryById(id); |
|
|
|
if(devEnvironment == null){ |
|
|
|
|
|
|
|
} |
|
|
|
String envName = devEnvironment.getName(); |
|
|
|
//TODO 设置环境变量 |
|
|
|
|
|
|
|
@@ -103,18 +111,22 @@ public class JupyterServiceImpl implements JupyterService { |
|
|
|
|
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
|
String podName = loginUser.getUsername().toLowerCase() + "-editor-pod"; |
|
|
|
|
|
|
|
//得到pod |
|
|
|
V1Pod pod = k8sClientUtil.getNSPodList(namespace, podName); |
|
|
|
if(pod == null){ |
|
|
|
return "pod不存在!"; |
|
|
|
} |
|
|
|
// 使用 Kubernetes API 删除 Pod |
|
|
|
String deleteResult = k8sClientUtil.deletePod(podName, namespace); |
|
|
|
|
|
|
|
// 检查 Pod 是否存在 |
|
|
|
boolean exists = k8sClientUtil.checkPodExists(podName, namespace); |
|
|
|
if (exists) { |
|
|
|
throw new Exception("Pod " + podName + " 删除失败"); |
|
|
|
} |
|
|
|
return deleteResult + ",编辑器已停止"; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PodStatusVo getJupyterStatus(FrameLogPathVo frameLogPathVo) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void upload(InputStream inputStream) { |
|
|
|
@@ -136,4 +148,5 @@ public class JupyterServiceImpl implements JupyterService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |