Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

LingxinMeng před 6 měsíci
rodič
revize
d5d49be1a5

+ 1 - 0
src/package/domain/comm_with_redis.go

@@ -81,6 +81,7 @@ func DeleteWaitingUser(taskCacheJson string) error {
 
 func AddWaitingCluster(project *entity.Project, task entity.Task) error {
 	taskCacheTemp := entity.TaskCache{
+		Env:                project.Env,
 		UserId:             project.UserId,
 		AlgorithmObjectKey: project.AlgorithmObjectKey,
 		UserParallelism:    project.Parallelism,

+ 1 - 0
src/package/entity/project.go

@@ -1,6 +1,7 @@
 package entity
 
 type Project struct {
+	Env                string `json:"env"` // 环境,需要根据该字段判断用哪个oss // cicv 国汽平台 pji 朴津平台
 	ProjectId          string `json:"projectId"`
 	AlgorithmObjectKey string `json:"algorithmObjectKey"`
 	EquipmentType      string `json:"equipmentType"`

+ 1 - 0
src/package/entity/task_cache.go

@@ -5,5 +5,6 @@ type TaskCache struct {
 	UserParallelism    int64  `json:"userParallelism"`
 	AlgorithmObjectKey string `json:"algorithmObjectKey"`
 	EquipmentType      string `json:"equipmentType"`
+	Env                string `json:"env"`
 	Task               Task   `json:"task"`
 }

+ 8 - 8
src/package/handler/start_project.go

@@ -137,7 +137,7 @@ func StartProject(c *gin.Context) {
 		c.JSON(http.StatusOK, entity.HttpResult{Status: false, Code: "400", Message: "请求参数格式错误。"})
 		return
 	}
-	if !checkEquipmentType(projectStartParam.EquipmentType) {
+	if !checkEquipmentType(projectStartParam.EquipmentType, *projectStartParam) {
 		c.JSON(http.StatusOK, entity.HttpResult{Status: true, Code: "400", Message: "设备类型错误。"})
 	}
 	// ------------ 维护一个运行任务队列,绑定用户id和节点名称,供下面两个判断同时使用(使用redis的队列)
@@ -171,7 +171,7 @@ func StartProject(c *gin.Context) {
 	c.JSON(http.StatusOK, entity.HttpResult{Status: true, Code: "2000", Message: "项目启动请求已被成功接收,等待调度处理。"})
 }
 
-func checkEquipmentType(equipmentType string) bool {
+func checkEquipmentType(equipmentType string, project entity.Project) bool {
 	/*
 		JIN_LONG_BA_SHI // "金龙中巴"
 		    PEI_SONG_JI_QI_REN // "智能配送机器人",
@@ -181,17 +181,17 @@ func checkEquipmentType(equipmentType string) bool {
 		    AN_FANG_JI_QI_REN // " "安防巡检机器人";
 	*/
 	if equipmentType == "JIN_LONG_BA_SHI" {
-		infra.GlobalLogger.Infof("接收到【金龙中巴】的仿真测试项目。")
+		infra.GlobalLogger.Infof("接收到【金龙中巴】的仿真测试项目:%v", project)
 	} else if equipmentType == "PEI_SONG_JI_QI_REN" {
-		infra.GlobalLogger.Infof("接收到【智能配送机器人】的仿真测试项目。")
+		infra.GlobalLogger.Infof("接收到【智能配送机器人】的仿真测试项目:%v", project)
 	} else if equipmentType == "SAO_DI_JI_QI_REN" {
-		infra.GlobalLogger.Infof("接收到【室内清洁机器人】的仿真测试项目。")
+		infra.GlobalLogger.Infof("接收到【室内清洁机器人】的仿真测试项目:%v", project)
 	} else if equipmentType == "YI_DAO_JI_QI_REN" {
-		infra.GlobalLogger.Infof("接收到【引导服务机器人】的仿真测试项目。")
+		infra.GlobalLogger.Infof("接收到【引导服务机器人】的仿真测试项目:%v", project)
 	} else if equipmentType == "PU_JIN_DUO_GONG_NENG_CHE" {
-		infra.GlobalLogger.Infof("接收到【朴津多功能车】的仿真测试项目。")
+		infra.GlobalLogger.Infof("接收到【朴津多功能车】的仿真测试项目:%v", project)
 	} else if equipmentType == "AN_FANG_JI_QI_REN" {
-		infra.GlobalLogger.Infof("接收到【安防巡检机器人】的仿真测试项目。")
+		infra.GlobalLogger.Infof("接收到【安防巡检机器人】的仿真测试项目:%v", project)
 	} else {
 		infra.GlobalLogger.Infof("接收到未知的设备类型【%v】", equipmentType)
 		return false

+ 12 - 11
src/package/service/run_task.go

@@ -68,7 +68,7 @@ func RunWaitingUser() {
 	}
 }
 
-// RunWaitingCluster 集群等待队列中的任务判断是否可以加入集群运行队列
+// 集群等待队列中的任务判断是否可以加入集群运行队列
 func RunWaitingCluster() {
 	infra.GlobalLogger.Infof("启动【集群等待队列】监控进程。")
 	for {
@@ -90,11 +90,9 @@ func RunWaitingCluster() {
 		algorithmExist := false
 
 		if can {
-			//infra.GlobalLogger.Infof("节点 %v 有剩余并行度。", gpuNode)
 			// 判断是否有待运行的任务
 			waitingClusterNumber, _ := infra.GlobalRedisClient.LLen(global.KeyTaskQueueWaitingCluster).Result()
 			if waitingClusterNumber == 0 {
-				//infra.GlobalLogger.Info("集群没有等待运行的任务。")
 				global.GpuNodeListMutex.Unlock()
 				continue
 			} else {
@@ -121,7 +119,7 @@ func RunWaitingCluster() {
 					continue
 				}
 			}
-			// --------------- 下载算法 --------------- todo 算法这里需要控制已经下载过的算法就不要再次下载了
+			// --------------- 下载算法 ---------------
 			{
 				infra.GlobalLogger.Infof("开始下载算法 %v。", firstTaskCache.AlgorithmObjectKey)
 				algorithmTarName = filepath.Base(firstTaskCache.AlgorithmObjectKey)
@@ -131,7 +129,7 @@ func RunWaitingCluster() {
 				algorithmImageNameWithVersion = algorithmImageName + ":latest"
 				algorithmExist = util.ImageExists(infra.GlobalDockerClient, algorithmImageName)
 				if !algorithmExist {
-					if firstTaskCache.EquipmentType == "JIN_LONG_BA_SHI" || firstTaskCache.EquipmentType == "PU_JIN_DUO_GONG_NENG_CHE" {
+					if firstTaskCache.Env == "cicv" {
 						err = infra.GlobalOssBucketCicv.GetObjectToFile(firstTaskCache.AlgorithmObjectKey, algorithmTarPath)
 					} else {
 						err = infra.GlobalOssBucketPji.GetObjectToFile(firstTaskCache.AlgorithmObjectKey, algorithmTarPath)
@@ -266,17 +264,20 @@ func RunWaitingCluster() {
 				continue
 			}
 			podString = strings.Replace(podString, "vtd-command", infra.ApplicationYaml.K8s.VtdCommandPjisuv, -1)
-			podString = strings.Replace(podString, "oss-type", infra.ApplicationYaml.OssCicv.Type, -1)
-			podString = strings.Replace(podString, "oss-ip", infra.ApplicationYaml.OssCicv.Endpoint, -1) // 不带http://前缀
-			podString = strings.Replace(podString, "oss-access-key", infra.ApplicationYaml.OssCicv.AccessKeyId, -1)
-			podString = strings.Replace(podString, "oss-secret-key", infra.ApplicationYaml.OssCicv.AccessKeySecret, -1)
-			podString = strings.Replace(podString, "oss-bucket", infra.ApplicationYaml.OssCicv.BucketName, -1)
 		} else {
 			if podString, err = util.ReadFile(infra.ApplicationYaml.K8s.VtdPodTemplateYamlPjibot); err != nil {
 				infra.GlobalLogger.Error(err)
 				continue
 			}
 			podString = strings.Replace(podString, "vtd-command", infra.ApplicationYaml.K8s.VtdCommandPjibot, -1)
+		}
+		if firstTaskCache.Env == "cicv" {
+			podString = strings.Replace(podString, "oss-type", infra.ApplicationYaml.OssCicv.Type, -1)
+			podString = strings.Replace(podString, "oss-ip", infra.ApplicationYaml.OssCicv.Endpoint, -1) // 不带http://前缀
+			podString = strings.Replace(podString, "oss-access-key", infra.ApplicationYaml.OssCicv.AccessKeyId, -1)
+			podString = strings.Replace(podString, "oss-secret-key", infra.ApplicationYaml.OssCicv.AccessKeySecret, -1)
+			podString = strings.Replace(podString, "oss-bucket", infra.ApplicationYaml.OssCicv.BucketName, -1)
+		} else {
 			podString = strings.Replace(podString, "oss-type", infra.ApplicationYaml.OssPji.Type, -1)
 			podString = strings.Replace(podString, "oss-ip", infra.ApplicationYaml.OssPji.Endpoint, -1) // 不带http://前缀
 			podString = strings.Replace(podString, "oss-access-key", infra.ApplicationYaml.OssPji.AccessKeyId, -1)
@@ -303,7 +304,7 @@ func RunWaitingCluster() {
 		tempDir := "/mnt/disk001/dcl_dispatch_server/temp/"
 		util.CreateDir(tempDir)
 		xoscLocalPath := tempDir + util.NewShortUUID() + ".xosc"
-		if firstTaskCache.EquipmentType == "JIN_LONG_BA_SHI" || firstTaskCache.EquipmentType == "PU_JIN_DUO_GONG_NENG_CHE" {
+		if firstTaskCache.Env == "cicv" { // cicv 或 pji
 			err = infra.GlobalOssBucketCicv.GetObjectToFile(firstTaskCache.Task.Scenario.ScenarioOsc, xoscLocalPath)
 		} else {
 			err = infra.GlobalOssBucketPji.GetObjectToFile(firstTaskCache.Task.Scenario.ScenarioOsc, xoscLocalPath)