From e58d73ae12acff0888fd8186477e04c5fd6c04bd Mon Sep 17 00:00:00 2001 From: chenzhihang <709011834@qq.com> Date: Tue, 10 Sep 2024 15:53:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8C=82=E8=BD=BD=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/platform/service/impl/MinioServiceImpl.java | 4 +++- .../java/com/ruoyi/platform/utils/K8sClientUtil.java | 9 ++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MinioServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MinioServiceImpl.java index 6a1656b2..380f96c6 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MinioServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MinioServiceImpl.java @@ -63,7 +63,9 @@ public class MinioServiceImpl implements MinioService { try (InputStream inputStream = file.getInputStream()){ minioUtil.uploadObject(bucketName, objectName, inputStream); result.put("fileName", file.getOriginalFilename()); - result.put("url", objectName); // objectName根据实际情况定义 + int lastIndex = objectName.lastIndexOf('/'); + String url = objectName.substring(0, lastIndex); + result.put("url", url); // objectName根据实际情况定义 result.put("fileSize", formattedSize); } catch (Exception e) { throw new Exception("上传文件失败: " + e.getMessage(), e); 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 03648e6e..cb382fd8 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 @@ -366,7 +366,7 @@ public class K8sClientUtil { .endContainer() .addNewVolume() .withName("workspace") - .withHostPath(new V1HostPathVolumeSource().path(hostPath + "/" + podName + "/tensorboard").type("DirectoryOrCreate")) + .withHostPath(new V1HostPathVolumeSource().path(pvcName).type("DirectoryOrCreate")) // .withPersistentVolumeClaim(new V1PersistentVolumeClaimVolumeSource().claimName(pvcName)) .endVolume() .withTerminationGracePeriodSeconds(14400L) @@ -452,13 +452,12 @@ public class K8sClientUtil { // 配置卷和卷挂载 List volumeMounts = new ArrayList<>(); volumeMounts.add(new V1VolumeMount().name("workspace").mountPath("/opt/notebooks")); - volumeMounts.add(new V1VolumeMount().name("dataset").mountPath("/opt/dataset").readOnly(true)); - volumeMounts.add(new V1VolumeMount().name("model").mountPath("/opt/model").readOnly(true)); + volumeMounts.add(new V1VolumeMount().name("data").mountPath("/opt/dataset").subPath(datasetPath).readOnly(true)); + volumeMounts.add(new V1VolumeMount().name("data").mountPath("/opt/model").subPath(modelPath).readOnly(true)); List volumes = new ArrayList<>(); volumes.add(new V1Volume().name("workspace").hostPath(new V1HostPathVolumeSource().path(hostPath + "/" + podName + "/notebooks").type("DirectoryOrCreate"))); - volumes.add(new V1Volume().name("dataset").hostPath(new V1HostPathVolumeSource().path(hostPath + "/" + podName + "/dataset").type("DirectoryOrCreate"))); - volumes.add(new V1Volume().name("model").hostPath(new V1HostPathVolumeSource().path(hostPath + "/" + podName + "/model").type("DirectoryOrCreate"))); + volumes.add(new V1Volume().name("data").hostPath(new V1HostPathVolumeSource().path(hostPath).type("DirectoryOrCreate"))); // 配置卷和卷挂载 // List volumeMounts = new ArrayList<>();