diff --git a/api/internal/logic/storelink/submitlinktasklogic.go b/api/internal/logic/storelink/submitlinktasklogic.go index e2ed5e44..006e85f2 100644 --- a/api/internal/logic/storelink/submitlinktasklogic.go +++ b/api/internal/logic/storelink/submitlinktasklogic.go @@ -26,14 +26,14 @@ func NewSubmitLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Su func (l *SubmitLinkTaskLogic) SubmitLinkTask(req *types.SubmitLinkTaskReq) (resp *types.SubmitLinkTaskResp, err error) { participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant) - var envs []string - if len(req.Envs) != 0 { - for _, v := range req.Envs { - env := v.Key + storeLink.COMMA + v.Val - envs = append(envs, env) + var params []string + if len(req.Params) != 0 { + for _, v := range req.Params { + param := v.Key + storeLink.COMMA + v.Val + params = append(params, param) } } - task, err := storelink.ILinkage.SubmitTask(req.ImageId, req.Cmd, envs, "") + task, err := storelink.ILinkage.SubmitTask(req.ImageId, req.Cmd, params, req.ResourceId) if err != nil { return nil, err } diff --git a/api/internal/storeLink/octopus.go b/api/internal/storeLink/octopus.go index e7227ced..73c89f1a 100644 --- a/api/internal/storeLink/octopus.go +++ b/api/internal/storeLink/octopus.go @@ -5,6 +5,7 @@ import ( "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils" "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus" + "strings" ) type OctopusLink struct { @@ -19,6 +20,7 @@ const ( IMG_NAME_PREFIX = "oct_" IMG_VERSION_PREFIX = "version_" TASK_NAME_PREFIX = "trainJob_" + RESOURCE_POOL = "common-pool" ) func NewOctopusLink(ctx context.Context, svcCtx *svc.ServiceContext, platform string) *OctopusLink { @@ -106,14 +108,23 @@ func (o *OctopusLink) QueryImageList() (interface{}, error) { return imgListResp, nil } -func (o *OctopusLink) SubmitTask(imageId string, cmd string, envs []string, resourceId string) (interface{}, error) { +func (o *OctopusLink) SubmitTask(imageId string, cmd string, params []string, resourceId string) (interface{}, error) { // octopus提交任务 + var prms []*octopus.Parameters + for _, param := range params { + var p octopus.Parameters + s := strings.Split(param, COMMA) + p.Key = s[0] + p.Value = s[1] + prms = append(prms, &p) + } + req := &octopus.CreateTrainJobReq{ Platform: o.platform, Params: &octopus.CreateTrainJobParam{ ImageId: imageId, - Name: TASK_NAME_PREFIX + utils.RandomString(5), - ResourcePool: "common-pool", + Name: TASK_NAME_PREFIX + utils.RandomString(7), + ResourcePool: RESOURCE_POOL, Config: []*octopus.Config{ { Command: cmd, @@ -121,6 +132,7 @@ func (o *OctopusLink) SubmitTask(imageId string, cmd string, envs []string, reso MinFailedTaskCount: 1, MinSucceededTaskCount: 1, TaskNumber: 1, + Parameters: prms, }, }, }, diff --git a/api/internal/storeLink/storeLink.go b/api/internal/storeLink/storeLink.go index 273846df..b05ef04c 100644 --- a/api/internal/storeLink/storeLink.go +++ b/api/internal/storeLink/storeLink.go @@ -14,7 +14,7 @@ type Linkage interface { UploadImage(path string) (interface{}, error) DeleteImage(imageId string) (interface{}, error) QueryImageList() (interface{}, error) - SubmitTask(imageId string, cmd string, envs []string, resourceId string) (interface{}, error) + SubmitTask(imageId string, cmd string, params []string, resourceId string) (interface{}, error) QueryTask(taskId string) (interface{}, error) DeleteTask(taskId string) (interface{}, error) }