From d8e4331b38690a5aa4b5fc5fe6756af6f07990d5 Mon Sep 17 00:00:00 2001 From: tzwang Date: Wed, 1 Nov 2023 17:37:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E7=AE=97=E8=81=94=E5=8A=A8=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: d9c1cd0261a2a21747728b3945c7a1cfa8cea303 --- api/desc/storelink/pcm-storelink.api | 11 +++++++++-- api/internal/logic/storelink/deletelinkimagelogic.go | 8 ++++++++ api/internal/logic/storelink/deletelinktasklogic.go | 8 ++++++++ api/internal/logic/storelink/getaispecslogic.go | 9 +++++++++ api/internal/storeLink/octopus.go | 2 ++ go.mod | 2 +- go.sum | 4 ++-- 7 files changed, 39 insertions(+), 5 deletions(-) diff --git a/api/desc/storelink/pcm-storelink.api b/api/desc/storelink/pcm-storelink.api index 021087b5..7e9fa909 100644 --- a/api/desc/storelink/pcm-storelink.api +++ b/api/desc/storelink/pcm-storelink.api @@ -50,9 +50,15 @@ type ( ImageId string `json:"imageId"` Cmd string `json:"cmd"` Params []*ParamSl `json:"params"` + Envs []*EnvSl `json:"params"` ResourceId string `json:"resourceId"` } + EnvSl { + Key string `json:"key"` + Val string `json:"value"` + } + ParamSl { Key string `json:"key"` Val string `json:"value"` @@ -109,10 +115,11 @@ type ( GetResourceSpecsResp { Success bool `json:"success"` ResourceSpecs []*ResourceSpecSl `json:"resourceSpecs"` + ErrorMsg string `json:"errorMsg"` } ResourceSpecSl { - ParticipantId string `json:"participantId"` + ParticipantId int64 `json:"participantId"` ParticipantName string `json:"participantName"` SpecName string `json:"specName"` SpecId string `json:"specId"` @@ -120,7 +127,7 @@ type ( } ParticipantSl { - ParticipantId string `json:"id"` + ParticipantId int64 `json:"id"` ParticipantName string `json:"name"` ParticipantType string `json:"type"` } diff --git a/api/internal/logic/storelink/deletelinkimagelogic.go b/api/internal/logic/storelink/deletelinkimagelogic.go index 519b48fe..02f52cbc 100644 --- a/api/internal/logic/storelink/deletelinkimagelogic.go +++ b/api/internal/logic/storelink/deletelinkimagelogic.go @@ -5,6 +5,7 @@ import ( "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/storeLink" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models" "github.com/zeromicro/go-zero/core/logx" ) @@ -25,6 +26,13 @@ func NewDeleteLinkImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *D func (l *DeleteLinkImageLogic) DeleteLinkImage(req *types.DeleteLinkImageReq) (resp *types.DeleteLinkImageResp, err error) { participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + if *participant == (models.StorelinkCenter{}) { + resp = &types.DeleteLinkImageResp{} + resp.Success = false + resp.ErrorMsg = "partId不存在" + return resp, nil + } + storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant) img, err := storelink.ILinkage.DeleteImage(req.ImageId) if err != nil { diff --git a/api/internal/logic/storelink/deletelinktasklogic.go b/api/internal/logic/storelink/deletelinktasklogic.go index bcc11933..6e710244 100644 --- a/api/internal/logic/storelink/deletelinktasklogic.go +++ b/api/internal/logic/storelink/deletelinktasklogic.go @@ -5,6 +5,7 @@ import ( "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/storeLink" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models" "github.com/zeromicro/go-zero/core/logx" ) @@ -25,6 +26,13 @@ func NewDeleteLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *De func (l *DeleteLinkTaskLogic) DeleteLinkTask(req *types.DeleteLinkTaskReq) (resp *types.DeleteLinkTaskResp, err error) { participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + if *participant == (models.StorelinkCenter{}) { + resp = &types.DeleteLinkTaskResp{} + resp.Success = false + resp.ErrorMsg = "partId不存在" + return resp, nil + } + storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant) task, err := storelink.ILinkage.DeleteTask(req.TaskId) if err != nil { diff --git a/api/internal/logic/storelink/getaispecslogic.go b/api/internal/logic/storelink/getaispecslogic.go index 137b5e43..06812f06 100644 --- a/api/internal/logic/storelink/getaispecslogic.go +++ b/api/internal/logic/storelink/getaispecslogic.go @@ -6,6 +6,7 @@ import ( "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/storeLink" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models" ) type GetAISpecsLogic struct { @@ -24,6 +25,14 @@ func NewGetAISpecsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAIS func (l *GetAISpecsLogic) GetAISpecs(req *types.GetResourceSpecsReq) (resp *types.GetResourceSpecsResp, err error) { participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + if *participant == (models.StorelinkCenter{}) { + resp = &types.GetResourceSpecsResp{} + resp.Success = false + resp.ResourceSpecs = nil + resp.ErrorMsg = "partId不存在" + return resp, nil + } + storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant) specs, err := storelink.ILinkage.QuerySpecs() if err != nil { diff --git a/api/internal/storeLink/octopus.go b/api/internal/storeLink/octopus.go index b8663ffa..2dc74aab 100644 --- a/api/internal/storeLink/octopus.go +++ b/api/internal/storeLink/octopus.go @@ -120,6 +120,7 @@ func (o *OctopusLink) SubmitTask(imageId string, cmd string, params []string, re prms = append(prms, &p) } + var str string req := &octopus.CreateTrainJobReq{ Platform: o.participant.Name, Params: &octopus.CreateTrainJobParam{ @@ -134,6 +135,7 @@ func (o *OctopusLink) SubmitTask(imageId string, cmd string, params []string, re MinSucceededTaskCount: 1, TaskNumber: 1, Parameters: prms, + Envs: str, }, }, }, diff --git a/go.mod b/go.mod index c1c81dfd..9227fffd 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230817103341-2459e5bfc835 gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes v0.0.0-20231027083610-c8a292768f4a gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231024115530-f6fd0505d2a1 - gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20231011071802-c6a7637b74e4 + gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20231101091522-38307e241dfd gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20231024105731-cbdceff549c9 gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714030125-a52fa198ddf4 gitlink.org.cn/jcce-pcm/utils v0.0.2 diff --git a/go.sum b/go.sum index 68c31a2f..208ebef6 100644 --- a/go.sum +++ b/go.sum @@ -1041,8 +1041,8 @@ gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes v0.0.0-20231027083610-c8a2927 gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes v0.0.0-20231027083610-c8a292768f4a/go.mod h1:xtSfvDUd+jJhqHBBibZ1d9/ud3oN9nxaNYYHwz+CDgY= gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231024115530-f6fd0505d2a1 h1:4Ibzcl4waYiHO3tdbqvcLUWEoV51ZaJhZBi7T518AA8= gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231024115530-f6fd0505d2a1/go.mod h1:pisJKAI8FRFFUcBaH3Gob+ENXWRM97rpuYmv9s1raag= -gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20231011071802-c6a7637b74e4 h1:iv78VZ5+j6/VNkEyD/GSmTJ96rpxzpKDUNknAoXsAmg= -gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20231011071802-c6a7637b74e4/go.mod h1:uyvpVqG1jHDXX+ubXI0RBwnWXzVykD/mliqGQIDvRoo= +gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20231101091522-38307e241dfd h1:9GIKpN6nel4U5jD91HL/vjzwo+EHTpE13SkT7WKyXtQ= +gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20231101091522-38307e241dfd/go.mod h1:uyvpVqG1jHDXX+ubXI0RBwnWXzVykD/mliqGQIDvRoo= gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20231024105731-cbdceff549c9 h1:r352e/Vrnity+BgrWyWCgn8uT2xPg6O86g+H4aIOdX8= gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20231024105731-cbdceff549c9/go.mod h1:m75SVNfNa1TUBlQtBfR0CeETQ0ez2RIUqlSCn1Mb/js= gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714030125-a52fa198ddf4 h1:r2hBP5G/bbkPpDTPk3ENnQxD82vkoYMSeNHYhNAVRX4=