|
@@ -2,17 +2,16 @@ package com.css.simulation.resource.scheduler.service;
|
|
|
|
|
|
import api.common.pojo.constants.DictConstants;
|
|
|
import api.common.util.*;
|
|
|
+import com.css.simulation.resource.scheduler.configuration.kubernetes.KubernetesConfiguration;
|
|
|
import com.css.simulation.resource.scheduler.mapper.*;
|
|
|
import com.css.simulation.resource.scheduler.pojo.po.*;
|
|
|
import com.css.simulation.resource.scheduler.pojo.to.*;
|
|
|
import com.css.simulation.resource.scheduler.util.GitUtil;
|
|
|
import com.css.simulation.resource.scheduler.util.KubernetesUtil;
|
|
|
import com.css.simulation.resource.scheduler.util.MinioUtil;
|
|
|
-import com.css.simulation.resource.scheduler.util.ProjectUtil;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import io.kubernetes.client.openapi.ApiClient;
|
|
|
import io.minio.MinioClient;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -70,9 +69,7 @@ public class ProjectService {
|
|
|
@Resource
|
|
|
AlgorithmMapper algorithmMapper;
|
|
|
@Resource
|
|
|
- ApiClient apiClient;
|
|
|
- @Resource
|
|
|
- ProjectUtil projectUtil;
|
|
|
+ KubernetesConfiguration kubernetesConfiguration;
|
|
|
|
|
|
// -------------------------------- Comment --------------------------------
|
|
|
|
|
@@ -272,15 +269,23 @@ public class ProjectService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 将 master 节点设置成镜像仓库,导入镜像的同时 commit 到仓库当中,供其他节点 pull
|
|
|
+ * @param projectId
|
|
|
+ * @param algorithmId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@SneakyThrows
|
|
|
@Transactional
|
|
|
public String handleAlgorithm(String projectId, String algorithmId) {
|
|
|
- String dockerImage;
|
|
|
//4-1 根据算法 id 获取算法文件地址、是否已导入成镜像。
|
|
|
AlgorithmPO algorithmPO = algorithmMapper.selectById(algorithmId);
|
|
|
- String algorithmTarLinuxTempPath = linuxTempPath + "algorithm/" + algorithmId + ".tar";
|
|
|
- dockerImage = "algorithm_" + algorithmId + ":latest";
|
|
|
+ String dockerImage;
|
|
|
+ String algorithmTarLinuxTempPath;
|
|
|
+
|
|
|
if (algorithmPO == null) {
|
|
|
+ dockerImage = "algorithm_" + algorithmId + ":latest";
|
|
|
+ algorithmTarLinuxTempPath = linuxTempPath + "algorithm/" + algorithmId + ".tar";
|
|
|
// 访问索为远程接口
|
|
|
String tokenUri = "http://open-api.zoogooy.com/cgi-bin/token/token?grant_type=client_credential";
|
|
|
String appid = "3e64be4a29e5478f9717d53c11ab26ad";
|
|
@@ -329,6 +334,9 @@ public class ProjectService {
|
|
|
FileUtil.writeInputStreamToLocalFile(inputStream, algorithmTarLinuxTempPath);
|
|
|
LinuxUtil.execute("docker import " + algorithmTarLinuxTempPath + " " + dockerImage);
|
|
|
} else {
|
|
|
+ String algorithmCode = algorithmPO.getAlgorithmCode();
|
|
|
+ dockerImage = "algorithm_" + algorithmCode + ":latest";
|
|
|
+ algorithmTarLinuxTempPath = linuxTempPath + "algorithm/" + algorithmCode + ".tar";
|
|
|
if ("1".equals(algorithmPO.getDockerImport()) && StringUtil.isNotEmpty(algorithmPO.getDockerImage())) {
|
|
|
dockerImage = algorithmPO.getDockerImage();
|
|
|
} else if ("0".equals(algorithmPO.getDockerImport()) || algorithmPO.getDockerImport() == null) {
|