From 7d067b0082abc973bd324ccbd32b185f45632a0f Mon Sep 17 00:00:00 2001 From: Jake <450705171@qq.com> Date: Tue, 14 May 2024 10:43:58 +0800 Subject: [PATCH] merge conflict Former-commit-id: b6a6a7c963182194e03b9673f5b2e47fe47952f4 --- api/internal/logic/hpc/commithpctasklogic.go | 28 +++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/api/internal/logic/hpc/commithpctasklogic.go b/api/internal/logic/hpc/commithpctasklogic.go index 13281d92..ebd6f252 100644 --- a/api/internal/logic/hpc/commithpctasklogic.go +++ b/api/internal/logic/hpc/commithpctasklogic.go @@ -8,7 +8,6 @@ import ( "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" "k8s.io/apimachinery/pkg/util/json" "math/rand" - "strconv" "time" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" @@ -51,26 +50,25 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t } var clusterIds []int64 - l.svcCtx.DbEngin.Raw("SELECT id FROM `t_cluster` where adapter_id = ? and label = ?", req.AdapterId, req.ClusterType).Scan(&clusterIds) - - adapterId, _ := strconv.ParseInt(req.AdapterId, 10, 64) - var adapterName string - l.svcCtx.DbEngin.Raw("SELECT name FROM `t_adapter` where id = ?", req.AdapterId).Scan(&adapterName) - if len(adapterName) == 0 || adapterName == "" { - return nil, errors.New("no corresponding adapter found") - } - clusterId := clusterIds[rand.Intn(len(clusterIds))] - var clusterName string - l.svcCtx.DbEngin.Raw("SELECT nickname FROM `t_cluster` where id = ?", clusterId).Scan(&clusterName) - - env, _ := json.Marshal(req.Environment) - + l.svcCtx.DbEngin.Raw("SELECT id FROM `t_cluster` where adapter_id in ? and label = ?", req.AdapterIds, req.ClusterType).Scan(&clusterIds) if len(clusterIds) == 0 || clusterIds == nil { resp.Code = 400 resp.Msg = "no cluster found" return resp, nil } + var clusterName string + var adapterId int64 + var adapterName string + clusterId := clusterIds[rand.Intn(len(clusterIds))] + l.svcCtx.DbEngin.Raw("SELECT nickname FROM `t_cluster` where id = ?", clusterId).Scan(&clusterName) + l.svcCtx.DbEngin.Raw("SELECT adapter_id FROM `t_cluster` where id = ?", clusterId).Scan(&adapterId) + l.svcCtx.DbEngin.Raw("SELECT name FROM `t_adapter` where id = ?", adapterId).Scan(&adapterName) + if len(adapterName) == 0 || adapterName == "" { + return nil, errors.New("no corresponding adapter found") + } + env, _ := json.Marshal(req.Environment) + hpcInfo := models.TaskHpc{ TaskId: taskModel.Id, AdapterId: uint(adapterId),