parent
31455d0420
commit
9fcb1a2db0
|
@ -98,8 +98,8 @@ public class JupyterServiceImpl implements JupyterService {
|
|||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
//构造pod名称
|
||||
String podName = loginUser.getUsername().toLowerCase() + "-editor-pod" + "-" + id;
|
||||
String pvcName = loginUser.getUsername().toLowerCase() + "-editor-pvc";
|
||||
//新建编辑器的pvc
|
||||
// String pvcName = loginUser.getUsername().toLowerCase() + "-editor-pvc";
|
||||
// V1PersistentVolumeClaim pvc = k8sClientUtil.createPvc(namespace, pvcName, storage, storageClassName);
|
||||
|
||||
//TODO 设置镜像可配置,这里先用默认镜像启动pod
|
||||
|
|
|
@ -26,9 +26,6 @@ import java.util.Map;
|
|||
@Service("MinioService")
|
||||
public class MinioServiceImpl implements MinioService {
|
||||
|
||||
@Value("${jupyter.hostPath}")
|
||||
private String hostPath;
|
||||
|
||||
private final MinioUtil minioUtil;
|
||||
|
||||
public MinioServiceImpl(MinioUtil minioUtil) {
|
||||
|
@ -66,7 +63,7 @@ public class MinioServiceImpl implements MinioService {
|
|||
try (InputStream inputStream = file.getInputStream()){
|
||||
minioUtil.uploadObject(bucketName, objectName, inputStream);
|
||||
result.put("fileName", file.getOriginalFilename());
|
||||
objectName = hostPath + "/" + objectName;
|
||||
objectName = "/" + objectName;
|
||||
result.put("url", objectName); // objectName根据实际情况定义
|
||||
result.put("fileSize", formattedSize);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -186,10 +186,8 @@ public class ModelsVersionServiceImpl implements ModelsVersionService {
|
|||
.filter(modelsVersion -> modelsVersion.getUrl() != null && !modelsVersion.getUrl().isEmpty())
|
||||
.findFirst()
|
||||
.ifPresent(modelsVersion -> {
|
||||
String url = modelsVersion.getUrl();
|
||||
String path = bucketName + '/' + url.substring(0, url.lastIndexOf('/'));
|
||||
String path = modelsVersion.getUrl();
|
||||
response.put("path", path);
|
||||
|
||||
});
|
||||
|
||||
response.put("content", modelsVersionList);
|
||||
|
|
|
@ -28,16 +28,17 @@ public class TensorBoardServiceImpl implements TensorBoardService {
|
|||
private RedisService redisService;
|
||||
@Resource
|
||||
private K8sClientUtil k8sClientUtil;
|
||||
|
||||
@Override
|
||||
public PodStatusVo getTensorBoardStatus(FrameLogPathVo frameLogPathVo){
|
||||
public PodStatusVo getTensorBoardStatus(FrameLogPathVo frameLogPathVo) {
|
||||
String status = PodStatus.Terminated.getName();
|
||||
PodStatusVo tensorboardStatusVo = new PodStatusVo();
|
||||
tensorboardStatusVo.setStatus(status);
|
||||
if (StringUtils.isEmpty(frameLogPathVo.getPath())){
|
||||
if (StringUtils.isEmpty(frameLogPathVo.getPath())) {
|
||||
return tensorboardStatusVo;
|
||||
}
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String podName = loginUser.getUsername().toLowerCase()+"-"+frameLogPathVo.getPath().split("/")[2]+ "-tensorboard-pod";
|
||||
String podName = loginUser.getUsername().toLowerCase() + "-" + frameLogPathVo.getPath().split("/")[2] + "-tensorboard-pod";
|
||||
|
||||
try {
|
||||
String podStatus = k8sClientUtil.getPodStatus(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace()) ? "default" : frameLogPathVo.getNamespace());
|
||||
|
@ -58,13 +59,17 @@ public class TensorBoardServiceImpl implements TensorBoardService {
|
|||
|
||||
@Override
|
||||
public String runTensorBoard(FrameLogPathVo frameLogPathVo) throws Exception {
|
||||
if (StringUtils.isEmpty(frameLogPathVo.getPath())||StringUtils.isEmpty(frameLogPathVo.getPvcName())){
|
||||
throw new Exception("存储路径或存储为空");
|
||||
// if (StringUtils.isEmpty(frameLogPathVo.getPath())||StringUtils.isEmpty(frameLogPathVo.getPvcName())){
|
||||
// throw new Exception("存储路径或存储为空");
|
||||
// }
|
||||
if (StringUtils.isEmpty(frameLogPathVo.getPath())) {
|
||||
throw new Exception("存储路径为空");
|
||||
}
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String podName = loginUser.getUsername().toLowerCase()+"-"+frameLogPathVo.getPath().split("/")[2]+ "-tensorboard-pod";
|
||||
Integer podPort = k8sClientUtil.createPodWithSubPath(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace())?"default":frameLogPathVo.getNamespace(), port, mountPath,frameLogPathVo.getPath(), frameLogPathVo.getPvcName(), image);
|
||||
redisService.setCacheObject(podName,masterIp + ":" + podPort);
|
||||
|
||||
Integer podPort = k8sClientUtil.createPodWithSubPath(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace()) ? "default" : frameLogPathVo.getNamespace(), port, mountPath, frameLogPathVo.getPath(), frameLogPathVo.getPvcName(), image);
|
||||
redisService.setCacheObject(podName, masterIp + ":" + podPort);
|
||||
return masterIp + ":" + podPort;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -365,13 +365,14 @@ public class K8sClientUtil {
|
|||
.endEnv()
|
||||
.endContainer()
|
||||
.addNewVolume()
|
||||
.withName("workspace").withPersistentVolumeClaim(new V1PersistentVolumeClaimVolumeSource().claimName(pvcName))
|
||||
.withName("workspace")
|
||||
.withHostPath(new V1HostPathVolumeSource().path(hostPath + "/" + podName + "/tensorboard").type("DirectoryOrCreate"))
|
||||
// .withPersistentVolumeClaim(new V1PersistentVolumeClaimVolumeSource().claimName(pvcName))
|
||||
.endVolume()
|
||||
.withTerminationGracePeriodSeconds(14400L)
|
||||
.endSpec()
|
||||
.build();
|
||||
|
||||
|
||||
try {
|
||||
pod = api.createNamespacedPod(namespace, pod, null, null, null);
|
||||
} catch (ApiException e) {
|
||||
|
|
Loading…
Reference in New Issue