From 3eb71a7bf592fa2de21222bdd25e1da6f4c6eb4c Mon Sep 17 00:00:00 2001 From: zhouqunjie Date: Sat, 11 May 2024 15:15:46 +0800 Subject: [PATCH] multiple adapters for hps task submit Former-commit-id: 27cbca8bf1eec9807636b541ed1c68741e85e043 --- api/desc/hpc/pcm-hpc.api | 2 +- api/internal/logic/hpc/commithpctasklogic.go | 12 ++++++------ api/internal/types/types.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/desc/hpc/pcm-hpc.api b/api/desc/hpc/pcm-hpc.api index 8584895c..5a798e19 100644 --- a/api/desc/hpc/pcm-hpc.api +++ b/api/desc/hpc/pcm-hpc.api @@ -14,7 +14,7 @@ type ( Description string `json:"description,optional"` TenantId int64 `json:"tenantId,optional"` TaskId int64 `json:"taskId,optional"` - AdapterId string `json:"adapterId,optional"` + AdapterIds []string `json:"adapterId"` MatchLabels map[string]string `json:"matchLabels,optional"` CardCount int64 `json:"cardCount,optional"` WorkDir string `json:"workDir,optional"` //paratera:workingDir diff --git a/api/internal/logic/hpc/commithpctasklogic.go b/api/internal/logic/hpc/commithpctasklogic.go index 994f3f91..e716b2c0 100644 --- a/api/internal/logic/hpc/commithpctasklogic.go +++ b/api/internal/logic/hpc/commithpctasklogic.go @@ -7,7 +7,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" @@ -50,14 +49,15 @@ 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) + l.svcCtx.DbEngin.Raw("SELECT id FROM `t_cluster` where adapter_id in ? and label = ?", req.AdapterIds, 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) - clusterId := clusterIds[rand.Intn(len(clusterIds))] 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) env, _ := json.Marshal(req.Environment) diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 61596427..fa258e8a 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -1164,7 +1164,7 @@ type CommitHpcTaskReq struct { Description string `json:"description,optional"` TenantId int64 `json:"tenantId,optional"` TaskId int64 `json:"taskId,optional"` - AdapterId string `json:"adapterId,optional"` + AdapterIds []string `json:"adapterIds"` MatchLabels map[string]string `json:"matchLabels,optional"` CardCount int64 `json:"cardCount,optional"` WorkDir string `json:"workDir,optional"` //paratera:workingDir