From 2809aef72f412d059c2ff399af20660daf0866b2 Mon Sep 17 00:00:00 2001 From: qiwang <1364512070@qq.com> Date: Tue, 2 Apr 2024 16:24:00 +0800 Subject: [PATCH 01/17] feat:add create mulserver interface Former-commit-id: daa650029ae7bf4beeebfe34b1bec5c686c91229 --- api/desc/pcm.api | 4 + api/desc/vm/pcm-vm.api | 61 +++++++++++--- api/etc/pcm.yaml | 3 +- api/internal/handler/routes.go | 5 ++ .../handler/vm/createmulserverhandler.go | 28 +++++++ .../logic/core/commitvmtasktemplogic.go | 21 ++++- api/internal/logic/vm/createmulserverlogic.go | 82 +++++++++++++++++++ api/internal/types/types.go | 63 +++++++++++--- go.mod | 10 +-- go.sum | 16 ++-- 10 files changed, 252 insertions(+), 41 deletions(-) create mode 100644 api/internal/handler/vm/createmulserverhandler.go create mode 100644 api/internal/logic/vm/createmulserverlogic.go diff --git a/api/desc/pcm.api b/api/desc/pcm.api index 24fd3043..ab6669c7 100644 --- a/api/desc/pcm.api +++ b/api/desc/pcm.api @@ -405,6 +405,10 @@ service pcm { @handler CreateServerHandler post /vm/createServer (CreateServerReq) returns (CreateServerResp) + @doc "跨域创建虚拟机" + @handler CreateMulServerHandler + post /vm/createMulServer (CreateMulServerReq) returns (CreateMulServerResp) + @doc "根据ID查询虚拟机详情" @handler GetServersDetailedByIdHandler get /vm/getServersDetailedById (GetServersDetailedByIdReq) returns (GetServersDetailedByIdResp) diff --git a/api/desc/vm/pcm-vm.api b/api/desc/vm/pcm-vm.api index b632439e..fb21c68c 100644 --- a/api/desc/vm/pcm-vm.api +++ b/api/desc/vm/pcm-vm.api @@ -121,19 +121,19 @@ type ( } ServersDetailed { - //created string `json:"created" copier:"created"` - Id string `json:"Id" copier:"Id"` - Name string `json:"Name" copier:"Name"` - OSTaskState uint32 `json:"OSTaskState" copier:"OSTaskState"` - Status string `json:"Status" copier:"Status"` - VmState string `json:"VmState" copier:"VmState"` - OS_EXT_SRV_ATTR_Instance_Name string `json:"OS_EXT_SRV_ATTR_Instance_Name" copier:"OS_EXT_SRV_ATTR_Instance_Name"` - Created string `json:"Created" copier:"Created"` - HostId string `json:"HostId" copier:"HostId"` - Ip string `json:"Ip" copier:"Ip"` - Image string `json:"Image" copier:"Image"` - Updated string `json:"Updated" copier:"Updated"` - Flavor string `json:"Flavor" copier:"Flavor"` + Id string `json:"id" copier:"Id"` + Name string `json:"name" copier:"Name"` + OSTaskState uint32 `json:"os_task_state" copier:"OSTaskState"` + Status string `json:"status" copier:"Status"` + VmState string `json:"vm_state" copier:"VmState"` + OS_EXT_SRV_ATTR_Instance_Name string `json:"os_ext_srv_attr_instance_name" copier:"OS_EXT_SRV_ATTR_Instance_Name"` + Created string `json:"created" copier:"Created"` + HostId string `json:"hostId" copier:"HostId"` + Ip string `json:"ip" copier:"Ip"` + Image string `json:"image" copier:"Image"` + Updated string `json:"updated" copier:"Updated"` + Flavor string `json:"flavor" copier:"Flavor"` + Key_name string `json:"key_name" copier:"Key_name"` } ) @@ -368,6 +368,41 @@ type ( } ) +type ( + CreateMulServerReq { + CreateMulServer []CreateMulServer `json:"createMulServer,optional"` + } + CreateMulServer { + Platform string `json:"platform,optional"` + CrServer MulCrServer `json:"crserver" copier:"CrServer"` + } + MulCrServer { + Server MulServer `json:"server" copier:"Server"` + } + MulServer { + AvailabilityZone string `json:"availability_zone" copier:"AvailabilityZone"` + Name string `json:"name,optional" copier:"Name"` + FlavorRef string `json:"flavorRef,optional" copier:"FlavorRef"` + Description string `json:"description,optional" copier:"Description"` + ImageRef string `json:"imageRef,optional" copier:"ImageRef"` + Networks []CreNetwork `json:"networks,optional" copier:"Networks"` + MinCount int32 `json:"min_count,optional" copier:"MinCount"` + } + CreateMulServerResp { + Server []MulServerResp `json:"server" copier:"Server"` + Code int32 `json:"code,omitempty"` + Msg string `json:"msg,omitempty"` + ErrorMsg string `json:"errorMsg,omitempty"` + } + MulServerResp { + Id string `json:"id" copier:"Id"` + Links []Links `json:"links" copier:"Links"` + OSDCFDiskConfig string `json:"OS_DCF_diskConfig" copier:"OSDCFDiskConfig"` + SecurityGroups []Security_groups_server `json:"security_groups" copier:"SecurityGroups"` + AdminPass string `json:"adminPass" copier:"AdminPass"` + } +) + type( RebuildServerReq{ ServerId string `json:"server_id" copier:"ServerId"` diff --git a/api/etc/pcm.yaml b/api/etc/pcm.yaml index b2b4766e..1be194eb 100644 --- a/api/etc/pcm.yaml +++ b/api/etc/pcm.yaml @@ -5,7 +5,8 @@ Port: 8999 Timeout: 50000 DB: - DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true&loc=Local + # DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true&loc=Local + DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true&loc=Local Redis: Host: 10.206.0.12:6379 Pass: redisPW123 diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index 45e701c2..91736dbf 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -476,6 +476,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/vm/createServer", Handler: vm.CreateServerHandler(serverCtx), }, + { + Method: http.MethodPost, + Path: "/vm/createMulServer", + Handler: vm.CreateMulServerHandler(serverCtx), + }, { Method: http.MethodGet, Path: "/vm/getServersDetailedById", diff --git a/api/internal/handler/vm/createmulserverhandler.go b/api/internal/handler/vm/createmulserverhandler.go new file mode 100644 index 00000000..613f1ca2 --- /dev/null +++ b/api/internal/handler/vm/createmulserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" +) + +func CreateMulServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateMulServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateMulServerLogic(r.Context(), svcCtx) + resp, err := l.CreateMulServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/logic/core/commitvmtasktemplogic.go b/api/internal/logic/core/commitvmtasktemplogic.go index f9501d46..85137007 100644 --- a/api/internal/logic/core/commitvmtasktemplogic.go +++ b/api/internal/logic/core/commitvmtasktemplogic.go @@ -2,6 +2,13 @@ package core import ( "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" @@ -25,6 +32,18 @@ func NewCommitVmTaskTempLogic(ctx context.Context, svcCtx *svc.ServiceContext) * func (l *CommitVmTaskTempLogic) CommitVmTaskTemp(req *types.CommitVmTaskReq) (resp *types.CommitVmTaskResp, err error) { // todo: add your logic here and delete this line - + CreateServerReq := &openstack.CreateServerReq{} + err = copier.CopyWithOption(CreateServerReq, req, copier.Option{Converters: utils.Converters}) + CreateServerResp, err := l.svcCtx.OpenstackRpc.CreateServer(l.ctx, CreateServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateServerResp, copier.Option{Converters: utils.Converters}) + return resp, err return } diff --git a/api/internal/logic/vm/createmulserverlogic.go b/api/internal/logic/vm/createmulserverlogic.go new file mode 100644 index 00000000..b59f575c --- /dev/null +++ b/api/internal/logic/vm/createmulserverlogic.go @@ -0,0 +1,82 @@ +package vm + +import ( + "context" + "fmt" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateMulServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateMulServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateMulServerLogic { + return &CreateMulServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// ServerLinks 表示服务器链接的结构体 +type ServerLinks struct { + Href string `json:"href"` // 注意:在JSON中,"href "有一个额外的空格,需要移除 + Rel string `json:"rel"` +} + +// SecurityGroup 表示安全组的结构体 +type SecurityGroup struct { + Name string `json:"name"` +} + +// Server 表示服务器的结构体 +type Server struct { + ID string `json:"id"` + Links []ServerLinks `json:"links"` + OSDCFDiskConfig string `json:"OS_DCF_diskConfig"` + SecurityGroups []SecurityGroup `json:"security_groups"` + AdminPass string `json:"adminPass"` +} + +// Response 表示整个响应的结构体 +type Response struct { + Server Server `json:"server"` +} + +func (l *CreateMulServerLogic) CreateMulServer(req *types.CreateMulServerReq) (resp *types.CreateMulServerResp, err error) { + // todo: add your logic here and delete this line + CreateServerReq := &openstack.CreateServerReq{} + var response Response + fmt.Println("请求入参:", req) + for _, server := range req.CreateMulServer { + fmt.Println("入参参数:", server) + err = copier.CopyWithOption(CreateServerReq, server, copier.Option{Converters: utils.Converters}) + CreateServerResp, err := l.svcCtx.OpenstackRpc.CreateServer(l.ctx, CreateServerReq) + fmt.Println("返回结果:", CreateServerResp) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to create Server list"), "Failed to get db Server list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateServerResp) + fmt.Println("返回结果b:", marshal) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &response) + } + err = copier.CopyWithOption(&resp, &response, copier.Option{Converters: utils.Converters}) + fmt.Println("返回结果c:", resp) + return resp, err +} diff --git a/api/internal/types/types.go b/api/internal/types/types.go index d6214767..2fa9ef29 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -2735,18 +2735,19 @@ type ListServersDetailedResp struct { } type ServersDetailed struct { - Id string `json:"Id" copier:"Id"` - Name string `json:"Name" copier:"Name"` - OSTaskState uint32 `json:"OSTaskState" copier:"OSTaskState"` - Status string `json:"Status" copier:"Status"` - VmState string `json:"VmState" copier:"VmState"` - OS_EXT_SRV_ATTR_Instance_Name string `json:"OS_EXT_SRV_ATTR_Instance_Name" copier:"OS_EXT_SRV_ATTR_Instance_Name"` - Created string `json:"Created" copier:"Created"` - HostId string `json:"HostId" copier:"HostId"` - Ip string `json:"Ip" copier:"Ip"` - Image string `json:"Image" copier:"Image"` - Updated string `json:"Updated" copier:"Updated"` - Flavor string `json:"Flavor" copier:"Flavor"` + Id string `json:"id" copier:"Id"` + Name string `json:"name" copier:"Name"` + OSTaskState uint32 `json:"os_task_state" copier:"OSTaskState"` + Status string `json:"status" copier:"Status"` + VmState string `json:"vm_state" copier:"VmState"` + OS_EXT_SRV_ATTR_Instance_Name string `json:"os_ext_srv_attr_instance_name" copier:"OS_EXT_SRV_ATTR_Instance_Name"` + Created string `json:"created" copier:"Created"` + HostId string `json:"hostId" copier:"HostId"` + Ip string `json:"ip" copier:"Ip"` + Image string `json:"image" copier:"Image"` + Updated string `json:"updated" copier:"Updated"` + Flavor string `json:"flavor" copier:"Flavor"` + Key_name string `json:"key_name" copier:"Key_name"` } type GetServersDetailedByIdReq struct { @@ -2983,6 +2984,44 @@ type ServerResp struct { AdminPass string `json:"adminPass" copier:"AdminPass"` } +type CreateMulServerReq struct { + CreateMulServer []CreateMulServer `json:"createMulServer,optional"` +} + +type CreateMulServer struct { + Platform string `json:"platform,optional"` + CrServer MulCrServer `json:"crserver" copier:"CrServer"` +} + +type MulCrServer struct { + Server MulServer `json:"server" copier:"Server"` +} + +type MulServer struct { + AvailabilityZone string `json:"availability_zone" copier:"AvailabilityZone"` + Name string `json:"name,optional" copier:"Name"` + FlavorRef string `json:"flavorRef,optional" copier:"FlavorRef"` + Description string `json:"description,optional" copier:"Description"` + ImageRef string `json:"imageRef,optional" copier:"ImageRef"` + Networks []CreNetwork `json:"networks,optional" copier:"Networks"` + MinCount int32 `json:"min_count,optional" copier:"MinCount"` +} + +type CreateMulServerResp struct { + Server []MulServerResp `json:"server" copier:"Server"` + Code int32 `json:"code,omitempty"` + Msg string `json:"msg,omitempty"` + ErrorMsg string `json:"errorMsg,omitempty"` +} + +type MulServerResp struct { + Id string `json:"id" copier:"Id"` + Links []Links `json:"links" copier:"Links"` + OSDCFDiskConfig string `json:"OS_DCF_diskConfig" copier:"OSDCFDiskConfig"` + SecurityGroups []Security_groups_server `json:"security_groups" copier:"SecurityGroups"` + AdminPass string `json:"adminPass" copier:"AdminPass"` +} + type RebuildServerReq struct { ServerId string `json:"server_id" copier:"ServerId"` Platform string `form:"platform,optional"` diff --git a/go.mod b/go.mod index 1717af8a..03bfbc16 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module gitlink.org.cn/JointCloud/pcm-coordinator -go 1.22 - -toolchain go1.22.1 +go 1.21 require ( github.com/JCCE-nudt/zero-contrib/zrpc/registry/nacos v0.0.0-20230419021610-13bbc83fbc3c @@ -25,7 +23,7 @@ require ( github.com/rs/zerolog v1.28.0 github.com/zeromicro/go-zero v1.6.3 gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c - gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240401022404-2f1425735f0d + gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240402074843-46c7d05954e6 gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d @@ -164,8 +162,8 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240325203815-454cdb8f5daa // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/go.sum b/go.sum index 4c2e07cc..60c36c6f 100644 --- a/go.sum +++ b/go.sum @@ -464,6 +464,7 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -728,6 +729,7 @@ github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/z github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= @@ -1079,10 +1081,10 @@ github.com/zeromicro/go-zero v1.6.3 h1:OL0NnHD5LdRNDolfcK9vUkJt7K8TcBE3RkzfM8poO github.com/zeromicro/go-zero v1.6.3/go.mod h1:XZL435ZxVi9MSXXtw2MRQhHgx6OoX3++MRMOE9xU70c= gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c h1:2Wl/hvaSFjh6fmCSIQhjkr9llMRREQeqcXNLZ/HPY18= gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c/go.mod h1:lSRfGs+PxFvw7CcndHWRd6UlLlGrZn0b0hp5cfaMNGw= -gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240328020739-cbdd8f5b226b h1:suRANMHQPhKKmgdJOZcbFYDJ0NUQkUGgVvMKxw75BQI= -gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240328020739-cbdd8f5b226b/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240401022404-2f1425735f0d h1:ZX/Kg8eKdaAfDsTd+Y+TrJsUvxp/DpbWUp+Ij4CtR+s= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240401022404-2f1425735f0d/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= +gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240402074843-46c7d05954e6 h1:d40gT5SaARH82SWJMMOao9iJ4QxrnjswjHFmU3tCPac= +gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240402074843-46c7d05954e6/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnzkJBfMRnya1NrhOzlroUtRa5ePiYbPKlHLoLV0= gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5/go.mod h1:97AlUXN13g9UN3+9/DzCHpeoU5sbdyv0IQuTEHNexzQ= gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a h1:fY1KmyZ6O7wVBvgt2HB+C9e1DncJdk/Wkv8m5Qz7abw= @@ -1094,18 +1096,12 @@ gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4c gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4 h1:NrxKAZ5uAzshB9EHcPw+XTOTzpxb5HslNRMYBrFC1Qo= gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4/go.mod h1:uyvpVqG1jHDXX+ubXI0RBwnWXzVykD/mliqGQIDvRoo= go.etcd.io/etcd/api/v3 v3.5.7/go.mod h1:9qew1gCdDDLu+VwmeG+iFpL+QlpHTo7iubavdVDgCAA= -go.etcd.io/etcd/api/v3 v3.5.12 h1:W4sw5ZoU2Juc9gBWuLk5U6fHfNVyY1WC5g9uiXZio/c= -go.etcd.io/etcd/api/v3 v3.5.12/go.mod h1:Ot+o0SWSyT6uHhA56al1oCED0JImsRiU9Dc26+C2a+4= go.etcd.io/etcd/api/v3 v3.5.13 h1:8WXU2/NBge6AUF1K1gOexB6e07NgsN1hXK0rSTtgSp4= go.etcd.io/etcd/api/v3 v3.5.13/go.mod h1:gBqlqkcMMZMVTMm4NDZloEVJzxQOQIls8splbqBDa0c= go.etcd.io/etcd/client/pkg/v3 v3.5.7/go.mod h1:o0Abi1MK86iad3YrWhgUsbGx1pmTS+hrORWc2CamuhY= -go.etcd.io/etcd/client/pkg/v3 v3.5.12 h1:EYDL6pWwyOsylrQyLp2w+HkQ46ATiOvoEdMarindU2A= -go.etcd.io/etcd/client/pkg/v3 v3.5.12/go.mod h1:seTzl2d9APP8R5Y2hFL3NVlD6qC/dOT+3kvrqPyTas4= go.etcd.io/etcd/client/pkg/v3 v3.5.13 h1:RVZSAnWWWiI5IrYAXjQorajncORbS0zI48LQlE2kQWg= go.etcd.io/etcd/client/pkg/v3 v3.5.13/go.mod h1:XxHT4u1qU12E2+po+UVPrEeL94Um6zL58ppuJWXSAB8= go.etcd.io/etcd/client/v3 v3.5.7/go.mod h1:sOWmj9DZUMyAngS7QQwCyAXXAL6WhgTOPLNS/NabQgw= -go.etcd.io/etcd/client/v3 v3.5.12 h1:v5lCPXn1pf1Uu3M4laUE2hp/geOTc5uPcYYsNe1lDxg= -go.etcd.io/etcd/client/v3 v3.5.12/go.mod h1:tSbBCakoWmmddL+BKVAJHa9km+O/E+bumDe9mSbPiqw= go.etcd.io/etcd/client/v3 v3.5.13 h1:o0fHTNJLeO0MyVbc7I3fsCf6nrOqn5d+diSarKnB2js= go.etcd.io/etcd/client/v3 v3.5.13/go.mod h1:cqiAeY8b5DEEcpxvgWKsbLIWNM/8Wy2xJSDMtioMcoI= go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= @@ -1755,8 +1751,12 @@ google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ google.golang.org/genproto v0.0.0-20230123190316-2c411cf9d197/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa h1:Jt1XW5PaLXF1/ePZrznsh/aAUvI7Adfc3LY1dAKlzRs= google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa/go.mod h1:K4kfzHtI0kqWA79gecJarFtDn/Mls+GxQcg3Zox91Ac= +google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda h1:b6F6WIV4xHHD0FA4oIyzU6mHWg2WI2X1RBehwa5QN38= +google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda/go.mod h1:AHcE/gZH76Bk/ROZhQphlRoWo5xKDEtz3eVEO1LfA8c= google.golang.org/genproto/googleapis/rpc v0.0.0-20240325203815-454cdb8f5daa h1:RBgMaUMP+6soRkik4VoN8ojR2nex2TqZwjSSogic+eo= google.golang.org/genproto/googleapis/rpc v0.0.0-20240325203815-454cdb8f5daa/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= From 2599f8a564afc085272faed85e661e1502f32fee Mon Sep 17 00:00:00 2001 From: qiwang <1364512070@qq.com> Date: Tue, 2 Apr 2024 16:28:47 +0800 Subject: [PATCH 02/17] feat:add create mulserver interface Former-commit-id: b917936a2027f599e1f71088de8c808a607c272d --- api/etc/pcm.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/etc/pcm.yaml b/api/etc/pcm.yaml index 1be194eb..79bde9f1 100644 --- a/api/etc/pcm.yaml +++ b/api/etc/pcm.yaml @@ -5,8 +5,8 @@ Port: 8999 Timeout: 50000 DB: - # DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true&loc=Local - DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true&loc=Local + DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true&loc=Local + # DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true&loc=Local Redis: Host: 10.206.0.12:6379 Pass: redisPW123 From db55f5e5a3f585c7f466416d6f533bb01db9a593 Mon Sep 17 00:00:00 2001 From: tzwang Date: Tue, 2 Apr 2024 16:53:27 +0800 Subject: [PATCH 03/17] fix getresources and dynamicResources strategy bugs Former-commit-id: fb05379230be7708ed91f5c21254af271a2b9237 --- .../logic/schedule/schedulesubmitlogic.go | 10 +++--- api/internal/scheduler/database/aiStorage.go | 5 ++- .../scheduler/schedulers/aiScheduler.go | 31 ++++++++++++++++--- .../scheduler/strategy/dynamicResources.go | 2 +- api/internal/storeLink/shuguangai.go | 30 +++++++++--------- 5 files changed, 49 insertions(+), 29 deletions(-) diff --git a/api/internal/logic/schedule/schedulesubmitlogic.go b/api/internal/logic/schedule/schedulesubmitlogic.go index a4704def..d5105390 100644 --- a/api/internal/logic/schedule/schedulesubmitlogic.go +++ b/api/internal/logic/schedule/schedulesubmitlogic.go @@ -28,11 +28,11 @@ func NewScheduleSubmitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sc func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *types.ScheduleResp, err error) { resp = &types.ScheduleResp{} opt := &option.AiOption{ - ResourceType: req.AiOption.ResourceType, - Tops: 0, - TaskType: req.AiOption.TaskType, - DatasetsName: req.AiOption.Datasets, - AlgorithmName: "cnn", + ResourceType: req.AiOption.ResourceType, + Tops: 0, + TaskType: req.AiOption.TaskType, + DatasetsName: req.AiOption.Datasets, + //AlgorithmName: "cnn", StrategyName: req.AiOption.Strategy, ClusterToStaticWeight: nil, Params: []string{ diff --git a/api/internal/scheduler/database/aiStorage.go b/api/internal/scheduler/database/aiStorage.go index edcc5969..670aec91 100644 --- a/api/internal/scheduler/database/aiStorage.go +++ b/api/internal/scheduler/database/aiStorage.go @@ -2,7 +2,6 @@ package database import ( "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" @@ -24,12 +23,12 @@ func (s *AiStorage) GetParticipants() (*types.ClusterListResp, error) { return &resp, nil } -func (s *AiStorage) SaveTask(cluster strategy.AssignedCluster) error { +func (s *AiStorage) SaveTask(name string) error { // 构建主任务结构体 taskModel := models.Task{ Status: constants.Saved, Description: "ai task", - Name: "testAi", + Name: name, CommitTime: time.Now(), } // 保存任务数据到数据库 diff --git a/api/internal/scheduler/schedulers/aiScheduler.go b/api/internal/scheduler/schedulers/aiScheduler.go index 4b62f427..8ff45161 100644 --- a/api/internal/scheduler/schedulers/aiScheduler.go +++ b/api/internal/scheduler/schedulers/aiScheduler.go @@ -100,6 +100,8 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter return nil, errors.New("clusters is nil") } + //res := struct { + //}{} var wg sync.WaitGroup var result []interface{} var errs []error @@ -115,6 +117,7 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter wg.Add(1) go func() { resp, err := executorMap[c.Name].Execute(as.ctx, as.option) + if err != nil { // TODO: database operation errCh <- err @@ -122,15 +125,20 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter return } // TODO: database operation - ch <- resp + data := struct { + Resp interface{} + ClusterId int64 + }{ + Resp: resp, + ClusterId: c.ParticipantId, + } + ch <- data wg.Done() }() } wg.Wait() - - for s := range ch { - result = append(result, s) - } + close(ch) + close(errCh) for e := range errCh { errs = append(errs, e) @@ -140,6 +148,19 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter return nil, errors.New("submit task failed") } + for s := range ch { + data := (s).(struct { + Resp interface{} + ClusterId int64 + }) + + result = append(result, data.Resp) + } + + err := as.AiStorages.SaveTask(as.option.TaskName) + if err != nil { + return nil, err + } return result, nil } diff --git a/api/internal/scheduler/strategy/dynamicResources.go b/api/internal/scheduler/strategy/dynamicResources.go index c8d4052f..bfb78263 100644 --- a/api/internal/scheduler/strategy/dynamicResources.go +++ b/api/internal/scheduler/strategy/dynamicResources.go @@ -49,7 +49,7 @@ func (ps *DynamicResourcesStrategy) Schedule() ([]*AssignedCluster, error) { if opt.ResourceType == "computeCard" { var maxCurrentCardHours float64 for _, card := range res.CardsAvail { - cardHours := common.RoundFloat(card.TOpsAtFp16*card.CardHours, 3) + cardHours := common.RoundFloat( /*card.TOpsAtFp16**/ card.CardHours, 3) if cardHours > maxCurrentCardHours { maxCurrentCardHours = cardHours } diff --git a/api/internal/storeLink/shuguangai.go b/api/internal/storeLink/shuguangai.go index e7da3222..a108d8b7 100644 --- a/api/internal/storeLink/shuguangai.go +++ b/api/internal/storeLink/shuguangai.go @@ -284,14 +284,14 @@ func (s *ShuguangAi) GetResourceStats(ctx context.Context) (*collector.ResourceS totalDcu := limitResp.Data.AccountMaxDcu //disk - diskReq := &hpcAC.ParaStorQuotaReq{} - diskResp, err := s.aCRpc.ParaStorQuota(ctx, diskReq) - if err != nil { - return nil, err - } - - totalDisk := common.RoundFloat(diskResp.Data[0].Threshold*KB*KB*KB, 3) - availDisk := common.RoundFloat((diskResp.Data[0].Threshold-diskResp.Data[0].Usage)*KB*KB*KB, 3) + //diskReq := &hpcAC.ParaStorQuotaReq{} + //diskResp, err := s.aCRpc.ParaStorQuota(ctx, diskReq) + //if err != nil { + // return nil, err + //} + // + //totalDisk := common.RoundFloat(diskResp.Data[0].Threshold*KB*KB*KB, 3) + //availDisk := common.RoundFloat((diskResp.Data[0].Threshold-diskResp.Data[0].Usage)*KB*KB*KB, 3) //memory nodeResp, err := s.aCRpc.GetNodeResources(ctx, nil) @@ -349,12 +349,12 @@ func (s *ShuguangAi) GetResourceStats(ctx context.Context) (*collector.ResourceS Balance: balance, CpuCoreTotal: totalCpu, CpuCoreAvail: CpuCoreAvail, - DiskTotal: totalDisk, - DiskAvail: availDisk, - MemTotal: memSize, - MemAvail: MemAvail, - CpuCoreHours: cpuHours, - CardsAvail: cards, + //DiskTotal: totalDisk, + //DiskAvail: availDisk, + MemTotal: memSize, + MemAvail: MemAvail, + CpuCoreHours: cpuHours, + CardsAvail: cards, } return resourceStats, nil @@ -381,7 +381,7 @@ func (s *ShuguangAi) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm, var algorithms []*collector.Algorithm for _, t := range GetTaskTypes() { taskType := t - req := &hpcAC.GetFileListReq{Limit: 100, Path: ALGORITHM_DIR + FORWARD_SLASH + taskType, Start: 0} + req := &hpcAC.GetFileListReq{Limit: 100, Path: ALGORITHM_DIR + FORWARD_SLASH + taskType, Start: 0, Order: "asc", OrderBy: "name", KeyWord: ""} list, err := s.aCRpc.GetFileList(ctx, req) if err != nil { return nil, err From dbe2363339b60661a000b0cfb1dcaf561c3ca5fd Mon Sep 17 00:00:00 2001 From: tzwang Date: Tue, 2 Apr 2024 18:35:42 +0800 Subject: [PATCH 04/17] updated type convert function Former-commit-id: c1a500ed22fc2922eb4d37d3651cca180c73f948 --- .../logic/schedule/schedulesubmitlogic.go | 43 ++++++++++++++----- .../scheduler/schedulers/aiScheduler.go | 13 ++---- api/internal/storeLink/storeLink.go | 17 ++++++++ 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/api/internal/logic/schedule/schedulesubmitlogic.go b/api/internal/logic/schedule/schedulesubmitlogic.go index d5105390..8dbccdae 100644 --- a/api/internal/logic/schedule/schedulesubmitlogic.go +++ b/api/internal/logic/schedule/schedulesubmitlogic.go @@ -4,6 +4,7 @@ import ( "context" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" @@ -28,26 +29,48 @@ func NewScheduleSubmitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sc func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *types.ScheduleResp, err error) { resp = &types.ScheduleResp{} opt := &option.AiOption{ - ResourceType: req.AiOption.ResourceType, - Tops: 0, - TaskType: req.AiOption.TaskType, - DatasetsName: req.AiOption.Datasets, - //AlgorithmName: "cnn", + ResourceType: req.AiOption.ResourceType, + Tops: req.AiOption.Tops, + TaskType: req.AiOption.TaskType, + DatasetsName: req.AiOption.Datasets, + AlgorithmName: req.AiOption.Algorithm, StrategyName: req.AiOption.Strategy, - ClusterToStaticWeight: nil, - Params: []string{ - "epoch,1", - }, + ClusterToStaticWeight: req.AiOption.StaticWeightMap, + Params: req.AiOption.Params, + Envs: req.AiOption.Envs, + Cmd: req.AiOption.Cmd, } aiSchdl, err := schedulers.NewAiScheduler(l.ctx, "", l.svcCtx.Scheduler, opt) if err != nil { return nil, err } - _, err = l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl) + results, err := l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl) if err != nil { return nil, err } + //转换成统一返回类型 + for _, r := range results { + sResp, err := storeLink.ConvertType(r, resp, nil) + if err != nil { + return nil, err + } + + if sResp.(*types.ScheduleResp).ErrorMsg != "" { + resp.ErrorMsg = sResp.(*types.ScheduleResp).ErrorMsg + "\n" + } + } + + if resp.ErrorMsg == "" { + resp.Success = true + err = l.svcCtx.Scheduler.AiStorages.SaveTask(req.AiOption.TaskName) + if err != nil { + return nil, err + } + } else { + resp.Success = false + } + return resp, nil } diff --git a/api/internal/scheduler/schedulers/aiScheduler.go b/api/internal/scheduler/schedulers/aiScheduler.go index 8ff45161..a9e73f17 100644 --- a/api/internal/scheduler/schedulers/aiScheduler.go +++ b/api/internal/scheduler/schedulers/aiScheduler.go @@ -100,8 +100,6 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter return nil, errors.New("clusters is nil") } - //res := struct { - //}{} var wg sync.WaitGroup var result []interface{} var errs []error @@ -116,15 +114,16 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter } wg.Add(1) go func() { + //var resp interface{} + //var err error resp, err := executorMap[c.Name].Execute(as.ctx, as.option) if err != nil { - // TODO: database operation errCh <- err wg.Done() return } - // TODO: database operation + data := struct { Resp interface{} ClusterId int64 @@ -153,14 +152,10 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter Resp interface{} ClusterId int64 }) - + // TODO: database operation result = append(result, data.Resp) } - err := as.AiStorages.SaveTask(as.option.TaskName) - if err != nil { - return nil, err - } return result, nil } diff --git a/api/internal/storeLink/storeLink.go b/api/internal/storeLink/storeLink.go index ce00a540..b3c0ba2d 100644 --- a/api/internal/storeLink/storeLink.go +++ b/api/internal/storeLink/storeLink.go @@ -370,6 +370,14 @@ func ConvertType(in interface{}, out interface{}, participant *models.StorelinkC resp.TaskId = inresp.Payload.JobId + return resp, nil + case *types.ScheduleResp: + resp := (interface{})(out).(*types.ScheduleResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + return resp, nil + } return resp, nil } return nil, nil @@ -404,6 +412,15 @@ func ConvertType(in interface{}, out interface{}, participant *models.StorelinkC resp.ErrorMsg = inresp.Msg } return resp, nil + case *types.ScheduleResp: + resp := (interface{})(out).(*types.ScheduleResp) + if inresp.Code == "0" { + resp.Success = true + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + } + return resp, nil } return nil, nil From 6ad1cbfcfbc32ee4db73a4e639c49bbcd0072076 Mon Sep 17 00:00:00 2001 From: qiwang <1364512070@qq.com> Date: Wed, 3 Apr 2024 14:48:44 +0800 Subject: [PATCH 05/17] feat:Add the survival_time field Former-commit-id: fbb71d90bcbd61e6fd109f49bcd077c9bb9fc3c2 --- api/desc/vm/pcm-vm.api | 1 + api/etc/pcm.yaml | 4 ++-- api/internal/logic/vm/listserversdetailedlogic.go | 13 +++---------- api/internal/types/types.go | 1 + go.mod | 2 +- go.sum | 2 ++ 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/api/desc/vm/pcm-vm.api b/api/desc/vm/pcm-vm.api index fb21c68c..28062302 100644 --- a/api/desc/vm/pcm-vm.api +++ b/api/desc/vm/pcm-vm.api @@ -134,6 +134,7 @@ type ( Updated string `json:"updated" copier:"Updated"` Flavor string `json:"flavor" copier:"Flavor"` Key_name string `json:"key_name" copier:"Key_name"` + Survival_time int32 `json:"survival_time" copier:"Survival_time"` } ) diff --git a/api/etc/pcm.yaml b/api/etc/pcm.yaml index 79bde9f1..2cb4aef9 100644 --- a/api/etc/pcm.yaml +++ b/api/etc/pcm.yaml @@ -5,8 +5,8 @@ Port: 8999 Timeout: 50000 DB: - DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true&loc=Local - # DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true&loc=Local + #DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true&loc=Local + DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true&loc=Local Redis: Host: 10.206.0.12:6379 Pass: redisPW123 diff --git a/api/internal/logic/vm/listserversdetailedlogic.go b/api/internal/logic/vm/listserversdetailedlogic.go index 63fdbe80..79b217e5 100644 --- a/api/internal/logic/vm/listserversdetailedlogic.go +++ b/api/internal/logic/vm/listserversdetailedlogic.go @@ -18,15 +18,12 @@ import ( "context" "github.com/jinzhu/copier" "github.com/pkg/errors" + "github.com/zeromicro/go-zero/core/logx" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" ) type ListServersDetailedLogic struct { @@ -44,18 +41,14 @@ func NewListServersDetailedLogic(ctx context.Context, svcCtx *svc.ServiceContext } func (l *ListServersDetailedLogic) ListServersDetailed(req *types.ListServersDetailedReq) (resp *types.ListServersDetailedResp, err error) { - // todo: add your logic here and delete this line + resp = &types.ListServersDetailedResp{} ListServersDetailedReq := &openstack.ListServersDetailedReq{} err = copier.CopyWithOption(ListServersDetailedReq, req, copier.Option{Converters: utils.Converters}) ListServersDetailedResp, err := l.svcCtx.OpenstackRpc.ListServersDetailed(l.ctx, ListServersDetailedReq) if err != nil { return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) } - marshal, err := json.Marshal(&ListServersDetailedResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) + utils.Convert(&ListServersDetailedResp.Servers, &resp.ServersDetailed) err = copier.CopyWithOption(&resp, &ListServersDetailedResp, copier.Option{Converters: utils.Converters}) return resp, err diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 2fa9ef29..819b0367 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -2748,6 +2748,7 @@ type ServersDetailed struct { Updated string `json:"updated" copier:"Updated"` Flavor string `json:"flavor" copier:"Flavor"` Key_name string `json:"key_name" copier:"Key_name"` + Survival_time int32 `json:"survival_time" copier:"Survival_time"` } type GetServersDetailedByIdReq struct { diff --git a/go.mod b/go.mod index 03bfbc16..53068e7a 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/rs/zerolog v1.28.0 github.com/zeromicro/go-zero v1.6.3 gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c - gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240402074843-46c7d05954e6 + gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d diff --git a/go.sum b/go.sum index 60c36c6f..e4a29585 100644 --- a/go.sum +++ b/go.sum @@ -1085,6 +1085,8 @@ gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240401022404-2f1425735f0d h1:ZX gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240401022404-2f1425735f0d/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240402074843-46c7d05954e6 h1:d40gT5SaARH82SWJMMOao9iJ4QxrnjswjHFmU3tCPac= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240402074843-46c7d05954e6/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= +gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6PsZ1+bev294IWdZRlV7mnOwI1+UzFcldVW/BqhQzI= +gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnzkJBfMRnya1NrhOzlroUtRa5ePiYbPKlHLoLV0= gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5/go.mod h1:97AlUXN13g9UN3+9/DzCHpeoU5sbdyv0IQuTEHNexzQ= gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a h1:fY1KmyZ6O7wVBvgt2HB+C9e1DncJdk/Wkv8m5Qz7abw= From c57cbc89ed046cba1ba615c3aec45e0adbe8fe5e Mon Sep 17 00:00:00 2001 From: qiwang <1364512070@qq.com> Date: Wed, 3 Apr 2024 14:52:32 +0800 Subject: [PATCH 06/17] feat:Add the survival_time field Former-commit-id: 60101077836282000110003c176979638ad5a6ad --- api/etc/pcm.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/etc/pcm.yaml b/api/etc/pcm.yaml index 2cb4aef9..79bde9f1 100644 --- a/api/etc/pcm.yaml +++ b/api/etc/pcm.yaml @@ -5,8 +5,8 @@ Port: 8999 Timeout: 50000 DB: - #DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true&loc=Local - DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true&loc=Local + DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true&loc=Local + # DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true&loc=Local Redis: Host: 10.206.0.12:6379 Pass: redisPW123 From cdd7fe9dca810ce3653fbbe862ba115be6187ac2 Mon Sep 17 00:00:00 2001 From: tzwang Date: Sun, 7 Apr 2024 16:50:30 +0800 Subject: [PATCH 07/17] updated schedule submit task api logic Former-commit-id: 72fe516fb25e2feb760391799265642341d16277 --- api/desc/schedule/pcm-schedule.api | 10 ++- .../logic/schedule/schedulesubmitlogic.go | 15 +--- .../scheduler/schedulers/aiScheduler.go | 81 ++++++++++++++----- .../schedulers/option/cloudOption.go | 9 +++ .../scheduler/strategy/dynamicResources.go | 2 + 5 files changed, 85 insertions(+), 32 deletions(-) create mode 100644 api/internal/scheduler/schedulers/option/cloudOption.go diff --git a/api/desc/schedule/pcm-schedule.api b/api/desc/schedule/pcm-schedule.api index 72ba71a7..eafba3de 100644 --- a/api/desc/schedule/pcm-schedule.api +++ b/api/desc/schedule/pcm-schedule.api @@ -13,8 +13,14 @@ type ( } ScheduleResp { - Success bool `json:"success"` - ErrorMsg string `json:"errorMsg"` + Results []*ScheduleResult `json:"results"` + } + + ScheduleResult { + ClusterId string `json:"clusterId"` + TaskId string `json:"taskId"` + Replica int32 `json:"replica"` + Msg string `json:"msg"` } AiOption { diff --git a/api/internal/logic/schedule/schedulesubmitlogic.go b/api/internal/logic/schedule/schedulesubmitlogic.go index 8dbccdae..074d31c0 100644 --- a/api/internal/logic/schedule/schedulesubmitlogic.go +++ b/api/internal/logic/schedule/schedulesubmitlogic.go @@ -4,8 +4,6 @@ import ( "context" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" @@ -50,15 +48,10 @@ func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *type return nil, err } - //转换成统一返回类型 - for _, r := range results { - sResp, err := storeLink.ConvertType(r, resp, nil) - if err != nil { - return nil, err - } - - if sResp.(*types.ScheduleResp).ErrorMsg != "" { - resp.ErrorMsg = sResp.(*types.ScheduleResp).ErrorMsg + "\n" + switch opt.GetOptionType() { + case option.AI: + for _, result := range results { + _ = (result).(*schedulers.AiResult) } } diff --git a/api/internal/scheduler/schedulers/aiScheduler.go b/api/internal/scheduler/schedulers/aiScheduler.go index a9e73f17..0533f22c 100644 --- a/api/internal/scheduler/schedulers/aiScheduler.go +++ b/api/internal/scheduler/schedulers/aiScheduler.go @@ -16,6 +16,7 @@ package schedulers import ( "context" + "encoding/json" "errors" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" @@ -25,6 +26,9 @@ import ( "gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/jcce-pcm/pcm-ac/hpcAC" + "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus" + "strconv" "sync" ) @@ -36,6 +40,13 @@ type AiScheduler struct { ctx context.Context } +type AiResult struct { + taskId string + clusterId string + replica int32 + msg string +} + func NewAiScheduler(ctx context.Context, val string, scheduler *scheduler.Scheduler, option *option.AiOption) (*AiScheduler, error) { return &AiScheduler{ctx: ctx, yamlString: val, Scheduler: scheduler, option: option}, nil } @@ -101,9 +112,9 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter } var wg sync.WaitGroup - var result []interface{} + var results []interface{} var errs []error - var ch = make(chan interface{}, len(clusters)) + var ch = make(chan *AiResult, len(clusters)) var errCh = make(chan error, len(clusters)) executorMap := *as.AiExecutor @@ -114,9 +125,8 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter } wg.Add(1) go func() { - //var resp interface{} - //var err error - resp, err := executorMap[c.Name].Execute(as.ctx, as.option) + opt, _ := cloneAiOption(as.option) + resp, err := executorMap[c.Name].Execute(as.ctx, opt) if err != nil { errCh <- err @@ -124,14 +134,11 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter return } - data := struct { - Resp interface{} - ClusterId int64 - }{ - Resp: resp, - ClusterId: c.ParticipantId, - } - ch <- data + result, _ := convertType(resp) + result.replica = c.Replicas + result.clusterId = strconv.FormatInt(c.ParticipantId, 10) + + ch <- result wg.Done() }() } @@ -148,15 +155,11 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter } for s := range ch { - data := (s).(struct { - Resp interface{} - ClusterId int64 - }) // TODO: database operation - result = append(result, data.Resp) + results = append(results, s) } - return result, nil + return results, nil } func (as *AiScheduler) findClustersWithResources() ([]*collector.ResourceStats, error) { @@ -202,3 +205,43 @@ func (as *AiScheduler) findClustersWithResources() ([]*collector.ResourceStats, } return resourceSpecs, nil } + +func convertType(in interface{}) (*AiResult, error) { + var result AiResult + switch (in).(type) { + case *hpcAC.SubmitTaskAiResp: + resp := (in).(*hpcAC.SubmitTaskAiResp) + if resp.Code == "0" { + result.taskId = resp.Data + } else { + result.msg = resp.Msg + } + return &result, nil + case *octopus.CreateTrainJobResp: + resp := (in).(*octopus.CreateTrainJobResp) + + if resp.Success { + result.taskId = resp.Payload.JobId + } else { + result.msg = resp.Error.Message + } + + return &result, nil + default: + return nil, errors.New("ai task response failed") + } +} + +func cloneAiOption(opt *option.AiOption) (*option.AiOption, error) { + origJSON, err := json.Marshal(opt) + if err != nil { + return nil, err + } + + clone := option.AiOption{} + if err = json.Unmarshal(origJSON, &clone); err != nil { + return nil, err + } + + return &clone, nil +} diff --git a/api/internal/scheduler/schedulers/option/cloudOption.go b/api/internal/scheduler/schedulers/option/cloudOption.go new file mode 100644 index 00000000..fe6274ed --- /dev/null +++ b/api/internal/scheduler/schedulers/option/cloudOption.go @@ -0,0 +1,9 @@ +package option + +type CloudOption struct { + task interface{} +} + +func (c CloudOption) GetOptionType() string { + return CLOUD +} diff --git a/api/internal/scheduler/strategy/dynamicResources.go b/api/internal/scheduler/strategy/dynamicResources.go index bfb78263..cb1d4922 100644 --- a/api/internal/scheduler/strategy/dynamicResources.go +++ b/api/internal/scheduler/strategy/dynamicResources.go @@ -64,6 +64,8 @@ func (ps *DynamicResourcesStrategy) Schedule() ([]*AssignedCluster, error) { } results = append(results, &assignedCluster) return results, nil + case option.CLOUD: + } return nil, errors.New("failed to apply DynamicResourcesStrategy") From 74789e940daaa852fa120202b9164fd6d198d4bd Mon Sep 17 00:00:00 2001 From: Jake <450705171@qq.com> Date: Sun, 7 Apr 2024 16:57:54 +0800 Subject: [PATCH 08/17] goctl generate types Former-commit-id: 36cf4966933f78d170ae6a43f4af3f4d100c803f --- api/internal/types/types.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api/internal/types/types.go b/api/internal/types/types.go index d055cc65..65aa7de6 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -5266,8 +5266,14 @@ type ScheduleReq struct { } type ScheduleResp struct { - Success bool `json:"success"` - ErrorMsg string `json:"errorMsg"` + Results []*ScheduleResult `json:"results"` +} + +type ScheduleResult struct { + ClusterId string `json:"clusterId"` + TaskId string `json:"taskId"` + Replica int32 `json:"replica"` + Msg string `json:"msg"` } type AiOption struct { From a8660d5d5b336fc0fa5393dd96ac30c466dac87f Mon Sep 17 00:00:00 2001 From: zhangwei <894646498@qq.com> Date: Sun, 7 Apr 2024 17:11:35 +0800 Subject: [PATCH 09/17] alert Former-commit-id: 545aa908151fb83153dbe89334f2a6cf1d3baf53 --- api/desc/core/pcm-core.api | 1 - api/desc/monitoring/pcm-monitoring.api | 32 ++++++-- api/desc/pcm.api | 6 +- .../handler/cloud/clusterinfohandler.go | 7 +- .../handler/monitoring/alertruleshandler.go | 10 +-- .../monitoring/createalertrulehandler.go | 7 +- .../handler/monitoring/nodesloadtophandler.go | 28 +++++++ api/internal/handler/routes.go | 7 +- .../logic/monitoring/alertruleslogic.go | 18 ++--- .../logic/monitoring/clustersloadlogic.go | 3 +- .../logic/monitoring/createalertrulelogic.go | 77 ++++++++++++++++--- .../logic/monitoring/nodesloadtoplogic.go | 44 +++++++++++ api/internal/types/types.go | 36 ++++++--- pkg/models/alertrulemodel.go | 18 +++++ pkg/tracker/promql.go | 41 +++++----- 15 files changed, 257 insertions(+), 78 deletions(-) create mode 100644 api/internal/handler/monitoring/nodesloadtophandler.go create mode 100644 api/internal/logic/monitoring/nodesloadtoplogic.go create mode 100644 pkg/models/alertrulemodel.go diff --git a/api/desc/core/pcm-core.api b/api/desc/core/pcm-core.api index 4c25b15c..9ac87a46 100644 --- a/api/desc/core/pcm-core.api +++ b/api/desc/core/pcm-core.api @@ -40,7 +40,6 @@ type remoteResp { type ( clustersLoadReq { - adapterId int64 `form:"adapterId"` clusterName string `form:"clusterName"` } clustersLoadResp { diff --git a/api/desc/monitoring/pcm-monitoring.api b/api/desc/monitoring/pcm-monitoring.api index edf95b4a..e09efd66 100644 --- a/api/desc/monitoring/pcm-monitoring.api +++ b/api/desc/monitoring/pcm-monitoring.api @@ -1,12 +1,34 @@ syntax = "v1" type CreateAlertRuleReq { + CLusterId int64 `json:"clusterId"` ClusterName string `json:"clusterName"` - Namespace string `json:"namespace"` Name string `json:"name"` - PromQL string `json:"PromQL"` + PromQL string `json:"promQL"` Duration string `json:"duration"` - Labels map[string]string `json:"labels"` - Annotations map[string]string `json:"annotations"` + Annotations string `json:"annotations,optional"` AlertLevel string `json:"alertLevel"` -} \ No newline at end of file + AlertType string `json:"alertType"` +} + +type ( + alertRulesResp { + Id int64 `json:"id"` + ClusterName string `json:"clusterName"` + Name string `json:"name"` + PromQL string `json:"promQL"` + Duration string `json:"duration"` + Annotations string `json:"annotations"` + AlertLevel string `json:"alertLevel"` + } +) + +type ( + nodesLoadTopReq { + ClusterName string `form:"clusterName"` + Metrics string `form:"metrics"` + } + nodesLoadTopResp { + data interface{} `json:"data"` + } +) \ No newline at end of file diff --git a/api/desc/pcm.api b/api/desc/pcm.api index 24fd3043..7fefaa36 100644 --- a/api/desc/pcm.api +++ b/api/desc/pcm.api @@ -948,9 +948,13 @@ service pcm { @doc "alert rules" @handler alertRulesHandler - get /monitoring/alert/rules + get /monitoring/alert/rule returns (alertRulesResp) @doc "cluster resource load" @handler clustersLoadHandler get /monitoring/cluster/load (clustersLoadReq) returns (clustersLoadResp) + + @doc "node resource load" + @handler nodesLoadTopHandler + get /monitoring/node/top (nodesLoadTopReq) returns (nodesLoadTopResp) } \ No newline at end of file diff --git a/api/internal/handler/cloud/clusterinfohandler.go b/api/internal/handler/cloud/clusterinfohandler.go index 50083770..51522ea4 100644 --- a/api/internal/handler/cloud/clusterinfohandler.go +++ b/api/internal/handler/cloud/clusterinfohandler.go @@ -1,6 +1,7 @@ package cloud import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" "net/http" "github.com/zeromicro/go-zero/rest/httpx" @@ -19,10 +20,6 @@ func ClusterInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { l := cloud.NewClusterInfoLogic(r.Context(), svcCtx) resp, err := l.ClusterInfo(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } + result.HttpResult(r, w, resp, err) } } diff --git a/api/internal/handler/monitoring/alertruleshandler.go b/api/internal/handler/monitoring/alertruleshandler.go index b058e73e..28cea567 100644 --- a/api/internal/handler/monitoring/alertruleshandler.go +++ b/api/internal/handler/monitoring/alertruleshandler.go @@ -1,9 +1,9 @@ package monitoring import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" "net/http" - "github.com/zeromicro/go-zero/rest/httpx" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" ) @@ -11,11 +11,7 @@ import ( func AlertRulesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { l := monitoring.NewAlertRulesLogic(r.Context(), svcCtx) - err := l.AlertRules() - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.Ok(w) - } + resp, err := l.AlertRules() + result.HttpResult(r, w, resp, err) } } diff --git a/api/internal/handler/monitoring/createalertrulehandler.go b/api/internal/handler/monitoring/createalertrulehandler.go index 444f60dd..292ca021 100644 --- a/api/internal/handler/monitoring/createalertrulehandler.go +++ b/api/internal/handler/monitoring/createalertrulehandler.go @@ -1,6 +1,7 @@ package monitoring import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" "net/http" "github.com/zeromicro/go-zero/rest/httpx" @@ -19,10 +20,6 @@ func CreateAlertRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { l := monitoring.NewCreateAlertRuleLogic(r.Context(), svcCtx) err := l.CreateAlertRule(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.Ok(w) - } + result.HttpResult(r, w, nil, err) } } diff --git a/api/internal/handler/monitoring/nodesloadtophandler.go b/api/internal/handler/monitoring/nodesloadtophandler.go new file mode 100644 index 00000000..4c0e5925 --- /dev/null +++ b/api/internal/handler/monitoring/nodesloadtophandler.go @@ -0,0 +1,28 @@ +package monitoring + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" +) + +func NodesLoadTopHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.NodesLoadTopReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := monitoring.NewNodesLoadTopLogic(r.Context(), svcCtx) + resp, err := l.NodesLoadTop(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index 45e701c2..9235c609 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -1189,7 +1189,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { }, { Method: http.MethodGet, - Path: "/monitoring/alert/rules", + Path: "/monitoring/alert/rule", Handler: monitoring.AlertRulesHandler(serverCtx), }, { @@ -1197,6 +1197,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/monitoring/cluster/load", Handler: monitoring.ClustersLoadHandler(serverCtx), }, + { + Method: http.MethodGet, + Path: "/monitoring/node/top", + Handler: monitoring.NodesLoadTopHandler(serverCtx), + }, }, rest.WithPrefix("/pcm/v1"), ) diff --git a/api/internal/logic/monitoring/alertruleslogic.go b/api/internal/logic/monitoring/alertruleslogic.go index 3014853b..93d5500c 100644 --- a/api/internal/logic/monitoring/alertruleslogic.go +++ b/api/internal/logic/monitoring/alertruleslogic.go @@ -2,10 +2,11 @@ package monitoring import ( "context" - "github.com/prometheus/alertmanager/api/v2/client/alert" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" ) type AlertRulesLogic struct { @@ -22,13 +23,8 @@ func NewAlertRulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlertR } } -func (l *AlertRulesLogic) AlertRules() error { - // todo: add your logic here and delete this line - alerts, err := l.svcCtx.AlertClient.Alert.GetAlerts(&alert.GetAlertsParams{}) - if err != nil { - return err - } - println(alerts.Error()) - return nil - return nil +func (l *AlertRulesLogic) AlertRules() (resp *types.AlertRulesResp, err error) { + resp = &types.AlertRulesResp{} + l.svcCtx.DbEngin.Raw("SELECT ar.id,ar.*,GROUP_CONCAT(tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',') as cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id WHERE ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id;").Scan(&resp) + return resp, nil } diff --git a/api/internal/logic/monitoring/clustersloadlogic.go b/api/internal/logic/monitoring/clustersloadlogic.go index 68f07eb1..ed2a4d07 100644 --- a/api/internal/logic/monitoring/clustersloadlogic.go +++ b/api/internal/logic/monitoring/clustersloadlogic.go @@ -28,8 +28,7 @@ func NewClustersLoadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Clus func (l *ClustersLoadLogic) ClustersLoad(req *types.ClustersLoadReq) (resp *types.ClustersLoadResp, err error) { resp = &types.ClustersLoadResp{} metrics := []string{"cluster_cpu_utilisation", "cluster_cpu_avail", "cluster_cpu_total", "cluster_memory_total", "cluster_memory_avail", "cluster_memory_utilisation", "cluster_disk_utilisation", "cluster_disk_avail", "cluster_disk_total"} - result := l.svcCtx.PromClient.GetNamedMetrics(metrics, time.Now(), tracker.ClusterOption{AdapterId: req.AdapterId, ClusterName: req.ClusterName}) + result := l.svcCtx.PromClient.GetNamedMetrics(metrics, time.Now(), tracker.ClusterOption{ClusterName: req.ClusterName}) resp.Data = result return resp, nil - return } diff --git a/api/internal/logic/monitoring/createalertrulelogic.go b/api/internal/logic/monitoring/createalertrulelogic.go index 63dfb95e..828f5635 100644 --- a/api/internal/logic/monitoring/createalertrulelogic.go +++ b/api/internal/logic/monitoring/createalertrulelogic.go @@ -3,12 +3,14 @@ package monitoring import ( "context" v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" - v12 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" - "github.com/zeromicro/go-zero/core/logx" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + v12 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/apimachinery/pkg/util/json" ) type CreateAlertRuleLogic struct { @@ -25,16 +27,49 @@ func NewCreateAlertRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C } } +type RuleSelectorResp struct { + Code int `json:"code"` + Msg string `json:"msg"` + Prometheus v1.Prometheus `json:"data"` +} + func (l *CreateAlertRuleLogic) CreateAlertRule(req *types.CreateAlertRuleReq) error { - // todo: add your logic here and delete this line + + // save to db + var alertRule models.AlertRule + tool.Convert(req, &alertRule) + alertRule.Id = tool.GenSnowflakeID() + tx := l.svcCtx.DbEngin.Save(&alertRule) + if tx.Error != nil { + return tx.Error + } + + // query server http url. + var server string + l.svcCtx.DbEngin.Raw("select ta.server from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and tc.name = ?", &req.ClusterName).Scan(&server) + + // rule selector + var ruleSelectorResp RuleSelectorResp + + response, err := l.svcCtx.HttpClient.R(). + SetQueryParams(map[string]string{ + "clusterName": req.ClusterName, + }). + SetResult(&ruleSelectorResp). + ForceContentType("application/json"). + Get(server + "/api/v1/monitoring/rule/selector") + if err != nil || response.IsError() { + return err + } + // Data Filling ruleDuration := v1.Duration(req.Duration) rule := &v1.PrometheusRule{ + TypeMeta: v12.TypeMeta{Kind: "PrometheusRule", + APIVersion: "monitoring.coreos.com/v1"}, ObjectMeta: v12.ObjectMeta{ Name: req.Name, - Namespace: req.Namespace, - Labels: map[string]string{ - "release": "prometheus", - }, + Namespace: ruleSelectorResp.Prometheus.ObjectMeta.Namespace, + Labels: ruleSelectorResp.Prometheus.Spec.RuleSelector.MatchLabels, }, Spec: v1.PrometheusRuleSpec{ Groups: []v1.RuleGroup{ @@ -48,13 +83,35 @@ func (l *CreateAlertRuleLogic) CreateAlertRule(req *types.CreateAlertRuleReq) er Labels: map[string]string{ "severity": req.AlertLevel, }, - Annotations: req.Annotations, + Annotations: map[string]string{"description": req.Annotations}, }, }, }, }, }, } - println(rule.Kind) + + ruleBytes, err := json.Marshal(rule) + if err != nil { + return err + } + + // create prometheus rule + response, err = l.svcCtx.HttpClient.R(). + SetBody(&OperateStruct{ + ClusterName: req.ClusterName, + YamlString: string(ruleBytes), + }). + ForceContentType("application/json"). + Post(server + "/api/v1/operate/apply") + if err != nil || response.IsError() { + return err + } + return nil } + +type OperateStruct struct { + ClusterName string `json:"clusterName"` + YamlString string `json:"yamlString"` +} diff --git a/api/internal/logic/monitoring/nodesloadtoplogic.go b/api/internal/logic/monitoring/nodesloadtoplogic.go new file mode 100644 index 00000000..7efb6cd4 --- /dev/null +++ b/api/internal/logic/monitoring/nodesloadtoplogic.go @@ -0,0 +1,44 @@ +package monitoring + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type NodesLoadTopLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewNodesLoadTopLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NodesLoadTopLogic { + return &NodesLoadTopLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *NodesLoadTopLogic) NodesLoadTop(req *types.NodesLoadTopReq) (resp *types.NodesLoadTopResp, err error) { + + resp = &types.NodesLoadTopResp{} + + var server string + l.svcCtx.DbEngin.Raw("select ta.server from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and tc.name = ?", &req.ClusterName).Scan(&server) + response, err := l.svcCtx.HttpClient.R(). + SetQueryParams(map[string]string{ + "clusterName": req.ClusterName, + "metrics": req.Metrics, + }). + SetResult(&resp). + ForceContentType("application/json"). + Get(server + "/api/v1/monitoring/node") + if err != nil || response.IsError() { + + } + return resp, nil +} diff --git a/api/internal/types/types.go b/api/internal/types/types.go index f1a3978a..d651558b 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -32,7 +32,6 @@ type RemoteResp struct { } type ClustersLoadReq struct { - AdapterId int64 `form:"adapterId"` ClusterName string `form:"clusterName"` } @@ -5376,12 +5375,31 @@ type PushResourceInfoReq struct { } type CreateAlertRuleReq struct { - ClusterName string `json:"clusterName"` - Namespace string `json:"namespace"` - Name string `json:"name"` - PromQL string `json:"PromQL"` - Duration string `json:"duration"` - Labels map[string]string `json:"labels"` - Annotations map[string]string `json:"annotations"` - AlertLevel string `json:"alertLevel"` + CLusterId int64 `json:"clusterId"` + ClusterName string `json:"clusterName"` + Name string `json:"name"` + PromQL string `json:"promQL"` + Duration string `json:"duration"` + Annotations string `json:"annotations,optional"` + AlertLevel string `json:"alertLevel"` + AlertType string `json:"alertType"` +} + +type AlertRulesResp struct { + Id int64 `json:"id"` + ClusterName string `json:"clusterName"` + Name string `json:"name"` + PromQL string `json:"promQL"` + Duration string `json:"duration"` + Annotations string `json:"annotations"` + AlertLevel string `json:"alertLevel"` +} + +type NodesLoadTopReq struct { + ClusterName string `form:"clusterName"` + Metrics string `form:"metrics"` +} + +type NodesLoadTopResp struct { + Data interface{} `json:"data"` } diff --git a/pkg/models/alertrulemodel.go b/pkg/models/alertrulemodel.go new file mode 100644 index 00000000..b5e47bab --- /dev/null +++ b/pkg/models/alertrulemodel.go @@ -0,0 +1,18 @@ +package models + +import ( + "database/sql" +) + +type AlertRule struct { + Id int64 `db:"id"` // id + ClusterId int64 `db:"cluster_id"` + Name string `db:"name"` // 节点名称 + AlertType string `db:"alert_type"` // 节点类型 int64 `db:"cpu_total"` // cpu核数 + PromQL string `db:"prom_ql"` + Duration string `db:"duration"` + AlertLevel string `db:"alert_level"` + Annotations string `db:"annotations"` + CreatedBy sql.NullInt64 `db:"created_by"` // 创建人 + UpdatedBy sql.NullInt64 `db:"updated_by"` // 更新人 +} diff --git a/pkg/tracker/promql.go b/pkg/tracker/promql.go index 1dc07394..013c079f 100644 --- a/pkg/tracker/promql.go +++ b/pkg/tracker/promql.go @@ -19,32 +19,31 @@ import ( "strings" ) -const ( - StatefulSet = "StatefulSet" - DaemonSet = "DaemonSet" - Deployment = "Deployment" -) - var promQLTemplates = map[string]string{ - "cluster_cpu_utilisation": "cluster_cpu_utilisation{$1}", - "cluster_memory_utilisation": "cluster_memory_utilisation{$1}", - "cluster_disk_utilisation": "cluster_disk_utilisation{$1}", - "cluster_cpu_total": "cluster_cpu_total{$1}", - "cluster_memory_total": "cluster_memory_total{$1}", - "cluster_disk_total": "cluster_disk_total{$1}", - "cluster_cpu_avail": "cluster_cpu_total{$1}", - "cluster_memory_avail": "cluster_memory_total{$1}", - "cluster_disk_avail": "cluster_disk_total{$1}", - "center_cpu_utilisation": "(sum by (adapter_id)(cluster_cpu_total{$1})-sum by (adapter_id)(cluster_cpu_avail{$1}))/sum by (adapter_id)(cluster_cpu_total{$1})", - "center_memory_utilisation": "(sum by (adapter_id)(cluster_memory_total{$1})-sum by (adapter_id)(cluster_memory_avail{$1}))/sum by (adapter_id)(cluster_memory_total{$1})", - "center_disk_utilisation": "(sum by (adapter_id)(cluster_disk_total{$1})-sum by (adapter_id)(cluster_disk_avail{$1}))/sum by (adapter_id)(cluster_disk_total{$1})", - "center_top3": "topk(3,((sum by (adapter_id)(cluster_cpu_total)-sum by (adapter_id)(cluster_cpu_avail))/sum by (adapter_id)(cluster_cpu_total) + (sum by (adapter_id)(cluster_memory_total) - sum by (adapter_id)(cluster_memory_avail))/sum by (adapter_id)(cluster_memory_total) + (sum by (adapter_id)(cluster_disk_total)-sum by (adapter_id)(cluster_disk_avail))/sum by (adapter_id)(cluster_disk_total))/3)", + "cluster_cpu_utilisation": "cluster_cpu_utilisation{$1}", + "cluster_memory_utilisation": "cluster_memory_utilisation{$1}", + "cluster_disk_utilisation": "cluster_disk_utilisation{$1}", + "cluster_cpu_total": "cluster_cpu_total{$1}", + "cluster_memory_total": "cluster_memory_total{$1}", + "cluster_disk_total": "cluster_disk_total{$1}", + "cluster_cpu_avail": "cluster_cpu_total{$1}", + "cluster_memory_avail": "cluster_memory_total{$1}", + "cluster_disk_avail": "cluster_disk_total{$1}", + + // center + "center_cpu_utilisation": "(sum by (adapter_id)(cluster_cpu_total{$1})-sum by (adapter_id)(cluster_cpu_avail{$1}))/sum by (adapter_id)(cluster_cpu_total{$1})", + "center_memory_utilisation": "(sum by (adapter_id)(cluster_memory_total{$1})-sum by (adapter_id)(cluster_memory_avail{$1}))/sum by (adapter_id)(cluster_memory_total{$1})", + "center_disk_utilisation": "(sum by (adapter_id)(cluster_disk_total{$1})-sum by (adapter_id)(cluster_disk_avail{$1}))/sum by (adapter_id)(cluster_disk_total{$1})", + "center_top3": "topk(3,((sum by (adapter_id)(cluster_cpu_total)-sum by (adapter_id)(cluster_cpu_avail))/sum by (adapter_id)(cluster_cpu_total) + (sum by (adapter_id)(cluster_memory_total) - sum by (adapter_id)(cluster_memory_avail))/sum by (adapter_id)(cluster_memory_total) + (sum by (adapter_id)(cluster_disk_total)-sum by (adapter_id)(cluster_disk_avail))/sum by (adapter_id)(cluster_disk_total))/3)", + + // namespace "namespace_cpu_usage": `round(namespace:container_cpu_usage_seconds_total:sum_rate{namespace!="", $1}, 0.001)`, "namespace_memory_usage": `namespace:container_memory_usage_bytes:sum{namespace!="", $1}`, "namespace_memory_usage_wo_cache": `namespace:container_memory_usage_bytes_wo_cache:sum{namespace!="", $1}`, - "controller_cpu_usage_rate": `sum( node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{}* on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{$1}) by (workload)/sum( kube_pod_container_resource_limits{job="kube-state-metrics", resource="cpu"}* on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{ }) by (workload)`, - "controller_memory_usage_rate": `sum( container_memory_working_set_bytes{job="kubelet", metrics_path="/metrics/cadvisor", container!="", image!=""} * on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{$1}) by (workload)/sum( kube_pod_container_resource_limits{job="kube-state-metrics", resource="memory"}* on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{ }) by (workload)`, + // controller + "controller_cpu_usage_rate": `sum( node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{}* on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{$1}) by (workload)/sum( kube_pod_container_resource_limits{job="kube-state-metrics", resource="cpu"}* on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{ }) by (workload)`, + "controller_memory_usage_rate": `sum( container_memory_working_set_bytes{job="kubelet", metrics_path="/metrics/cadvisor", container!="", image!=""} * on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{$1}) by (workload)/sum( kube_pod_container_resource_limits{job="kube-state-metrics", resource="memory"}* on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{ }) by (workload)`, // pod "pod_cpu_usage": `round(sum by (namespace, pod) (irate(container_cpu_usage_seconds_total{job="kubelet", pod!="", image!=""}[5m])) * on (namespace, pod) group_left(owner_kind,owner_name) kube_pod_owner{$1} * on (namespace, pod) group_left(node) kube_pod_info{$2}, 0.001)`, "pod_cpu_usage_rate": `sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{ $1}) by (pod) / sum(kube_pod_container_resource_limits{ $1,unit="core"}) by (pod)`, From 6af7f4da0d48b335d9dbaf75f8aac20d3b6c1658 Mon Sep 17 00:00:00 2001 From: tzwang Date: Sun, 7 Apr 2024 18:36:39 +0800 Subject: [PATCH 10/17] updated storelink imports Former-commit-id: bc16ee0d15e402befd95a041b61e4327c3549ca1 --- .../logic/schedule/schedulesubmitlogic.go | 12 ++--- .../scheduler/schedulers/aiScheduler.go | 4 +- api/internal/scheduler/service/aiService.go | 4 +- api/internal/storeLink/octopus.go | 4 +- api/internal/storeLink/shuguangHpc.go | 4 +- api/internal/storeLink/shuguangai.go | 4 +- api/internal/storeLink/storeLink.go | 19 ++----- api/internal/svc/servicecontext.go | 4 +- go.mod | 47 +++++++++-------- go.sum | 52 ++++++++++++++++++- 10 files changed, 95 insertions(+), 59 deletions(-) diff --git a/api/internal/logic/schedule/schedulesubmitlogic.go b/api/internal/logic/schedule/schedulesubmitlogic.go index 074d31c0..3ffc13fe 100644 --- a/api/internal/logic/schedule/schedulesubmitlogic.go +++ b/api/internal/logic/schedule/schedulesubmitlogic.go @@ -50,19 +50,15 @@ func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *type switch opt.GetOptionType() { case option.AI: - for _, result := range results { - _ = (result).(*schedulers.AiResult) - } - } - if resp.ErrorMsg == "" { - resp.Success = true + for _, r := range results { + _ = (r).(*schedulers.AiResult) + //scheResult := &types.ScheduleResult{} + } err = l.svcCtx.Scheduler.AiStorages.SaveTask(req.AiOption.TaskName) if err != nil { return nil, err } - } else { - resp.Success = false } return resp, nil diff --git a/api/internal/scheduler/schedulers/aiScheduler.go b/api/internal/scheduler/schedulers/aiScheduler.go index 0533f22c..248d4452 100644 --- a/api/internal/scheduler/schedulers/aiScheduler.go +++ b/api/internal/scheduler/schedulers/aiScheduler.go @@ -18,6 +18,7 @@ import ( "context" "encoding/json" "errors" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" @@ -26,8 +27,7 @@ import ( "gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/jcce-pcm/pcm-ac/hpcAC" - "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus" + "gitlink.org.cn/JointCloud/pcm-octopus/octopus" "strconv" "sync" ) diff --git a/api/internal/scheduler/service/aiService.go b/api/internal/scheduler/service/aiService.go index 5b21003b..6c7b4096 100644 --- a/api/internal/scheduler/service/aiService.go +++ b/api/internal/scheduler/service/aiService.go @@ -1,13 +1,13 @@ package service import ( + "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/executor" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/jcce-pcm/pcm-ac/hpcacclient" + "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/client/imagesservice" "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/client/modelartsservice" - "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopusclient" ) const ( diff --git a/api/internal/storeLink/octopus.go b/api/internal/storeLink/octopus.go index 2422ada3..18d6c3e1 100644 --- a/api/internal/storeLink/octopus.go +++ b/api/internal/storeLink/octopus.go @@ -20,8 +20,8 @@ import ( "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus" - "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopusclient" + "gitlink.org.cn/JointCloud/pcm-octopus/octopus" + "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" "math" "strconv" "strings" diff --git a/api/internal/storeLink/shuguangHpc.go b/api/internal/storeLink/shuguangHpc.go index d5ffc8ec..9b16401f 100644 --- a/api/internal/storeLink/shuguangHpc.go +++ b/api/internal/storeLink/shuguangHpc.go @@ -4,10 +4,10 @@ import ( "context" "errors" "fmt" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" + "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/jcce-pcm/pcm-ac/hpcAC" - "gitlink.org.cn/jcce-pcm/pcm-ac/hpcacclient" "strconv" "strings" ) diff --git a/api/internal/storeLink/shuguangai.go b/api/internal/storeLink/shuguangai.go index a108d8b7..fd9c6245 100644 --- a/api/internal/storeLink/shuguangai.go +++ b/api/internal/storeLink/shuguangai.go @@ -17,13 +17,13 @@ package storeLink import ( "context" "errors" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" + "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/common" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/jcce-pcm/pcm-ac/hpcAC" - "gitlink.org.cn/jcce-pcm/pcm-ac/hpcacclient" "strconv" "strings" ) diff --git a/api/internal/storeLink/storeLink.go b/api/internal/storeLink/storeLink.go index b3c0ba2d..87ca2ff8 100644 --- a/api/internal/storeLink/storeLink.go +++ b/api/internal/storeLink/storeLink.go @@ -17,18 +17,18 @@ package storeLink import ( "context" "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" + "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/common" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/timeutils" - "gitlink.org.cn/jcce-pcm/pcm-ac/hpcAC" - "gitlink.org.cn/jcce-pcm/pcm-ac/hpcacclient" + "gitlink.org.cn/JointCloud/pcm-octopus/octopus" + "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/client/imagesservice" "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/client/modelartsservice" "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts" - "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus" - "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopusclient" "gorm.io/gorm" "strings" "sync" @@ -373,11 +373,6 @@ func ConvertType(in interface{}, out interface{}, participant *models.StorelinkC return resp, nil case *types.ScheduleResp: resp := (interface{})(out).(*types.ScheduleResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - return resp, nil - } return resp, nil } return nil, nil @@ -414,12 +409,6 @@ func ConvertType(in interface{}, out interface{}, participant *models.StorelinkC return resp, nil case *types.ScheduleResp: resp := (interface{})(out).(*types.ScheduleResp) - if inresp.Code == "0" { - resp.Success = true - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - } return resp, nil } return nil, nil diff --git a/api/internal/svc/servicecontext.go b/api/internal/svc/servicecontext.go index 4bec99a7..ee9510d2 100644 --- a/api/internal/svc/servicecontext.go +++ b/api/internal/svc/servicecontext.go @@ -21,6 +21,7 @@ import ( "github.com/robfig/cron/v3" "github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/zrpc" + "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/config" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/database" @@ -29,13 +30,12 @@ import ( "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/client/participantservice" "gitlink.org.cn/JointCloud/pcm-kubernetes/kubernetesclient" + "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" "gitlink.org.cn/JointCloud/pcm-openstack/openstackclient" slurmClient "gitlink.org.cn/JointCloud/pcm-slurm/slurmclient" - "gitlink.org.cn/jcce-pcm/pcm-ac/hpcacclient" "gitlink.org.cn/jcce-pcm/pcm-participant-ceph/cephclient" "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/client/imagesservice" "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/client/modelartsservice" - "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopusclient" "gorm.io/driver/mysql" "gorm.io/gorm" "gorm.io/gorm/logger" diff --git a/go.mod b/go.mod index 53068e7a..d6e5bd90 100644 --- a/go.mod +++ b/go.mod @@ -13,25 +13,25 @@ require ( github.com/go-sql-driver/mysql v1.7.1 github.com/jinzhu/copier v0.4.0 github.com/json-iterator/go v1.1.12 - github.com/nacos-group/nacos-sdk-go/v2 v2.2.4 + github.com/nacos-group/nacos-sdk-go/v2 v2.2.5 github.com/pkg/errors v0.9.1 github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.71.2 github.com/prometheus/alertmanager v0.27.0 github.com/prometheus/client_golang v1.19.0 - github.com/prometheus/common v0.51.1 + github.com/prometheus/common v0.52.2 github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.28.0 github.com/zeromicro/go-zero v1.6.3 + gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240407093112-465b5009e89b + gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240407025724-6ffd7668eb9c gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 - gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090 - gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4 - go.opentelemetry.io/otel/trace v1.24.0 + go.opentelemetry.io/otel/trace v1.25.0 gonum.org/v1/gonum v0.11.0 - google.golang.org/grpc v1.62.1 + google.golang.org/grpc v1.63.0 google.golang.org/protobuf v1.33.0 gorm.io/datatypes v1.2.0 gorm.io/driver/mysql v1.5.2 @@ -54,9 +54,10 @@ require ( github.com/aws/aws-sdk-go v1.50.8 // indirect github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bitly/go-simplejson v0.5.1 // indirect github.com/buger/jsonparser v1.1.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/coreos/go-semver v0.3.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect @@ -78,6 +79,7 @@ require ( github.com/go-openapi/strfmt v0.22.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/go-openapi/validate v0.23.0 // indirect + github.com/go-redis/redis v6.15.9+incompatible // indirect github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect @@ -122,7 +124,7 @@ require ( github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/openzipkin/zipkin-go v0.4.2 // indirect github.com/pelletier/go-toml/v2 v2.2.0 // indirect - github.com/prometheus/client_model v0.6.0 // indirect + github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common/sigv4 v0.1.0 // indirect github.com/prometheus/exporter-toolkit v0.11.0 // indirect github.com/prometheus/procfs v0.13.0 // indirect @@ -133,31 +135,32 @@ require ( github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/xhit/go-str2duration/v2 v2.1.0 // indirect github.com/xlab/treeprint v1.2.0 // indirect + gitlink.org.cn/jcce-pcm/utils v0.0.2 // indirect go.etcd.io/etcd/api/v3 v3.5.13 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect go.etcd.io/etcd/client/v3 v3.5.13 // indirect go.mongodb.org/mongo-driver v1.13.1 // indirect - go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel v1.25.0 // indirect go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect - go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 // indirect - go.opentelemetry.io/otel/exporters/zipkin v1.24.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/otel/sdk v1.24.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.25.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0 // indirect + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.25.0 // indirect + go.opentelemetry.io/otel/exporters/zipkin v1.25.0 // indirect + go.opentelemetry.io/otel/metric v1.25.0 // indirect + go.opentelemetry.io/otel/sdk v1.25.0 // indirect go.opentelemetry.io/proto/otlp v1.1.0 // indirect go.uber.org/automaxprocs v1.5.3 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.21.0 // indirect + golang.org/x/crypto v0.22.0 // indirect golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect golang.org/x/mod v0.15.0 // indirect - golang.org/x/net v0.22.0 // indirect - golang.org/x/oauth2 v0.18.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/oauth2 v0.19.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/term v0.18.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.18.0 // indirect @@ -171,7 +174,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/api v0.29.3 // indirect k8s.io/klog/v2 v2.120.1 // indirect - k8s.io/kube-openapi v0.0.0-20240322212309-b815d8309940 // indirect + k8s.io/kube-openapi v0.0.0-20240403164606-bc84c2ddaf99 // indirect k8s.io/utils v0.0.0-20240310230437-4693a0247e57 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect diff --git a/go.sum b/go.sum index e4a29585..6582822a 100644 --- a/go.sum +++ b/go.sum @@ -449,6 +449,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bitly/go-simplejson v0.5.1 h1:xgwPbetQScXt1gh9BmoJ6j9JMr3TElvuIyjR8pgdoow= +github.com/bitly/go-simplejson v0.5.1/go.mod h1:YOPVLzCfwK14b4Sff3oP1AmGhI9T9Vsg84etUnlyp+Q= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= @@ -470,6 +472,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -589,6 +593,8 @@ github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+Gr github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-openapi/validate v0.23.0 h1:2l7PJLzCis4YUGEoW6eoQw3WhyM65WSIcjX6SQnlfDw= github.com/go-openapi/validate v0.23.0/go.mod h1:EeiAZ5bmpSIOJV1WLfyYF9qp/B1ZgSaEpHTJHtN5cbE= +github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg= +github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-resty/resty/v2 v2.12.0 h1:rsVL8P90LFvkUYq/V5BTVe203WfRIU4gvcf+yfzJzGA= @@ -893,6 +899,8 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+ github.com/nacos-group/nacos-sdk-go/v2 v2.2.1/go.mod h1:ys/1adWeKXXzbNWfRNbaFlX/t6HVLWdpsNDvmoWTw0g= github.com/nacos-group/nacos-sdk-go/v2 v2.2.4 h1:t3Eoz3ySvKrm7p2WMfWYciCF87UEdLac64CZKFlC0BA= github.com/nacos-group/nacos-sdk-go/v2 v2.2.4/go.mod h1:Q9qY/WK+kxTKK7cNoxMkdkKcD7BLBgTmwQ1jmThgGK8= +github.com/nacos-group/nacos-sdk-go/v2 v2.2.5 h1:r0wwT7PayEjvEHzWXwr1ROi/JSqzujM4w+1L5ikThzQ= +github.com/nacos-group/nacos-sdk-go/v2 v2.2.5/go.mod h1:OObBon0prVJVPoIbSZxpEkFiBfL0d1LcBtuAMiNn+8c= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= @@ -976,6 +984,8 @@ github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6T github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= @@ -985,6 +995,8 @@ github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+ github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/common v0.51.1 h1:eIjN50Bwglz6a/c3hAgSMcofL3nD+nFQkV6Dd4DsQCw= github.com/prometheus/common v0.51.1/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= +github.com/prometheus/common v0.52.2 h1:LW8Vk7BccEdONfrJBDffQGRtpSzi5CQaRZGtboOO2ck= +github.com/prometheus/common v0.52.2/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4= github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI= github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= @@ -1079,8 +1091,12 @@ github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7 github.com/zeromicro/go-zero v1.5.1/go.mod h1:bGYm4XWsGN9GhDsO2O2BngpVoWjf3Eog2a5hUOMhlXs= github.com/zeromicro/go-zero v1.6.3 h1:OL0NnHD5LdRNDolfcK9vUkJt7K8TcBE3RkzfM8poOVw= github.com/zeromicro/go-zero v1.6.3/go.mod h1:XZL435ZxVi9MSXXtw2MRQhHgx6OoX3++MRMOE9xU70c= +gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240407093112-465b5009e89b h1:I/0NwMSyKomCYQO+zqr3k9DG75SF8TzX8nXde+8MvzI= +gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240407093112-465b5009e89b/go.mod h1:w3Nb5TNymCItQ7K3x4Q0JLuoq9OerwAzAWT2zsPE9Xo= gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c h1:2Wl/hvaSFjh6fmCSIQhjkr9llMRREQeqcXNLZ/HPY18= gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c/go.mod h1:lSRfGs+PxFvw7CcndHWRd6UlLlGrZn0b0hp5cfaMNGw= +gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240407025724-6ffd7668eb9c h1:yA5W4Wz6hGgnbjvz+pJCxufpu8UMvJtLW7MP4maCdVA= +gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240407025724-6ffd7668eb9c/go.mod h1:2J652/+hdt3jGXj+XFMe0nnmvEn9yx7m6XjcOOJOROI= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240401022404-2f1425735f0d h1:ZX/Kg8eKdaAfDsTd+Y+TrJsUvxp/DpbWUp+Ij4CtR+s= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240401022404-2f1425735f0d/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240402074843-46c7d05954e6 h1:d40gT5SaARH82SWJMMOao9iJ4QxrnjswjHFmU3tCPac= @@ -1089,14 +1105,14 @@ gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6 gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnzkJBfMRnya1NrhOzlroUtRa5ePiYbPKlHLoLV0= gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5/go.mod h1:97AlUXN13g9UN3+9/DzCHpeoU5sbdyv0IQuTEHNexzQ= -gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a h1:fY1KmyZ6O7wVBvgt2HB+C9e1DncJdk/Wkv8m5Qz7abw= -gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a/go.mod h1:oMaWf5sEDFKTfCbIlT6/7IFI3f6PsuiRnWzzQruSF5Q= gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d h1:DHjl/rLuH2gKYtY0MKMGNQDHFT12APg25RlMUQo+tHk= gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d/go.mod h1:r/KLzUpupCV5jdxSfgDhc2pVjP0fBi3VhAWRttsBn30= gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090 h1:jztlHo72bcWM1jUwvG3Hfk2K+AJL0RvlsdIqlktH/MI= gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090/go.mod h1:pisJKAI8FRFFUcBaH3Gob+ENXWRM97rpuYmv9s1raag= gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4 h1:NrxKAZ5uAzshB9EHcPw+XTOTzpxb5HslNRMYBrFC1Qo= gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4/go.mod h1:uyvpVqG1jHDXX+ubXI0RBwnWXzVykD/mliqGQIDvRoo= +gitlink.org.cn/jcce-pcm/utils v0.0.2 h1:Stif8W9C9TOCS2hw4g+OlOywDrsVYNrkiyKfBrWkT0w= +gitlink.org.cn/jcce-pcm/utils v0.0.2/go.mod h1:u8PTlBpzUyOlbQJgfSiutq91q/JtrJIQiPNDe4S/pGs= go.etcd.io/etcd/api/v3 v3.5.7/go.mod h1:9qew1gCdDDLu+VwmeG+iFpL+QlpHTo7iubavdVDgCAA= go.etcd.io/etcd/api/v3 v3.5.13 h1:8WXU2/NBge6AUF1K1gOexB6e07NgsN1hXK0rSTtgSp4= go.etcd.io/etcd/api/v3 v3.5.13/go.mod h1:gBqlqkcMMZMVTMm4NDZloEVJzxQOQIls8splbqBDa0c= @@ -1120,6 +1136,8 @@ go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel v1.25.0 h1:gldB5FfhRl7OJQbUHt/8s0a7cE8fbsPAtdpRaApKy4k= +go.opentelemetry.io/otel v1.25.0/go.mod h1:Wa2ds5NOXEMkCmUou1WA7ZBfLTHWIsp034OVD7AO+Vg= go.opentelemetry.io/otel/exporters/jaeger v1.14.0/go.mod h1:4Ay9kk5vELRrbg5z4cpP9EtmQRFap2Wb0woPG4lujZA= go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4= go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI= @@ -1127,25 +1145,41 @@ go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0/go.mod h1:UFG7EBM go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0/go.mod h1:HrbCVv40OOLTABmOn1ZWty6CHXkU8DK/Urc43tHug70= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0 h1:dT33yIHtmsqpixFsSQPwNeY5drM9wTcoL8h0FWF4oGM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0/go.mod h1:h95q0LBGh7hlAC08X2DhSeyIG02YQ0UyioTCVAqRPmc= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0/go.mod h1:5w41DY6S9gZrbjuq6Y+753e96WfPha5IcsOSZTtullM= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 h1:Mw5xcxMwlqoJd97vwPxA8isEaIoxsta9/Q51+TTJLGE= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0/go.mod h1:CQNu9bj7o7mC6U7+CA/schKEYakYXWr79ucDHTMGhCM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.25.0 h1:vOL89uRfOCCNIjkisd0r7SEdJF3ZJFyCNY34fdZs8eU= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.25.0/go.mod h1:8GlBGcDk8KKi7n+2S4BT/CPZQYH3erLu0/k64r1MYgo= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0/go.mod h1:+N7zNjIJv4K+DeX67XXET0P+eIciESgaFDBqh+ZJFS4= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0 h1:Mbi5PKN7u322woPa85d7ebZ+SOvEoPvoiBu+ryHWgfA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0/go.mod h1:e7ciERRhZaOZXVjx5MiL8TK5+Xv7G5Gv5PA2ZDEJdL8= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 h1:s0PHtIkN+3xrbDOpt2M8OTG92cWqUESvzh2MxiR5xY8= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0/go.mod h1:hZlFbDbRt++MMPCCfSJfmhkGIWnX1h3XjkfxZUjLrIA= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.25.0 h1:0vZZdECYzhTt9MKQZ5qQ0V+J3MFu4MQaQ3COfugF+FQ= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.25.0/go.mod h1:e7iXx3HjaSSBXfy9ykVUlupS2Vp7LBIBuT21ousM2Hk= go.opentelemetry.io/otel/exporters/zipkin v1.14.0/go.mod h1:RcjvOAcvhzcufQP8aHmzRw1gE9g/VEZufDdo2w+s4sk= go.opentelemetry.io/otel/exporters/zipkin v1.24.0 h1:3evrL5poBuh1KF51D9gO/S+N/1msnm4DaBqs/rpXUqY= go.opentelemetry.io/otel/exporters/zipkin v1.24.0/go.mod h1:0EHgD8R0+8yRhUYJOGR8Hfg2dpiJQxDOszd5smVO9wM= +go.opentelemetry.io/otel/exporters/zipkin v1.25.0 h1:iLzdsOsstvim/54ymA2BhEN4+1NbsvwGvOhSkQy2TaY= +go.opentelemetry.io/otel/exporters/zipkin v1.25.0/go.mod h1:3QXxNo6ace1QZX6pSHEzGKKESVdjQxXR03FcIH7dNGs= go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/metric v1.25.0 h1:LUKbS7ArpFL/I2jJHdJcqMGxkRdxpPHE0VU/D4NuEwA= +go.opentelemetry.io/otel/metric v1.25.0/go.mod h1:rkDLUSd2lC5lq2dFNrX9LGAbINP5B7WBkC78RXCpH5s= go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM= go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= +go.opentelemetry.io/otel/sdk v1.25.0 h1:PDryEJPC8YJZQSyLY5eqLeafHtG+X7FWnf3aXMtxbqo= +go.opentelemetry.io/otel/sdk v1.25.0/go.mod h1:oFgzCM2zdsxKzz6zwpTZYLLQsFwc+K0daArPdIhuxkw= go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/otel/trace v1.25.0 h1:tqukZGLwQYRIFtSQM2u2+yfMVTgGVeqRLPUYx1Dq6RM= +go.opentelemetry.io/otel/trace v1.25.0/go.mod h1:hCCs70XM/ljO+BeQkyFnbK28SBIJ/Emuha+ccrCRT7I= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= @@ -1192,6 +1226,8 @@ golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58 golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1311,6 +1347,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1340,6 +1378,8 @@ golang.org/x/oauth2 v0.3.0/go.mod h1:rQrIauxkUhJ6CuwEXwymO2/eh4xz2ZWF1nBkcxS+tGk golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= +golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= +golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1460,6 +1500,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1474,6 +1516,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1801,6 +1845,8 @@ google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwS google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= +google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1895,6 +1941,8 @@ k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= k8s.io/kube-openapi v0.0.0-20240322212309-b815d8309940 h1:qVoMaQV5t62UUvHe16Q3eb2c5HPzLHYzsi0Tu/xLndo= k8s.io/kube-openapi v0.0.0-20240322212309-b815d8309940/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= +k8s.io/kube-openapi v0.0.0-20240403164606-bc84c2ddaf99 h1:w6nThEmGo9zcL+xH1Tu6pjxJ3K1jXFW+V0u4peqN8ks= +k8s.io/kube-openapi v0.0.0-20240403164606-bc84c2ddaf99/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= k8s.io/utils v0.0.0-20230115233650-391b47cb4029/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= From 286e58f9d6503e824331cdd2820a2e0b0fc74acb Mon Sep 17 00:00:00 2001 From: tzwang Date: Sun, 7 Apr 2024 19:44:55 +0800 Subject: [PATCH 11/17] updated error imports Former-commit-id: 895dceb1e64d7aa35e9e83450b26091dec9ab9ff --- .../logic/core/getcomputingpowerlogic.go | 4 +- .../logic/core/getgeneralinfologic.go | 4 +- .../logic/schedule/schedulesubmitlogic.go | 12 ++-- api/internal/scheduler/scheduler.go | 4 +- .../scheduler/schedulers/aiScheduler.go | 24 +++---- .../scheduler/schedulers/cloudScheduler.go | 2 +- .../scheduler/schedulers/hpcScheduler.go | 2 +- .../scheduler/schedulers/vmScheduler.go | 2 +- go.mod | 8 +-- go.sum | 63 ++----------------- 10 files changed, 35 insertions(+), 90 deletions(-) diff --git a/api/internal/logic/core/getcomputingpowerlogic.go b/api/internal/logic/core/getcomputingpowerlogic.go index 8fe735b4..40ec24fd 100644 --- a/api/internal/logic/core/getcomputingpowerlogic.go +++ b/api/internal/logic/core/getcomputingpowerlogic.go @@ -17,10 +17,10 @@ package core import ( "context" "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/jcce-pcm/pcm-ac/hpcAC" - "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus" + "gitlink.org.cn/JointCloud/pcm-octopus/octopus" "log" ) diff --git a/api/internal/logic/core/getgeneralinfologic.go b/api/internal/logic/core/getgeneralinfologic.go index 92f69e05..8d0e3461 100644 --- a/api/internal/logic/core/getgeneralinfologic.go +++ b/api/internal/logic/core/getgeneralinfologic.go @@ -17,10 +17,10 @@ package core import ( "context" "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/jcce-pcm/pcm-ac/hpcAC" - "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus" + "gitlink.org.cn/JointCloud/pcm-octopus/octopus" "log" ) diff --git a/api/internal/logic/schedule/schedulesubmitlogic.go b/api/internal/logic/schedule/schedulesubmitlogic.go index 3ffc13fe..c1f9e0f0 100644 --- a/api/internal/logic/schedule/schedulesubmitlogic.go +++ b/api/internal/logic/schedule/schedulesubmitlogic.go @@ -50,10 +50,14 @@ func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *type switch opt.GetOptionType() { case option.AI: - - for _, r := range results { - _ = (r).(*schedulers.AiResult) - //scheResult := &types.ScheduleResult{} + rs := (results).([]*schedulers.AiResult) + for _, r := range rs { + scheResult := &types.ScheduleResult{} + scheResult.ClusterId = r.ClusterId + scheResult.TaskId = r.TaskId + scheResult.Replica = r.Replica + scheResult.Msg = r.Msg + resp.Results = append(resp.Results, scheResult) } err = l.svcCtx.Scheduler.AiStorages.SaveTask(req.AiOption.TaskName) if err != nil { diff --git a/api/internal/scheduler/scheduler.go b/api/internal/scheduler/scheduler.go index 2ed27228..75aa115f 100644 --- a/api/internal/scheduler/scheduler.go +++ b/api/internal/scheduler/scheduler.go @@ -47,7 +47,7 @@ type Scheduler struct { type SubSchedule interface { GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error) PickOptimalStrategy() (strategy.Strategy, error) - AssignTask(clusters []*strategy.AssignedCluster) ([]interface{}, error) + AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) } func NewScheduler(subSchedule SubSchedule, val string, dbEngin *gorm.DB, participantRpc participantservice.ParticipantService) (*Scheduler, error) { @@ -130,7 +130,7 @@ func (s *Scheduler) TempAssign() error { return nil } -func (s *Scheduler) AssignAndSchedule(ss SubSchedule) ([]interface{}, error) { +func (s *Scheduler) AssignAndSchedule(ss SubSchedule) (interface{}, error) { //// 已指定 ParticipantId //if s.task.ParticipantId != 0 { // return nil diff --git a/api/internal/scheduler/schedulers/aiScheduler.go b/api/internal/scheduler/schedulers/aiScheduler.go index 248d4452..58a4b614 100644 --- a/api/internal/scheduler/schedulers/aiScheduler.go +++ b/api/internal/scheduler/schedulers/aiScheduler.go @@ -41,10 +41,10 @@ type AiScheduler struct { } type AiResult struct { - taskId string - clusterId string - replica int32 - msg string + TaskId string + ClusterId string + Replica int32 + Msg string } func NewAiScheduler(ctx context.Context, val string, scheduler *scheduler.Scheduler, option *option.AiOption) (*AiScheduler, error) { @@ -106,13 +106,13 @@ func (as *AiScheduler) PickOptimalStrategy() (strategy.Strategy, error) { return nil, errors.New("no strategy has been chosen") } -func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]interface{}, error) { +func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { if clusters == nil { return nil, errors.New("clusters is nil") } var wg sync.WaitGroup - var results []interface{} + var results []*AiResult var errs []error var ch = make(chan *AiResult, len(clusters)) var errCh = make(chan error, len(clusters)) @@ -135,8 +135,8 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]inter } result, _ := convertType(resp) - result.replica = c.Replicas - result.clusterId = strconv.FormatInt(c.ParticipantId, 10) + result.Replica = c.Replicas + result.ClusterId = strconv.FormatInt(c.ParticipantId, 10) ch <- result wg.Done() @@ -212,18 +212,18 @@ func convertType(in interface{}) (*AiResult, error) { case *hpcAC.SubmitTaskAiResp: resp := (in).(*hpcAC.SubmitTaskAiResp) if resp.Code == "0" { - result.taskId = resp.Data + result.TaskId = resp.Data } else { - result.msg = resp.Msg + result.Msg = resp.Msg } return &result, nil case *octopus.CreateTrainJobResp: resp := (in).(*octopus.CreateTrainJobResp) if resp.Success { - result.taskId = resp.Payload.JobId + result.TaskId = resp.Payload.JobId } else { - result.msg = resp.Error.Message + result.Msg = resp.Error.Message } return &result, nil diff --git a/api/internal/scheduler/schedulers/cloudScheduler.go b/api/internal/scheduler/schedulers/cloudScheduler.go index 097635ab..e4035574 100644 --- a/api/internal/scheduler/schedulers/cloudScheduler.go +++ b/api/internal/scheduler/schedulers/cloudScheduler.go @@ -115,6 +115,6 @@ func (cs *CloudScheduler) genTaskAndProviders() (*providerPricing.Task, []*provi return nil, providerList, nil } -func (cs *CloudScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]interface{}, error) { +func (cs *CloudScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { return nil, nil } diff --git a/api/internal/scheduler/schedulers/hpcScheduler.go b/api/internal/scheduler/schedulers/hpcScheduler.go index 319b8183..6d84eaef 100644 --- a/api/internal/scheduler/schedulers/hpcScheduler.go +++ b/api/internal/scheduler/schedulers/hpcScheduler.go @@ -50,6 +50,6 @@ func (h *HpcScheduler) genTaskAndProviders(task *response.TaskInfo) (*providerPr return nil, nil } -func (h *HpcScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]interface{}, error) { +func (h *HpcScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { return nil, nil } diff --git a/api/internal/scheduler/schedulers/vmScheduler.go b/api/internal/scheduler/schedulers/vmScheduler.go index 80e89c4e..4bb626f3 100644 --- a/api/internal/scheduler/schedulers/vmScheduler.go +++ b/api/internal/scheduler/schedulers/vmScheduler.go @@ -64,7 +64,7 @@ func (vm *VmScheduler) genTaskAndProviders() (*providerPricing.Task, []*provider return nil, providerList, nil } -func (v VmScheduler) AssignTask(clusters []*strategy.AssignedCluster) ([]interface{}, error) { +func (v VmScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { //TODO implement me panic("implement me") } diff --git a/go.mod b/go.mod index d6e5bd90..b6422d1c 100644 --- a/go.mod +++ b/go.mod @@ -22,9 +22,9 @@ require ( github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.28.0 github.com/zeromicro/go-zero v1.6.3 - gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240407093112-465b5009e89b - gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240407025724-6ffd7668eb9c + gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240407112649-e479e74b58c8 gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c + gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240407105727-38e45468eaa8 gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d @@ -54,7 +54,6 @@ require ( github.com/aws/aws-sdk-go v1.50.8 // indirect github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bitly/go-simplejson v0.5.1 // indirect github.com/buger/jsonparser v1.1.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect @@ -79,7 +78,6 @@ require ( github.com/go-openapi/strfmt v0.22.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/go-openapi/validate v0.23.0 // indirect - github.com/go-redis/redis v6.15.9+incompatible // indirect github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect @@ -135,7 +133,6 @@ require ( github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/xhit/go-str2duration/v2 v2.1.0 // indirect github.com/xlab/treeprint v1.2.0 // indirect - gitlink.org.cn/jcce-pcm/utils v0.0.2 // indirect go.etcd.io/etcd/api/v3 v3.5.13 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect go.etcd.io/etcd/client/v3 v3.5.13 // indirect @@ -164,7 +161,6 @@ require ( golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.18.0 // indirect - google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/go.sum b/go.sum index 6582822a..cdd78495 100644 --- a/go.sum +++ b/go.sum @@ -449,8 +449,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bitly/go-simplejson v0.5.1 h1:xgwPbetQScXt1gh9BmoJ6j9JMr3TElvuIyjR8pgdoow= -github.com/bitly/go-simplejson v0.5.1/go.mod h1:YOPVLzCfwK14b4Sff3oP1AmGhI9T9Vsg84etUnlyp+Q= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= @@ -466,11 +464,9 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -593,8 +589,6 @@ github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+Gr github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-openapi/validate v0.23.0 h1:2l7PJLzCis4YUGEoW6eoQw3WhyM65WSIcjX6SQnlfDw= github.com/go-openapi/validate v0.23.0/go.mod h1:EeiAZ5bmpSIOJV1WLfyYF9qp/B1ZgSaEpHTJHtN5cbE= -github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg= -github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-resty/resty/v2 v2.12.0 h1:rsVL8P90LFvkUYq/V5BTVe203WfRIU4gvcf+yfzJzGA= @@ -735,7 +729,6 @@ github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/z github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= @@ -897,8 +890,6 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nacos-group/nacos-sdk-go/v2 v2.2.1/go.mod h1:ys/1adWeKXXzbNWfRNbaFlX/t6HVLWdpsNDvmoWTw0g= -github.com/nacos-group/nacos-sdk-go/v2 v2.2.4 h1:t3Eoz3ySvKrm7p2WMfWYciCF87UEdLac64CZKFlC0BA= -github.com/nacos-group/nacos-sdk-go/v2 v2.2.4/go.mod h1:Q9qY/WK+kxTKK7cNoxMkdkKcD7BLBgTmwQ1jmThgGK8= github.com/nacos-group/nacos-sdk-go/v2 v2.2.5 h1:r0wwT7PayEjvEHzWXwr1ROi/JSqzujM4w+1L5ikThzQ= github.com/nacos-group/nacos-sdk-go/v2 v2.2.5/go.mod h1:OObBon0prVJVPoIbSZxpEkFiBfL0d1LcBtuAMiNn+8c= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= @@ -982,8 +973,6 @@ github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1: github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= @@ -993,8 +982,6 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9 github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/common v0.51.1 h1:eIjN50Bwglz6a/c3hAgSMcofL3nD+nFQkV6Dd4DsQCw= -github.com/prometheus/common v0.51.1/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= github.com/prometheus/common v0.52.2 h1:LW8Vk7BccEdONfrJBDffQGRtpSzi5CQaRZGtboOO2ck= github.com/prometheus/common v0.52.2/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4= @@ -1091,16 +1078,12 @@ github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7 github.com/zeromicro/go-zero v1.5.1/go.mod h1:bGYm4XWsGN9GhDsO2O2BngpVoWjf3Eog2a5hUOMhlXs= github.com/zeromicro/go-zero v1.6.3 h1:OL0NnHD5LdRNDolfcK9vUkJt7K8TcBE3RkzfM8poOVw= github.com/zeromicro/go-zero v1.6.3/go.mod h1:XZL435ZxVi9MSXXtw2MRQhHgx6OoX3++MRMOE9xU70c= -gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240407093112-465b5009e89b h1:I/0NwMSyKomCYQO+zqr3k9DG75SF8TzX8nXde+8MvzI= -gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240407093112-465b5009e89b/go.mod h1:w3Nb5TNymCItQ7K3x4Q0JLuoq9OerwAzAWT2zsPE9Xo= +gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240407112649-e479e74b58c8 h1:cX6U2gUcp/sIP3TKFv4q/1O8gp10q+M3k5Ql15yaEMI= +gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240407112649-e479e74b58c8/go.mod h1:w3Nb5TNymCItQ7K3x4Q0JLuoq9OerwAzAWT2zsPE9Xo= gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c h1:2Wl/hvaSFjh6fmCSIQhjkr9llMRREQeqcXNLZ/HPY18= gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c/go.mod h1:lSRfGs+PxFvw7CcndHWRd6UlLlGrZn0b0hp5cfaMNGw= -gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240407025724-6ffd7668eb9c h1:yA5W4Wz6hGgnbjvz+pJCxufpu8UMvJtLW7MP4maCdVA= -gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240407025724-6ffd7668eb9c/go.mod h1:2J652/+hdt3jGXj+XFMe0nnmvEn9yx7m6XjcOOJOROI= -gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240401022404-2f1425735f0d h1:ZX/Kg8eKdaAfDsTd+Y+TrJsUvxp/DpbWUp+Ij4CtR+s= -gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240401022404-2f1425735f0d/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= -gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240402074843-46c7d05954e6 h1:d40gT5SaARH82SWJMMOao9iJ4QxrnjswjHFmU3tCPac= -gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240402074843-46c7d05954e6/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= +gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240407105727-38e45468eaa8 h1:jdwYydJxYPlfIS9yZvnNX1w08aJGYWq5ADD5EXLW3+Q= +gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240407105727-38e45468eaa8/go.mod h1:QOD5+/l2D+AYBjF2h5T0mdJyfGAmF78QmeKdbBXbjLQ= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6PsZ1+bev294IWdZRlV7mnOwI1+UzFcldVW/BqhQzI= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnzkJBfMRnya1NrhOzlroUtRa5ePiYbPKlHLoLV0= @@ -1109,10 +1092,6 @@ gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d/go.mod h1:r/KLzUpupCV5jdxSfgDhc2pVjP0fBi3VhAWRttsBn30= gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090 h1:jztlHo72bcWM1jUwvG3Hfk2K+AJL0RvlsdIqlktH/MI= gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090/go.mod h1:pisJKAI8FRFFUcBaH3Gob+ENXWRM97rpuYmv9s1raag= -gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4 h1:NrxKAZ5uAzshB9EHcPw+XTOTzpxb5HslNRMYBrFC1Qo= -gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4/go.mod h1:uyvpVqG1jHDXX+ubXI0RBwnWXzVykD/mliqGQIDvRoo= -gitlink.org.cn/jcce-pcm/utils v0.0.2 h1:Stif8W9C9TOCS2hw4g+OlOywDrsVYNrkiyKfBrWkT0w= -gitlink.org.cn/jcce-pcm/utils v0.0.2/go.mod h1:u8PTlBpzUyOlbQJgfSiutq91q/JtrJIQiPNDe4S/pGs= go.etcd.io/etcd/api/v3 v3.5.7/go.mod h1:9qew1gCdDDLu+VwmeG+iFpL+QlpHTo7iubavdVDgCAA= go.etcd.io/etcd/api/v3 v3.5.13 h1:8WXU2/NBge6AUF1K1gOexB6e07NgsN1hXK0rSTtgSp4= go.etcd.io/etcd/api/v3 v3.5.13/go.mod h1:gBqlqkcMMZMVTMm4NDZloEVJzxQOQIls8splbqBDa0c= @@ -1134,8 +1113,6 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel v1.25.0 h1:gldB5FfhRl7OJQbUHt/8s0a7cE8fbsPAtdpRaApKy4k= go.opentelemetry.io/otel v1.25.0/go.mod h1:Wa2ds5NOXEMkCmUou1WA7ZBfLTHWIsp034OVD7AO+Vg= go.opentelemetry.io/otel/exporters/jaeger v1.14.0/go.mod h1:4Ay9kk5vELRrbg5z4cpP9EtmQRFap2Wb0woPG4lujZA= @@ -1143,41 +1120,25 @@ go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0/go.mod h1:UFG7EBMRdXyFstOwH028U0sVf+AvukSGhF0g8+dmNG8= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0/go.mod h1:HrbCVv40OOLTABmOn1ZWty6CHXkU8DK/Urc43tHug70= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0 h1:dT33yIHtmsqpixFsSQPwNeY5drM9wTcoL8h0FWF4oGM= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0/go.mod h1:h95q0LBGh7hlAC08X2DhSeyIG02YQ0UyioTCVAqRPmc= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0/go.mod h1:5w41DY6S9gZrbjuq6Y+753e96WfPha5IcsOSZTtullM= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 h1:Mw5xcxMwlqoJd97vwPxA8isEaIoxsta9/Q51+TTJLGE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0/go.mod h1:CQNu9bj7o7mC6U7+CA/schKEYakYXWr79ucDHTMGhCM= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.25.0 h1:vOL89uRfOCCNIjkisd0r7SEdJF3ZJFyCNY34fdZs8eU= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.25.0/go.mod h1:8GlBGcDk8KKi7n+2S4BT/CPZQYH3erLu0/k64r1MYgo= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0/go.mod h1:+N7zNjIJv4K+DeX67XXET0P+eIciESgaFDBqh+ZJFS4= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0 h1:Mbi5PKN7u322woPa85d7ebZ+SOvEoPvoiBu+ryHWgfA= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0/go.mod h1:e7ciERRhZaOZXVjx5MiL8TK5+Xv7G5Gv5PA2ZDEJdL8= -go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 h1:s0PHtIkN+3xrbDOpt2M8OTG92cWqUESvzh2MxiR5xY8= -go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0/go.mod h1:hZlFbDbRt++MMPCCfSJfmhkGIWnX1h3XjkfxZUjLrIA= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.25.0 h1:0vZZdECYzhTt9MKQZ5qQ0V+J3MFu4MQaQ3COfugF+FQ= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.25.0/go.mod h1:e7iXx3HjaSSBXfy9ykVUlupS2Vp7LBIBuT21ousM2Hk= go.opentelemetry.io/otel/exporters/zipkin v1.14.0/go.mod h1:RcjvOAcvhzcufQP8aHmzRw1gE9g/VEZufDdo2w+s4sk= -go.opentelemetry.io/otel/exporters/zipkin v1.24.0 h1:3evrL5poBuh1KF51D9gO/S+N/1msnm4DaBqs/rpXUqY= -go.opentelemetry.io/otel/exporters/zipkin v1.24.0/go.mod h1:0EHgD8R0+8yRhUYJOGR8Hfg2dpiJQxDOszd5smVO9wM= go.opentelemetry.io/otel/exporters/zipkin v1.25.0 h1:iLzdsOsstvim/54ymA2BhEN4+1NbsvwGvOhSkQy2TaY= go.opentelemetry.io/otel/exporters/zipkin v1.25.0/go.mod h1:3QXxNo6ace1QZX6pSHEzGKKESVdjQxXR03FcIH7dNGs= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= go.opentelemetry.io/otel/metric v1.25.0 h1:LUKbS7ArpFL/I2jJHdJcqMGxkRdxpPHE0VU/D4NuEwA= go.opentelemetry.io/otel/metric v1.25.0/go.mod h1:rkDLUSd2lC5lq2dFNrX9LGAbINP5B7WBkC78RXCpH5s= go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM= -go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= -go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/sdk v1.25.0 h1:PDryEJPC8YJZQSyLY5eqLeafHtG+X7FWnf3aXMtxbqo= go.opentelemetry.io/otel/sdk v1.25.0/go.mod h1:oFgzCM2zdsxKzz6zwpTZYLLQsFwc+K0daArPdIhuxkw= go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/otel/trace v1.25.0 h1:tqukZGLwQYRIFtSQM2u2+yfMVTgGVeqRLPUYx1Dq6RM= go.opentelemetry.io/otel/trace v1.25.0/go.mod h1:hCCs70XM/ljO+BeQkyFnbK28SBIJ/Emuha+ccrCRT7I= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -1224,7 +1185,6 @@ golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= @@ -1345,7 +1305,6 @@ golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= @@ -1376,8 +1335,6 @@ golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.3.0/go.mod h1:rQrIauxkUhJ6CuwEXwymO2/eh4xz2ZWF1nBkcxS+tGk= golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= -golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= -golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1498,7 +1455,6 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= @@ -1514,7 +1470,6 @@ golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= @@ -1678,8 +1633,6 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -1795,12 +1748,8 @@ google.golang.org/genproto v0.0.0-20221202195650-67e5cbc046fd/go.mod h1:cTsE614G google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/genproto v0.0.0-20230123190316-2c411cf9d197/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa h1:Jt1XW5PaLXF1/ePZrznsh/aAUvI7Adfc3LY1dAKlzRs= -google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa/go.mod h1:K4kfzHtI0kqWA79gecJarFtDn/Mls+GxQcg3Zox91Ac= google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda h1:b6F6WIV4xHHD0FA4oIyzU6mHWg2WI2X1RBehwa5QN38= google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda/go.mod h1:AHcE/gZH76Bk/ROZhQphlRoWo5xKDEtz3eVEO1LfA8c= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240325203815-454cdb8f5daa h1:RBgMaUMP+6soRkik4VoN8ojR2nex2TqZwjSSogic+eo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240325203815-454cdb8f5daa/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1843,8 +1792,6 @@ google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCD google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -1939,8 +1886,6 @@ k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= -k8s.io/kube-openapi v0.0.0-20240322212309-b815d8309940 h1:qVoMaQV5t62UUvHe16Q3eb2c5HPzLHYzsi0Tu/xLndo= -k8s.io/kube-openapi v0.0.0-20240322212309-b815d8309940/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= k8s.io/kube-openapi v0.0.0-20240403164606-bc84c2ddaf99 h1:w6nThEmGo9zcL+xH1Tu6pjxJ3K1jXFW+V0u4peqN8ks= k8s.io/kube-openapi v0.0.0-20240403164606-bc84c2ddaf99/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= From 24610ac92b48114777d2c0b98b956e37ef2f8e85 Mon Sep 17 00:00:00 2001 From: zhangwei <894646498@qq.com> Date: Mon, 8 Apr 2024 08:49:01 +0800 Subject: [PATCH 12/17] alert Former-commit-id: d0e5f3565f8531360991f9fa5d89d8be0d94dd18 --- api/desc/monitoring/pcm-monitoring.api | 6 +- api/desc/pcm.api | 2 +- api/internal/types/types.go | 121 +++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 2 deletions(-) diff --git a/api/desc/monitoring/pcm-monitoring.api b/api/desc/monitoring/pcm-monitoring.api index e09efd66..9a09aed1 100644 --- a/api/desc/monitoring/pcm-monitoring.api +++ b/api/desc/monitoring/pcm-monitoring.api @@ -12,7 +12,11 @@ type CreateAlertRuleReq { } type ( - alertRulesResp { + AlertRulesResp { + alertRules []AlertRule `json:"alertRules"` + } + + AlertRule { Id int64 `json:"id"` ClusterName string `json:"clusterName"` Name string `json:"name"` diff --git a/api/desc/pcm.api b/api/desc/pcm.api index ca01fdce..ee7ffd74 100644 --- a/api/desc/pcm.api +++ b/api/desc/pcm.api @@ -952,7 +952,7 @@ service pcm { @doc "alert rules" @handler alertRulesHandler - get /monitoring/alert/rule returns (alertRulesResp) + get /monitoring/alert/rule returns (AlertRulesResp) @doc "cluster resource load" @handler clustersLoadHandler diff --git a/api/internal/types/types.go b/api/internal/types/types.go index d6305899..ddea5775 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -5316,6 +5316,123 @@ type AiAlgorithmsResp struct { Algorithms []string `json:"algorithms"` } +type PullTaskInfoReq struct { + AdapterId int64 `form:"adapterId"` +} + +type PullTaskInfoResp struct { + HpcInfoList []*HpcInfo `json:"HpcInfoList,omitempty"` + CloudInfoList []*CloudInfo `json:"CloudInfoList,omitempty"` + AiInfoList []*AiInfo `json:"AiInfoList,omitempty"` + VmInfoList []*VmInfo `json:"VmInfoList,omitempty"` +} + +type HpcInfo struct { + Id int64 `json:"id"` // id + TaskId int64 `json:"task_id"` // 任务id + JobId string `json:"job_id"` // 作业id(在第三方系统中的作业id) + AdapterId int64 `json:"adapter_id"` // 执行任务的适配器id + ClusterId int64 `json:"cluster_id"` // 执行任务的集群id + ClusterType string `json:"cluster_type"` // 执行任务的集群类型 + Name string `json:"name"` // 名称 + Status string `json:"status"` // 状态 + CmdScript string `json:"cmd_script"` + StartTime string `json:"start_time"` // 开始时间 + RunningTime int64 `json:"running_time"` // 运行时间 + DerivedEs string `json:"derived_es"` + Cluster string `json:"cluster"` + BlockId int64 `json:"block_id"` + AllocNodes int64 `json:"alloc_nodes"` + AllocCpu int64 `json:"alloc_cpu"` + CardCount int64 `json:"card_count"` // 卡数 + Version string `json:"version"` + Account string `json:"account"` + WorkDir string `json:"work_dir"` // 工作路径 + AssocId int64 `json:"assoc_id"` + ExitCode int64 `json:"exit_code"` + WallTime string `json:"wall_time"` // 最大运行时间 + Result string `json:"result"` // 运行结果 + DeletedAt string `json:"deleted_at"` // 删除时间 + YamlString string `json:"yaml_string"` + AppType string `json:"app_type"` // 应用类型 + AppName string `json:"app_name"` // 应用名称 + Queue string `json:"queue"` // 队列名称 + SubmitType string `json:"submit_type"` // cmd(命令行模式) + NNode string `json:"n_node"` // 节点个数(当指定该参数时,GAP_NODE_STRING必须为"") + StdOutFile string `json:"std_out_file"` // 工作路径/std.err.%j + StdErrFile string `json:"std_err_file"` // 工作路径/std.err.%j + StdInput string `json:"std_input"` + Environment string `json:"environment"` + DeletedFlag int64 `json:"deleted_flag"` // 是否删除(0-否,1-是) + CreatedBy int64 `json:"created_by"` // 创建人 + CreatedTime string `json:"created_time"` // 创建时间 + UpdatedBy int64 `json:"updated_by"` // 更新人 + UpdatedTime string `json:"updated_time"` // 更新时间 +} + +type CloudInfo struct { + Participant int64 `json:"participant,omitempty"` + Id int64 `json:"id,omitempty"` + TaskId int64 `json:"taskId,omitempty"` + ApiVersion string `json:"apiVersion,omitempty"` + Kind string `json:"kind,omitempty"` + Namespace string `json:"namespace,omitempty"` + Name string `json:"name,omitempty"` + Status string `json:"status,omitempty"` + StartTime string `json:"startTime,omitempty"` + RunningTime int64 `json:"runningTime,omitempty"` + Result string `json:"result,omitempty"` + YamlString string `json:"yamlString,omitempty"` +} + +type AiInfo struct { + ParticipantId int64 `json:"participantId,omitempty"` + TaskId int64 `json:"taskId,omitempty"` + ProjectId string `json:"project_id,omitempty"` + Name string `json:"name,omitempty"` + Status string `json:"status,omitempty"` + StartTime string `json:"startTime,omitempty"` + RunningTime int64 `json:"runningTime,omitempty"` + Result string `json:"result,omitempty"` + JobId string `json:"jobId,omitempty"` + CreateTime string `json:"createTime,omitempty"` + ImageUrl string `json:"imageUrl,omitempty"` + Command string `json:"command,omitempty"` + FlavorId string `json:"flavorId,omitempty"` + SubscriptionId string `json:"subscriptionId,omitempty"` + ItemVersionId string `json:"itemVersionId,omitempty"` +} + +type VmInfo struct { + ParticipantId int64 `json:"participantId,omitempty"` + TaskId int64 `json:"taskId,omitempty"` + Name string `json:"name,omitempty"` + FlavorRef string `json:"flavor_ref,omitempty"` + ImageRef string `json:"image_ref,omitempty"` + NetworkUuid string `json:"network_uuid,omitempty"` + BlockUuid string `json:"block_uuid,omitempty"` + SourceType string `json:"source_type,omitempty"` + DeleteOnTermination bool `json:"delete_on_termination,omitempty"` + State string `json:"state,omitempty"` +} + +type PushTaskInfoReq struct { + AdapterId int64 `json:"adapterId"` + HpcInfoList []*HpcInfo `json:"hpcInfoList"` + CloudInfoList []*CloudInfo `json:"cloudInfoList"` + AiInfoList []*AiInfo `json:"aiInfoList"` + VmInfoList []*VmInfo `json:"vmInfoList"` +} + +type PushTaskInfoResp struct { + Code int64 `json:"code"` + Msg string `json:"msg"` +} + +type PushResourceInfoReq struct { + AdapterId int64 `json:"adapterId"` +} + type CreateAlertRuleReq struct { CLusterId int64 `json:"clusterId"` ClusterName string `json:"clusterName"` @@ -5328,6 +5445,10 @@ type CreateAlertRuleReq struct { } type AlertRulesResp struct { + AlertRules []AlertRule `json:"alertRules"` +} + +type AlertRule struct { Id int64 `json:"id"` ClusterName string `json:"clusterName"` Name string `json:"name"` From 2929b6e0f36d6a9deda202291659bc1593514f3d Mon Sep 17 00:00:00 2001 From: zhangwei <894646498@qq.com> Date: Mon, 8 Apr 2024 09:16:52 +0800 Subject: [PATCH 13/17] alert Former-commit-id: b59e446af73f3fdbdfc9bcff0f7a6beaf6bac935 --- api/desc/monitoring/pcm-monitoring.api | 2 ++ api/internal/handler/monitoring/nodesloadtophandler.go | 7 ++----- api/internal/logic/monitoring/alertruleslogic.go | 4 +++- api/internal/logic/monitoring/nodesloadtoplogic.go | 2 +- api/internal/types/types.go | 2 ++ 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/api/desc/monitoring/pcm-monitoring.api b/api/desc/monitoring/pcm-monitoring.api index 9a09aed1..c5ff3f5a 100644 --- a/api/desc/monitoring/pcm-monitoring.api +++ b/api/desc/monitoring/pcm-monitoring.api @@ -33,6 +33,8 @@ type ( Metrics string `form:"metrics"` } nodesLoadTopResp { + code int `json:"code"` data interface{} `json:"data"` + msg string `json:"msg"` } ) \ No newline at end of file diff --git a/api/internal/handler/monitoring/nodesloadtophandler.go b/api/internal/handler/monitoring/nodesloadtophandler.go index 4c0e5925..81630285 100644 --- a/api/internal/handler/monitoring/nodesloadtophandler.go +++ b/api/internal/handler/monitoring/nodesloadtophandler.go @@ -1,6 +1,7 @@ package monitoring import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" "net/http" "github.com/zeromicro/go-zero/rest/httpx" @@ -19,10 +20,6 @@ func NodesLoadTopHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { l := monitoring.NewNodesLoadTopLogic(r.Context(), svcCtx) resp, err := l.NodesLoadTop(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } + result.HttpResult(r, w, resp, err) } } diff --git a/api/internal/logic/monitoring/alertruleslogic.go b/api/internal/logic/monitoring/alertruleslogic.go index 93d5500c..ee9eb1dc 100644 --- a/api/internal/logic/monitoring/alertruleslogic.go +++ b/api/internal/logic/monitoring/alertruleslogic.go @@ -25,6 +25,8 @@ func NewAlertRulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlertR func (l *AlertRulesLogic) AlertRules() (resp *types.AlertRulesResp, err error) { resp = &types.AlertRulesResp{} - l.svcCtx.DbEngin.Raw("SELECT ar.id,ar.*,GROUP_CONCAT(tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',') as cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id WHERE ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id;").Scan(&resp) + var alertRules []types.AlertRule + l.svcCtx.DbEngin.Raw("SELECT ar.id,ar.*,GROUP_CONCAT(tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',') as cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id WHERE ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id").Scan(&alertRules) + resp.AlertRules = alertRules return resp, nil } diff --git a/api/internal/logic/monitoring/nodesloadtoplogic.go b/api/internal/logic/monitoring/nodesloadtoplogic.go index 7efb6cd4..5a1fd7e2 100644 --- a/api/internal/logic/monitoring/nodesloadtoplogic.go +++ b/api/internal/logic/monitoring/nodesloadtoplogic.go @@ -38,7 +38,7 @@ func (l *NodesLoadTopLogic) NodesLoadTop(req *types.NodesLoadTopReq) (resp *type ForceContentType("application/json"). Get(server + "/api/v1/monitoring/node") if err != nil || response.IsError() { - + return nil, err } return resp, nil } diff --git a/api/internal/types/types.go b/api/internal/types/types.go index ddea5775..274ccf66 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -5464,5 +5464,7 @@ type NodesLoadTopReq struct { } type NodesLoadTopResp struct { + Code int `json:"code"` Data interface{} `json:"data"` + Msg string `json:"msg"` } From 5c0a3de84912d2a1d2ea5a8af58764a43f7a665a Mon Sep 17 00:00:00 2001 From: tzwang Date: Mon, 8 Apr 2024 17:25:59 +0800 Subject: [PATCH 14/17] updated pcm.api and ai storage Former-commit-id: ad231ed21f23a0c39ded7b00ae76393b76ab299f --- api/desc/pcm.api | 2 +- api/desc/schedule/pcm-schedule.api | 6 +-- api/internal/scheduler/database/aiStorage.go | 10 +++++ api/internal/scheduler/service/aiService.go | 40 ++++++++++---------- api/internal/svc/servicecontext.go | 2 +- 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/api/desc/pcm.api b/api/desc/pcm.api index ee7ffd74..6165299c 100644 --- a/api/desc/pcm.api +++ b/api/desc/pcm.api @@ -897,7 +897,7 @@ service pcm { get /schedule/ai/getStrategies returns (AiStrategyResp) @handler ScheduleGetAlgorithmsHandler - get /schedule/ai/getAlgorithms (AiAlgorithmsReq) returns (AiAlgorithmsResp) + get /schedule/ai/getAlgorithms/:resourceType/:taskType/:dataset (AiAlgorithmsReq) returns (AiAlgorithmsResp) @handler ScheduleSubmitHandler post /schedule/submit (ScheduleReq) returns (ScheduleResp) diff --git a/api/desc/schedule/pcm-schedule.api b/api/desc/schedule/pcm-schedule.api index eafba3de..8b6b2dd0 100644 --- a/api/desc/schedule/pcm-schedule.api +++ b/api/desc/schedule/pcm-schedule.api @@ -55,9 +55,9 @@ type ( } AiAlgorithmsReq { - ResourceType string `json:"resourceType"` - TaskType string `json:"taskType"` - Dataset string `json:"dataset"` + ResourceType string `path:"resourceType"` + TaskType string `path:"taskType"` + Dataset string `path:"dataset"` } AiAlgorithmsResp { diff --git a/api/internal/scheduler/database/aiStorage.go b/api/internal/scheduler/database/aiStorage.go index 670aec91..c0b706f2 100644 --- a/api/internal/scheduler/database/aiStorage.go +++ b/api/internal/scheduler/database/aiStorage.go @@ -23,6 +23,16 @@ func (s *AiStorage) GetParticipants() (*types.ClusterListResp, error) { return &resp, nil } +func (s *AiStorage) GetClustersByAdapterId(id string) (*types.ClusterListResp, error) { + var resp types.ClusterListResp + tx := s.DbEngin.Raw("select * from t_cluster where `deleted_at` IS NULL and `adapter_id` = ? ORDER BY create_time Desc", id).Scan(&resp.List) + if tx.Error != nil { + logx.Errorf(tx.Error.Error()) + return nil, tx.Error + } + return &resp, nil +} + func (s *AiStorage) SaveTask(name string) error { // 构建主任务结构体 taskModel := models.Task{ diff --git a/api/internal/scheduler/service/aiService.go b/api/internal/scheduler/service/aiService.go index 6c7b4096..aa8ded01 100644 --- a/api/internal/scheduler/service/aiService.go +++ b/api/internal/scheduler/service/aiService.go @@ -2,12 +2,14 @@ package service import ( "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/database" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/executor" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/client/imagesservice" "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/client/modelartsservice" + "strconv" ) const ( @@ -16,34 +18,30 @@ const ( SHUGUANGAI = "shuguangAi" ) -var ( - AiTypeMap = map[string]string{ - "hanwuji": OCTOPUS, - //"suiyan": OCTOPUS, - //"sailingsi": OCTOPUS, - //"modelarts-CloudBrain2": MODELARTS, - "shuguangAi": SHUGUANGAI, - } -) +func InitAiClusterMap(octopusRpc octopusclient.Octopus, modelArtsRpc modelartsservice.ModelArtsService, modelArtsImgRpc imagesservice.ImagesService, aCRpc hpcacclient.HpcAC, storages *database.AiStorage) (*map[string]executor.AiExecutor, *map[string]collector.AiCollector) { + clusters, _ := storages.GetClustersByAdapterId("1777144940459986944") -func InitAiClusterMap(octopusRpc octopusclient.Octopus, modelArtsRpc modelartsservice.ModelArtsService, modelArtsImgRpc imagesservice.ImagesService, aCRpc hpcacclient.HpcAC) (*map[string]executor.AiExecutor, *map[string]collector.AiCollector) { executorMap := make(map[string]executor.AiExecutor) collectorMap := make(map[string]collector.AiCollector) - for k, v := range AiTypeMap { - switch v { + for _, c := range clusters.List { + switch c.Name { case OCTOPUS: - octopus := storeLink.NewOctopusLink(octopusRpc, k, 0) - collectorMap[k] = octopus - executorMap[k] = octopus + id, _ := strconv.ParseInt(c.Id, 10, 64) + octopus := storeLink.NewOctopusLink(octopusRpc, c.Nickname, id) + collectorMap[c.Nickname] = octopus + executorMap[c.Nickname] = octopus case MODELARTS: - modelarts := storeLink.NewModelArtsLink(modelArtsRpc, modelArtsImgRpc, k, 0) - collectorMap[k] = modelarts - executorMap[k] = modelarts + id, _ := strconv.ParseInt(c.Id, 10, 64) + modelarts := storeLink.NewModelArtsLink(modelArtsRpc, modelArtsImgRpc, c.Nickname, id) + collectorMap[c.Nickname] = modelarts + executorMap[c.Nickname] = modelarts case SHUGUANGAI: - sgai := storeLink.NewShuguangAi(aCRpc, k, 0) - collectorMap[k] = sgai - executorMap[k] = sgai + id, _ := strconv.ParseInt(c.Id, 10, 64) + sgai := storeLink.NewShuguangAi(aCRpc, c.Nickname, id) + collectorMap[c.Nickname] = sgai + executorMap[c.Nickname] = sgai } } + return &executorMap, &collectorMap } diff --git a/api/internal/svc/servicecontext.go b/api/internal/svc/servicecontext.go index ee9510d2..ee6fc50f 100644 --- a/api/internal/svc/servicecontext.go +++ b/api/internal/svc/servicecontext.go @@ -120,8 +120,8 @@ func NewServiceContext(c config.Config) *ServiceContext { aCRpc := hpcacclient.NewHpcAC(zrpc.MustNewClient(c.ACRpcConf)) modelArtsRpc := modelartsservice.NewModelArtsService(zrpc.MustNewClient(c.ModelArtsRpcConf)) modelArtsImgRpc := imagesservice.NewImagesService(zrpc.MustNewClient(c.ModelArtsImgRpcConf)) - aiExecutor, resourceCollector := service.InitAiClusterMap(octopusRpc, modelArtsRpc, modelArtsImgRpc, aCRpc) storage := &database.AiStorage{DbEngin: dbEngin} + aiExecutor, resourceCollector := service.InitAiClusterMap(octopusRpc, modelArtsRpc, modelArtsImgRpc, aCRpc, storage) scheduler := scheduler.NewSchdlr(resourceCollector, storage, aiExecutor) return &ServiceContext{ From 42ea96a01eda21d302b6ddcdfdab362cf2c2d2b4 Mon Sep 17 00:00:00 2001 From: Jake <450705171@qq.com> Date: Mon, 8 Apr 2024 17:33:07 +0800 Subject: [PATCH 15/17] goctl generate types Former-commit-id: 22558cc63e9ad0082999bdada0c82cbd40a291e1 --- api/internal/handler/routes.go | 2 +- api/internal/types/types.go | 123 +-------------------------------- 2 files changed, 4 insertions(+), 121 deletions(-) diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index c4d6163d..aecdd7ab 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -1112,7 +1112,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { }, { Method: http.MethodGet, - Path: "/schedule/ai/getAlgorithms", + Path: "/schedule/ai/getAlgorithms/:resourceType/:taskType/:dataset", Handler: schedule.ScheduleGetAlgorithmsHandler(serverCtx), }, { diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 274ccf66..3f1c3f03 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -5307,132 +5307,15 @@ type AiStrategyResp struct { } type AiAlgorithmsReq struct { - ResourceType string `json:"resourceType"` - TaskType string `json:"taskType"` - Dataset string `json:"dataset"` + ResourceType string `path:"resourceType"` + TaskType string `path:"taskType"` + Dataset string `path:"dataset"` } type AiAlgorithmsResp struct { Algorithms []string `json:"algorithms"` } -type PullTaskInfoReq struct { - AdapterId int64 `form:"adapterId"` -} - -type PullTaskInfoResp struct { - HpcInfoList []*HpcInfo `json:"HpcInfoList,omitempty"` - CloudInfoList []*CloudInfo `json:"CloudInfoList,omitempty"` - AiInfoList []*AiInfo `json:"AiInfoList,omitempty"` - VmInfoList []*VmInfo `json:"VmInfoList,omitempty"` -} - -type HpcInfo struct { - Id int64 `json:"id"` // id - TaskId int64 `json:"task_id"` // 任务id - JobId string `json:"job_id"` // 作业id(在第三方系统中的作业id) - AdapterId int64 `json:"adapter_id"` // 执行任务的适配器id - ClusterId int64 `json:"cluster_id"` // 执行任务的集群id - ClusterType string `json:"cluster_type"` // 执行任务的集群类型 - Name string `json:"name"` // 名称 - Status string `json:"status"` // 状态 - CmdScript string `json:"cmd_script"` - StartTime string `json:"start_time"` // 开始时间 - RunningTime int64 `json:"running_time"` // 运行时间 - DerivedEs string `json:"derived_es"` - Cluster string `json:"cluster"` - BlockId int64 `json:"block_id"` - AllocNodes int64 `json:"alloc_nodes"` - AllocCpu int64 `json:"alloc_cpu"` - CardCount int64 `json:"card_count"` // 卡数 - Version string `json:"version"` - Account string `json:"account"` - WorkDir string `json:"work_dir"` // 工作路径 - AssocId int64 `json:"assoc_id"` - ExitCode int64 `json:"exit_code"` - WallTime string `json:"wall_time"` // 最大运行时间 - Result string `json:"result"` // 运行结果 - DeletedAt string `json:"deleted_at"` // 删除时间 - YamlString string `json:"yaml_string"` - AppType string `json:"app_type"` // 应用类型 - AppName string `json:"app_name"` // 应用名称 - Queue string `json:"queue"` // 队列名称 - SubmitType string `json:"submit_type"` // cmd(命令行模式) - NNode string `json:"n_node"` // 节点个数(当指定该参数时,GAP_NODE_STRING必须为"") - StdOutFile string `json:"std_out_file"` // 工作路径/std.err.%j - StdErrFile string `json:"std_err_file"` // 工作路径/std.err.%j - StdInput string `json:"std_input"` - Environment string `json:"environment"` - DeletedFlag int64 `json:"deleted_flag"` // 是否删除(0-否,1-是) - CreatedBy int64 `json:"created_by"` // 创建人 - CreatedTime string `json:"created_time"` // 创建时间 - UpdatedBy int64 `json:"updated_by"` // 更新人 - UpdatedTime string `json:"updated_time"` // 更新时间 -} - -type CloudInfo struct { - Participant int64 `json:"participant,omitempty"` - Id int64 `json:"id,omitempty"` - TaskId int64 `json:"taskId,omitempty"` - ApiVersion string `json:"apiVersion,omitempty"` - Kind string `json:"kind,omitempty"` - Namespace string `json:"namespace,omitempty"` - Name string `json:"name,omitempty"` - Status string `json:"status,omitempty"` - StartTime string `json:"startTime,omitempty"` - RunningTime int64 `json:"runningTime,omitempty"` - Result string `json:"result,omitempty"` - YamlString string `json:"yamlString,omitempty"` -} - -type AiInfo struct { - ParticipantId int64 `json:"participantId,omitempty"` - TaskId int64 `json:"taskId,omitempty"` - ProjectId string `json:"project_id,omitempty"` - Name string `json:"name,omitempty"` - Status string `json:"status,omitempty"` - StartTime string `json:"startTime,omitempty"` - RunningTime int64 `json:"runningTime,omitempty"` - Result string `json:"result,omitempty"` - JobId string `json:"jobId,omitempty"` - CreateTime string `json:"createTime,omitempty"` - ImageUrl string `json:"imageUrl,omitempty"` - Command string `json:"command,omitempty"` - FlavorId string `json:"flavorId,omitempty"` - SubscriptionId string `json:"subscriptionId,omitempty"` - ItemVersionId string `json:"itemVersionId,omitempty"` -} - -type VmInfo struct { - ParticipantId int64 `json:"participantId,omitempty"` - TaskId int64 `json:"taskId,omitempty"` - Name string `json:"name,omitempty"` - FlavorRef string `json:"flavor_ref,omitempty"` - ImageRef string `json:"image_ref,omitempty"` - NetworkUuid string `json:"network_uuid,omitempty"` - BlockUuid string `json:"block_uuid,omitempty"` - SourceType string `json:"source_type,omitempty"` - DeleteOnTermination bool `json:"delete_on_termination,omitempty"` - State string `json:"state,omitempty"` -} - -type PushTaskInfoReq struct { - AdapterId int64 `json:"adapterId"` - HpcInfoList []*HpcInfo `json:"hpcInfoList"` - CloudInfoList []*CloudInfo `json:"cloudInfoList"` - AiInfoList []*AiInfo `json:"aiInfoList"` - VmInfoList []*VmInfo `json:"vmInfoList"` -} - -type PushTaskInfoResp struct { - Code int64 `json:"code"` - Msg string `json:"msg"` -} - -type PushResourceInfoReq struct { - AdapterId int64 `json:"adapterId"` -} - type CreateAlertRuleReq struct { CLusterId int64 `json:"clusterId"` ClusterName string `json:"clusterName"` From 368fe3b2799ed2a56652b4ed551df181e0880c38 Mon Sep 17 00:00:00 2001 From: qiwang <1364512070@qq.com> Date: Tue, 9 Apr 2024 16:31:33 +0800 Subject: [PATCH 16/17] feat:Add virtual machine overview interface Former-commit-id: f7e32629352ce159909e33e7fdc0f9317cd72400 --- api/desc/core/pcm-core.api | 7 +- api/desc/pcm.api | 10 +- api/desc/vm/pcm-vm.api | 16 ++ api/internal/handler/routes.go | 10 +- .../getopenstackoverviewhandler.go} | 12 +- api/internal/logic/core/commitvmtasklogic.go | 16 +- .../logic/core/commitvmtasktemplogic.go | 49 ------ .../logic/vm/getopenstackoverviewlogic.go | 35 +++++ api/internal/types/types.go | 140 +++++++++++++++++- 9 files changed, 227 insertions(+), 68 deletions(-) rename api/internal/handler/{core/commitvmtasktemphandler.go => vm/getopenstackoverviewhandler.go} (61%) delete mode 100644 api/internal/logic/core/commitvmtasktemplogic.go create mode 100644 api/internal/logic/vm/getopenstackoverviewlogic.go diff --git a/api/desc/core/pcm-core.api b/api/desc/core/pcm-core.api index 4cdefe5e..8e844817 100644 --- a/api/desc/core/pcm-core.api +++ b/api/desc/core/pcm-core.api @@ -133,6 +133,8 @@ type ( MatchLabels map[string]string `json:"matchLabels,optional"` servers []ServerCommit `json:"servers,optional"` platform string `json:"platform,optional"` + AdapterId string `json:"adapterId,optional"` + ClusterType string `json:"clusterType,optional"` } ServerCommit { allCardRunTime string `json:"allCardRunTime"` @@ -159,7 +161,10 @@ type ( } commitVmTaskResp { - VmTask []VmTask `json:"vmTask" copier:"VmTask"` + // VmTask []VmTask `json:"vmTask" copier:"VmTask"` + TaskId int64 `json:"taskId"` + Code int32 `json:"code"` + Msg string `json:"msg"` } VmTask{ Id string `json:"id" copier:"Id"` diff --git a/api/desc/pcm.api b/api/desc/pcm.api index ab6669c7..464ca5a4 100644 --- a/api/desc/pcm.api +++ b/api/desc/pcm.api @@ -43,10 +43,6 @@ service pcm { @handler commitVmTaskHandler post /core/commitVmTask (commitVmTaskReq) returns (commitVmTaskResp) - @doc "提交虚拟机任务临时" - @handler commitVmTaskTempHandler - post /core/commitVmTaskTemp (commitVmTaskReq) returns (commitVmTaskResp) - @doc "删除任务" @handler deleteTaskHandler delete /core/deleteTask/:id (deleteTaskReq) @@ -385,10 +381,14 @@ service pcm { @handler GetNetworkNumHandler get /vm/getNetworkNum (ListNetworksReq) returns (NetworkNum) - @doc "查询镜像列表" + @doc "查询镜像数量" @handler getImageNumHandler get /vm/getImageNum (ListImagesReq) returns (ImageNum) + @doc "查询虚拟机概览数据" + @handler getOpenstackOverviewHandler + get /vm/getOpenstackOverview (OpenstackOverviewReq) returns (OpenstackOverviewResp) + @doc "查询虚拟机列表" @handler ListServerHandler get /vm/listServer (ListServersReq) returns (ListServersResp) diff --git a/api/desc/vm/pcm-vm.api b/api/desc/vm/pcm-vm.api index 28062302..eb18dc3a 100644 --- a/api/desc/vm/pcm-vm.api +++ b/api/desc/vm/pcm-vm.api @@ -75,6 +75,22 @@ type ( Msg string `json:"msg,omitempty"` ErrorMsg string `json:"errorMsg,omitempty"` } + + OpenstackOverviewReq { + Platform string `form:"platform,optional"` + } + OpenstackOverviewResp { + Data OpenstackOverview `json:"data"` + Code int32 `json:"code,omitempty"` + Msg string `json:"msg,omitempty"` + ErrorMsg string `json:"errorMsg,omitempty"` + } + OpenstackOverview { + max_total_cores int32 `json:"max_total_cores"` + max_total_ram_size int32 `json:"max_total_ram_size"` + max_total_volumes int32 `json:"max_total_volumes"` + } + ) /****************** servers start*************************/ type ( diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index 91736dbf..f4f60e67 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -45,11 +45,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/core/commitVmTask", Handler: core.CommitVmTaskHandler(serverCtx), }, - { - Method: http.MethodPost, - Path: "/core/commitVmTaskTemp", - Handler: core.CommitVmTaskTempHandler(serverCtx), - }, { Method: http.MethodDelete, Path: "/core/deleteTask/:id", @@ -456,6 +451,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/vm/getImageNum", Handler: vm.GetImageNumHandler(serverCtx), }, + { + Method: http.MethodGet, + Path: "/vm/getOpenstackOverview", + Handler: vm.GetOpenstackOverviewHandler(serverCtx), + }, { Method: http.MethodGet, Path: "/vm/listServer", diff --git a/api/internal/handler/core/commitvmtasktemphandler.go b/api/internal/handler/vm/getopenstackoverviewhandler.go similarity index 61% rename from api/internal/handler/core/commitvmtasktemphandler.go rename to api/internal/handler/vm/getopenstackoverviewhandler.go index 6167ba5c..871f814c 100644 --- a/api/internal/handler/core/commitvmtasktemphandler.go +++ b/api/internal/handler/vm/getopenstackoverviewhandler.go @@ -1,24 +1,24 @@ -package core +package vm import ( "net/http" "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" ) -func CommitVmTaskTempHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { +func GetOpenstackOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - var req types.CommitVmTaskReq + var req types.OpenstackOverviewReq if err := httpx.Parse(r, &req); err != nil { httpx.ErrorCtx(r.Context(), w, err) return } - l := core.NewCommitVmTaskTempLogic(r.Context(), svcCtx) - resp, err := l.CommitVmTaskTemp(&req) + l := vm.NewGetOpenstackOverviewLogic(r.Context(), svcCtx) + resp, err := l.GetOpenstackOverview(&req) if err != nil { httpx.ErrorCtx(r.Context(), w, err) } else { diff --git a/api/internal/logic/core/commitvmtasklogic.go b/api/internal/logic/core/commitvmtasklogic.go index 4b81af55..fd048234 100644 --- a/api/internal/logic/core/commitvmtasklogic.go +++ b/api/internal/logic/core/commitvmtasklogic.go @@ -42,6 +42,14 @@ func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *type if tx.Error != nil { return nil, tx.Error } + + var clusterIds []int64 + l.svcCtx.DbEngin.Raw("SELECT id FROM `t_cluster` where adapter_id = ? and label = ?", req.AdapterId, req.ClusterType).Scan(&clusterIds) + + if len(clusterIds) == 0 || clusterIds == nil { + return nil, nil + } + vm := models.Vm{} tool.Convert(req, &vm) mqInfo := response.TaskInfo{ @@ -52,5 +60,11 @@ func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *type } //req.TaskId = taskModel.Id mqs.InsQueue.Beta.Add(&mqInfo) - return + tx = l.svcCtx.DbEngin.Create(&mqInfo) + resp = &types.CommitVmTaskResp{ + Code: 200, + Msg: "success", + TaskId: taskModel.Id, + } + return resp, nil } diff --git a/api/internal/logic/core/commitvmtasktemplogic.go b/api/internal/logic/core/commitvmtasktemplogic.go deleted file mode 100644 index 85137007..00000000 --- a/api/internal/logic/core/commitvmtasktemplogic.go +++ /dev/null @@ -1,49 +0,0 @@ -package core - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CommitVmTaskTempLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCommitVmTaskTempLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitVmTaskTempLogic { - return &CommitVmTaskTempLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CommitVmTaskTempLogic) CommitVmTaskTemp(req *types.CommitVmTaskReq) (resp *types.CommitVmTaskResp, err error) { - // todo: add your logic here and delete this line - CreateServerReq := &openstack.CreateServerReq{} - err = copier.CopyWithOption(CreateServerReq, req, copier.Option{Converters: utils.Converters}) - CreateServerResp, err := l.svcCtx.OpenstackRpc.CreateServer(l.ctx, CreateServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateServerResp, copier.Option{Converters: utils.Converters}) - return resp, err - return -} diff --git a/api/internal/logic/vm/getopenstackoverviewlogic.go b/api/internal/logic/vm/getopenstackoverviewlogic.go new file mode 100644 index 00000000..39155fc8 --- /dev/null +++ b/api/internal/logic/vm/getopenstackoverviewlogic.go @@ -0,0 +1,35 @@ +package vm + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" +) + +type GetOpenstackOverviewLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetOpenstackOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOpenstackOverviewLogic { + return &GetOpenstackOverviewLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetOpenstackOverviewLogic) GetOpenstackOverview(req *types.OpenstackOverviewReq) (resp *types.OpenstackOverviewResp, err error) { + // todo: add your logic here and delete this line + var openstackOverview types.OpenstackOverview + sqlStr := "SELECT t.max_total_cores,t.max_total_ram_size,t.max_total_volumes FROM `vm_openstack_overview` t left join t_cluster tc on t.cluster_id=tc.id where tc.`name` = ?" + l.svcCtx.DbEngin.Raw(sqlStr, req.Platform).Scan(&openstackOverview) + resp = &types.OpenstackOverviewResp{ + Code: 200, + Msg: "success", + Data: openstackOverview, + } + return resp, err +} diff --git a/api/internal/types/types.go b/api/internal/types/types.go index d055cc65..d30c6334 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -118,6 +118,8 @@ type CommitVmTaskReq struct { MatchLabels map[string]string `json:"matchLabels,optional"` Servers []ServerCommit `json:"servers,optional"` Platform string `json:"platform,optional"` + AdapterId string `json:"adapterId,optional"` + ClusterType string `json:"clusterType,optional"` } type ServerCommit struct { @@ -147,7 +149,9 @@ type Block_device_mapping_v2Commit struct { } type CommitVmTaskResp struct { - VmTask []VmTask `json:"vmTask" copier:"VmTask"` + TaskId int64 `json:"taskId"` + Code int32 `json:"code"` + Msg string `json:"msg"` } type VmTask struct { @@ -2692,6 +2696,23 @@ type GetVolumeLimitsResp struct { ErrorMsg string `json:"errorMsg,omitempty"` } +type OpenstackOverviewReq struct { + Platform string `form:"platform,optional"` +} + +type OpenstackOverviewResp struct { + Data OpenstackOverview `json:"data"` + Code int32 `json:"code,omitempty"` + Msg string `json:"msg,omitempty"` + ErrorMsg string `json:"errorMsg,omitempty"` +} + +type OpenstackOverview struct { + Max_total_cores int32 `json:"max_total_cores"` + Max_total_ram_size int32 `json:"max_total_ram_size"` + Max_total_volumes int32 `json:"max_total_volumes"` +} + type ListServersReq struct { Limit int32 `form:"limit,optional"` OffSet int32 `form:"offSet,optional"` @@ -5311,6 +5332,123 @@ type AiAlgorithmsResp struct { Algorithms []string `json:"algorithms"` } +type PullTaskInfoReq struct { + AdapterId int64 `form:"adapterId"` +} + +type PullTaskInfoResp struct { + HpcInfoList []*HpcInfo `json:"HpcInfoList,omitempty"` + CloudInfoList []*CloudInfo `json:"CloudInfoList,omitempty"` + AiInfoList []*AiInfo `json:"AiInfoList,omitempty"` + VmInfoList []*VmInfo `json:"VmInfoList,omitempty"` +} + +type HpcInfo struct { + Id int64 `json:"id"` // id + TaskId int64 `json:"task_id"` // 任务id + JobId string `json:"job_id"` // 作业id(在第三方系统中的作业id) + AdapterId int64 `json:"adapter_id"` // 执行任务的适配器id + ClusterId int64 `json:"cluster_id"` // 执行任务的集群id + ClusterType string `json:"cluster_type"` // 执行任务的集群类型 + Name string `json:"name"` // 名称 + Status string `json:"status"` // 状态 + CmdScript string `json:"cmd_script"` + StartTime string `json:"start_time"` // 开始时间 + RunningTime int64 `json:"running_time"` // 运行时间 + DerivedEs string `json:"derived_es"` + Cluster string `json:"cluster"` + BlockId int64 `json:"block_id"` + AllocNodes int64 `json:"alloc_nodes"` + AllocCpu int64 `json:"alloc_cpu"` + CardCount int64 `json:"card_count"` // 卡数 + Version string `json:"version"` + Account string `json:"account"` + WorkDir string `json:"work_dir"` // 工作路径 + AssocId int64 `json:"assoc_id"` + ExitCode int64 `json:"exit_code"` + WallTime string `json:"wall_time"` // 最大运行时间 + Result string `json:"result"` // 运行结果 + DeletedAt string `json:"deleted_at"` // 删除时间 + YamlString string `json:"yaml_string"` + AppType string `json:"app_type"` // 应用类型 + AppName string `json:"app_name"` // 应用名称 + Queue string `json:"queue"` // 队列名称 + SubmitType string `json:"submit_type"` // cmd(命令行模式) + NNode string `json:"n_node"` // 节点个数(当指定该参数时,GAP_NODE_STRING必须为"") + StdOutFile string `json:"std_out_file"` // 工作路径/std.err.%j + StdErrFile string `json:"std_err_file"` // 工作路径/std.err.%j + StdInput string `json:"std_input"` + Environment string `json:"environment"` + DeletedFlag int64 `json:"deleted_flag"` // 是否删除(0-否,1-是) + CreatedBy int64 `json:"created_by"` // 创建人 + CreatedTime string `json:"created_time"` // 创建时间 + UpdatedBy int64 `json:"updated_by"` // 更新人 + UpdatedTime string `json:"updated_time"` // 更新时间 +} + +type CloudInfo struct { + Participant int64 `json:"participant,omitempty"` + Id int64 `json:"id,omitempty"` + TaskId int64 `json:"taskId,omitempty"` + ApiVersion string `json:"apiVersion,omitempty"` + Kind string `json:"kind,omitempty"` + Namespace string `json:"namespace,omitempty"` + Name string `json:"name,omitempty"` + Status string `json:"status,omitempty"` + StartTime string `json:"startTime,omitempty"` + RunningTime int64 `json:"runningTime,omitempty"` + Result string `json:"result,omitempty"` + YamlString string `json:"yamlString,omitempty"` +} + +type AiInfo struct { + ParticipantId int64 `json:"participantId,omitempty"` + TaskId int64 `json:"taskId,omitempty"` + ProjectId string `json:"project_id,omitempty"` + Name string `json:"name,omitempty"` + Status string `json:"status,omitempty"` + StartTime string `json:"startTime,omitempty"` + RunningTime int64 `json:"runningTime,omitempty"` + Result string `json:"result,omitempty"` + JobId string `json:"jobId,omitempty"` + CreateTime string `json:"createTime,omitempty"` + ImageUrl string `json:"imageUrl,omitempty"` + Command string `json:"command,omitempty"` + FlavorId string `json:"flavorId,omitempty"` + SubscriptionId string `json:"subscriptionId,omitempty"` + ItemVersionId string `json:"itemVersionId,omitempty"` +} + +type VmInfo struct { + ParticipantId int64 `json:"participantId,omitempty"` + TaskId int64 `json:"taskId,omitempty"` + Name string `json:"name,omitempty"` + FlavorRef string `json:"flavor_ref,omitempty"` + ImageRef string `json:"image_ref,omitempty"` + NetworkUuid string `json:"network_uuid,omitempty"` + BlockUuid string `json:"block_uuid,omitempty"` + SourceType string `json:"source_type,omitempty"` + DeleteOnTermination bool `json:"delete_on_termination,omitempty"` + State string `json:"state,omitempty"` +} + +type PushTaskInfoReq struct { + AdapterId int64 `json:"adapterId"` + HpcInfoList []*HpcInfo `json:"hpcInfoList"` + CloudInfoList []*CloudInfo `json:"cloudInfoList"` + AiInfoList []*AiInfo `json:"aiInfoList"` + VmInfoList []*VmInfo `json:"vmInfoList"` +} + +type PushTaskInfoResp struct { + Code int64 `json:"code"` + Msg string `json:"msg"` +} + +type PushResourceInfoReq struct { + AdapterId int64 `json:"adapterId"` +} + type CreateAlertRuleReq struct { ClusterName string `json:"clusterName"` Namespace string `json:"namespace"` From 5da458b1a682d2ef463fab8c8478cb1c1d755322 Mon Sep 17 00:00:00 2001 From: jagger Date: Wed, 10 Apr 2024 09:39:11 +0800 Subject: [PATCH 17/17] fix dict bugs Signed-off-by: jagger Former-commit-id: 12dde250bf03664513668fd7e5506796de2934bc --- api/desc/core/pcm-core.api | 3 --- api/internal/logic/dictionary/adddictitemlogic.go | 3 +-- api/internal/logic/dictionary/editdictitemlogic.go | 2 +- api/internal/logic/dictionary/editdictlogic.go | 2 +- api/internal/logic/dictionary/listdictitembycodelogic.go | 8 +++++--- api/internal/types/types.go | 3 --- 6 files changed, 8 insertions(+), 13 deletions(-) diff --git a/api/desc/core/pcm-core.api b/api/desc/core/pcm-core.api index c748d77b..81db75ae 100644 --- a/api/desc/core/pcm-core.api +++ b/api/desc/core/pcm-core.api @@ -817,7 +817,6 @@ type ( ItemValue string `json:"itemValue,omitempty"` Description string `json:"description,omitempty"` SortOrder string `json:"sortOrder,omitempty"` - Type string `json:"type,omitempty" db:"type"` ParentId string `json:"parentId,omitempty"` Status string `json:"status,omitempty" db:"status"` CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"` @@ -843,7 +842,6 @@ type ( ItemValue string `json:"itemValue,optional"` Description string `json:"description,optional"` SortOrder string `json:"sortOrder,optional"` - Type string `json:"type,optional"` ParentId string `json:"parentId,optional"` Status string `json:"status,optional"` } @@ -855,7 +853,6 @@ type ( ItemValue string `json:"itemValue,omitempty"` Description string `json:"description,omitempty"` SortOrder string `json:"sortOrder,omitempty"` - Type string `json:"type,omitempty"` ParentId string `json:"parentId,omitempty"` Status string `json:"status,omitempty"` CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"` diff --git a/api/internal/logic/dictionary/adddictitemlogic.go b/api/internal/logic/dictionary/adddictitemlogic.go index 22f8f667..11892d8e 100644 --- a/api/internal/logic/dictionary/adddictitemlogic.go +++ b/api/internal/logic/dictionary/adddictitemlogic.go @@ -39,11 +39,10 @@ func (l *AddDictItemLogic) AddDictItem(req *types.DictItemEditReq) (resp *types. dictItem.ItemValue = req.ItemValue dictItem.Description = req.Description dictItem.SortOrder = req.SortOrder - dictItem.Type = req.Type + dictItem.ParentId = "0" if req.ParentId != "" { dictItem.ParentId = req.ParentId } - dictItem.ParentId = "0" dictItem.Status = req.Status dictItem.Id = utils.GenSnowflakeIDStr() dictItem.CreateTime = time.Now().Format("2006-01-02 15:04:05") diff --git a/api/internal/logic/dictionary/editdictitemlogic.go b/api/internal/logic/dictionary/editdictitemlogic.go index b09de93b..60cadbd0 100644 --- a/api/internal/logic/dictionary/editdictitemlogic.go +++ b/api/internal/logic/dictionary/editdictitemlogic.go @@ -30,7 +30,7 @@ func (l *EditDictItemLogic) EditDictItem(req *types.DictItemEditReq) (resp *type dictItem := &types.DictItemInfo{} result := l.svcCtx.DbEngin.Table("t_dict_item").First(&dictItem, req.Id) if errors.Is(result.Error, gorm.ErrRecordNotFound) { - logx.Errorf("Dictionary data editing failure. errors: %s", err.Error()) + logx.Errorf("Dictionary data editing failure. errors: %s", result.Error) return nil, errors.New("DictItem does not exist") } utils.Convert(req, &dictItem) diff --git a/api/internal/logic/dictionary/editdictlogic.go b/api/internal/logic/dictionary/editdictlogic.go index a9323e29..735718a2 100644 --- a/api/internal/logic/dictionary/editdictlogic.go +++ b/api/internal/logic/dictionary/editdictlogic.go @@ -31,7 +31,7 @@ func (l *EditDictLogic) EditDict(req *types.DictEditReq) (resp *types.DictResp, dict := &types.DictInfo{} result := l.svcCtx.DbEngin.Table("t_dict").First(&dict, req.Id) if errors.Is(result.Error, gorm.ErrRecordNotFound) { - logx.Errorf("Dictionary editing failure. errors: %s", err.Error()) + logx.Errorf("Dictionary editing failure. errors: %s", result.Error) return nil, errors.New("Dict does not exist") } utils.Convert(req, &dict) diff --git a/api/internal/logic/dictionary/listdictitembycodelogic.go b/api/internal/logic/dictionary/listdictitembycodelogic.go index b8eb2331..0fd16b86 100644 --- a/api/internal/logic/dictionary/listdictitembycodelogic.go +++ b/api/internal/logic/dictionary/listdictitembycodelogic.go @@ -2,6 +2,7 @@ package dictionary import ( "context" + "github.com/pkg/errors" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" @@ -29,12 +30,13 @@ func (l *ListDictItemByCodeLogic) ListDictItemByCode(req *types.DictCodeReq) (re db := l.svcCtx.DbEngin.Model(&types.DictInfo{}).Table("t_dict") // 左连接查询 - db.Select("t_dict_item.*").Joins("left join t_dict_item on t_dict.id = t_dict_item.dict_id"). + err = db.Select("t_dict_item.*").Joins("left join t_dict_item on t_dict.id = t_dict_item.dict_id"). Where("t_dict.dict_code = ?", req.DictCode). Where("t_dict_item.status", 1). - Order("t_dict_item.sort_order").Scan(&dictList) + Order("t_dict_item.sort_order").Scan(&dictList).Error if err != nil { - return resp, err + logx.Errorf("ListDictItemByCode()=> failed %s", err.Error()) + return nil, errors.New("description Failed to query dictionary entry data") } resp.List = dictList return resp, nil diff --git a/api/internal/types/types.go b/api/internal/types/types.go index f6c8363f..9fdcc9df 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -791,7 +791,6 @@ type DictItemInfo struct { ItemValue string `json:"itemValue,omitempty"` Description string `json:"description,omitempty"` SortOrder string `json:"sortOrder,omitempty"` - Type string `json:"type,omitempty" db:"type"` ParentId string `json:"parentId,omitempty"` Status string `json:"status,omitempty" db:"status"` CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"` @@ -817,7 +816,6 @@ type DictItemEditReq struct { ItemValue string `json:"itemValue,optional"` Description string `json:"description,optional"` SortOrder string `json:"sortOrder,optional"` - Type string `json:"type,optional"` ParentId string `json:"parentId,optional"` Status string `json:"status,optional"` } @@ -829,7 +827,6 @@ type DictItemResp struct { ItemValue string `json:"itemValue,omitempty"` Description string `json:"description,omitempty"` SortOrder string `json:"sortOrder,omitempty"` - Type string `json:"type,omitempty"` ParentId string `json:"parentId,omitempty"` Status string `json:"status,omitempty"` CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`