|
@@ -5,6 +5,7 @@ import api.common.util.*;
|
|
|
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;
|
|
@@ -311,20 +312,28 @@ public class ProjectService {
|
|
|
FileUtil.writeInputStreamToLocalFile(inputStream, algorithmTarLinuxTempPath);
|
|
|
LinuxUtil.execute("docker import " + algorithmTarLinuxTempPath + " " + dockerImage);
|
|
|
} else {
|
|
|
- String minioPath = algorithmPO.getMinioPath();
|
|
|
- if ("0".equals(algorithmPO.getDockerImport()) || algorithmPO.getDockerImport() == null) {
|
|
|
-
|
|
|
- MinioUtil.downloadToFile(minioClient, bucketName, minioPath, algorithmTarLinuxTempPath);
|
|
|
-
|
|
|
+ if ("1".equals(algorithmPO.getDockerImport()) && StringUtil.isNotEmpty(algorithmPO.getDockerImage())) {
|
|
|
+ dockerImage = algorithmPO.getDockerImage();
|
|
|
+ } else if ("0".equals(algorithmPO.getDockerImport()) || algorithmPO.getDockerImport() == null) {
|
|
|
+ String uploadMode = algorithmPO.getUploadMode();
|
|
|
+ if (DictConstants.ALGORITHM_UPLOAD_MODE_FILE.equals(uploadMode)) {
|
|
|
+ String minioPath = algorithmPO.getMinioPath();
|
|
|
+ MinioUtil.downloadToFile(minioClient, bucketName, minioPath, algorithmTarLinuxTempPath);
|
|
|
+ } else if (DictConstants.ALGORITHM_UPLOAD_MODE_GIT.equals(uploadMode)) {
|
|
|
+ String gitUrl = algorithmPO.getGitUrl();
|
|
|
+ String gitUserName = algorithmPO.getGitUserName();
|
|
|
+ String gitPassword = algorithmPO.getGitPassword();
|
|
|
+ GitUtil.clone(gitUrl, gitUserName, gitPassword, algorithmTarLinuxTempPath);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("算法 " + algorithmId + " 的 upload_mode 字段数据有误!");
|
|
|
+ }
|
|
|
+
|
|
|
LinuxUtil.execute("docker import " + algorithmTarLinuxTempPath + " " + dockerImage);
|
|
|
algorithmMapper.updateDockerImportAndDockerImageById("1", dockerImage, algorithmId);
|
|
|
- } else if ("1".equals(algorithmPO.getDockerImport()) && StringUtil.isNotEmpty(algorithmPO.getDockerImage())) {
|
|
|
- dockerImage = algorithmPO.getDockerImage();
|
|
|
} else {
|
|
|
throw new RuntimeException("算法 " + algorithmId + " 的 mysql 数据有误!");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
log.info("ProjectService--handleAlgorithm 项目 " + projectId + " 使用的算法镜像为:" + dockerImage);
|
|
|
return dockerImage;
|
|
|
}
|
|
@@ -340,7 +349,7 @@ public class ProjectService {
|
|
|
* @param jobTemplateYamlPathTarget 执行文件
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
- public void transferAndRunYaml(String jobTemplateYamlPathSource, String projectId, String projectType, String algorithmDockerImage, long completions, long parallelism, String jobTemplateYamlPathTarget) {
|
|
|
+ public void transferAndRunYaml(String jobTemplateYamlPathSource, String projectId, String algorithmDockerImage, long completions, long parallelism, String jobTemplateYamlPathTarget) {
|
|
|
log.info("ProjectConsumer--transferYaml 项目 " + projectId + " 的完成度为:" + completions);
|
|
|
log.info("ProjectConsumer--transferYaml 项目 " + projectId + " 的并行度为:" + parallelism);
|
|
|
String yamlSource = FileUtil.read(jobTemplateYamlPathSource);
|
|
@@ -353,16 +362,9 @@ public class ProjectService {
|
|
|
String replace5 = replace4.replace("completions-number", completions + "");
|
|
|
String replace6 = replace5.replace("parallelism-number", parallelism + "");
|
|
|
String replace7 = replace6.replace("apiVers1on", "apiVersion");
|
|
|
- String replace8 = replace7.replace("1atch/v1", "batch/v1");
|
|
|
- String finalYaml;
|
|
|
- if(DictConstants.PROJECT_TYPE_MANUAL.equals(projectType)){
|
|
|
- finalYaml = replace8;
|
|
|
- }else if (DictConstants.PROJECT_TYPE_AUTO_SUB.equals(projectType)){
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- log.info("ProjectConsumer--parseManualProject 开始执行 yaml 文件" + replace8);
|
|
|
- FileUtil.writeStringToLocalFile(replace8, jobTemplateYamlPathTarget);
|
|
|
+ String finalYaml = replace7.replace("1atch/v1", "batch/v1");
|
|
|
+ log.info("ProjectConsumer--parseManualProject 开始执行 yaml 文件" + finalYaml);
|
|
|
+ FileUtil.writeStringToLocalFile(finalYaml, jobTemplateYamlPathTarget);
|
|
|
|
|
|
KubernetesUtil.applyYaml(hostname, username, password, jobTemplateYamlPathTarget);
|
|
|
}
|