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 01a41535..e7fcf857 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 @@ -12,6 +12,7 @@ import com.ruoyi.platform.utils.MinioUtil; import com.ruoyi.platform.utils.MlflowUtil; 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.stereotype.Service; @@ -103,15 +104,14 @@ 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 + ",编辑器已停止"; } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java index 9a5a2ab4..febb449e 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java @@ -573,12 +573,8 @@ public class K8sClientUtil { V1Pod pod = api.deleteNamespacedPod(podName, namespace, null, null, null, null, null, null); return "Pod " + podName + " 删除请求已发送"; } 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; } }