Browse Source

feat:开发环境数据集模型可配置一阶段

pull/57/head
西大锐 1 year ago
parent
commit
e84beac4c6
2 changed files with 8 additions and 12 deletions
  1. +6
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java
  2. +2
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java

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

@@ -12,6 +12,7 @@ import com.ruoyi.platform.utils.MinioUtil;
import com.ruoyi.platform.utils.MlflowUtil; import com.ruoyi.platform.utils.MlflowUtil;
import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.system.api.model.LoginUser;
import io.kubernetes.client.openapi.models.V1PersistentVolumeClaim; import io.kubernetes.client.openapi.models.V1PersistentVolumeClaim;
import io.kubernetes.client.openapi.models.V1Pod;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


@@ -103,15 +104,14 @@ public class JupyterServiceImpl implements JupyterService {


LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
String podName = loginUser.getUsername().toLowerCase() + "-editor-pod"; String podName = loginUser.getUsername().toLowerCase() + "-editor-pod";

//得到pod
V1Pod pod = k8sClientUtil.getNSPodList(namespace, podName);
if(pod == null){
return "pod不存在!";
}
// 使用 Kubernetes API 删除 Pod // 使用 Kubernetes API 删除 Pod
String deleteResult = k8sClientUtil.deletePod(podName, namespace); String deleteResult = k8sClientUtil.deletePod(podName, namespace);


// 检查 Pod 是否存在
boolean exists = k8sClientUtil.checkPodExists(podName, namespace);
if (exists) {
throw new Exception("Pod " + podName + " 删除失败");
}
return deleteResult + ",编辑器已停止"; return deleteResult + ",编辑器已停止";
} }




+ 2
- 6
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java View File

@@ -573,12 +573,8 @@ public class K8sClientUtil {
V1Pod pod = api.deleteNamespacedPod(podName, namespace, null, null, null, null, null, null); V1Pod pod = api.deleteNamespacedPod(podName, namespace, null, null, null, null, null, null);
return "Pod " + podName + " 删除请求已发送"; return "Pod " + podName + " 删除请求已发送";
} catch (ApiException e) { } catch (ApiException e) {
if (e.getCode() == 404) {
return "Pod " + podName + " 不存在";
} else {
log.error("删除pod异常:" + e.getResponseBody(), e);
throw e;
}
log.error("删除pod异常:" + e.getResponseBody(), e);
throw e;
} }
} }




Loading…
Cancel
Save