|
|
|
@@ -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; |
|
|
|
} |
|
|
|
} |