|
|
|
@@ -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) |
|
|
|
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 |
|
|
|
} |
|
|
|
|
|
|
|
adapterId, _ := strconv.ParseInt(req.AdapterId, 10, 64) |
|
|
|
var clusterName string |
|
|
|
var adapterId int64 |
|
|
|
var adapterName string |
|
|
|
l.svcCtx.DbEngin.Raw("SELECT name FROM `t_adapter` where id = ?", req.AdapterId).Scan(&adapterName) |
|
|
|
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") |
|
|
|
} |
|
|
|
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) |
|
|
|
|
|
|
|
if len(clusterIds) == 0 || clusterIds == nil { |
|
|
|
resp.Code = 400 |
|
|
|
resp.Msg = "no cluster found" |
|
|
|
return resp, nil |
|
|
|
} |
|
|
|
|
|
|
|
hpcInfo := models.TaskHpc{ |
|
|
|
TaskId: taskModel.Id, |
|
|
|
AdapterId: uint(adapterId), |
|
|
|
|