Merge remote-tracking branch 'origin/master'

Former-commit-id: c797cc12a5
This commit is contained in:
qiwang 2024-07-26 10:25:50 +08:00
commit 658fedaad6
4 changed files with 22 additions and 8 deletions

View File

@ -4,9 +4,11 @@ import (
"context"
"errors"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/updater"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"time"
)
type DeployInstanceListLogic struct {
@ -36,6 +38,17 @@ func (l *DeployInstanceListLogic) DeployInstanceList(req *types.DeployInstanceLi
return nil, tx.Error
}
ins := list[0]
for i := range list {
last, _ := time.Parse(time.RFC3339, ins.UpdateTime)
latest, _ := time.Parse(time.RFC3339, list[i].UpdateTime)
if latest.After(last) {
ins = list[i]
}
}
go updater.UpdateDeployInstanceStatus(l.svcCtx, ins)
//count total
var total int64
err = tx.Count(&total).Error

View File

@ -26,6 +26,10 @@ func NewStartDeployInstanceListLogic(ctx context.Context, svcCtx *svc.ServiceCon
func (l *StartDeployInstanceListLogic) StartDeployInstanceList(req *types.StartDeployInstanceReq) (resp *types.StartDeployInstanceResp, err error) {
resp = &types.StartDeployInstanceResp{}
success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[req.AdapterId][req.ClusterId].StartInferDeployInstance(l.ctx, req.InstanceId)
if !success {
return nil, errors.New("start instance failed")
}
id, err := strconv.ParseInt(req.Id, 10, 64)
ins, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceById(id)
if err != nil {
@ -34,9 +38,5 @@ func (l *StartDeployInstanceListLogic) StartDeployInstanceList(req *types.StartD
l.svcCtx.Scheduler.AiStorages.UpdateInferDeployInstance(ins)
if !success {
return nil, errors.New("start instance failed")
}
return resp, nil
}

View File

@ -26,6 +26,10 @@ func NewStopDeployInstanceLogic(ctx context.Context, svcCtx *svc.ServiceContext)
func (l *StopDeployInstanceLogic) StopDeployInstance(req *types.StopDeployInstanceReq) (resp *types.StopDeployInstanceResp, err error) {
resp = &types.StopDeployInstanceResp{}
success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[req.AdapterId][req.ClusterId].StopInferDeployInstance(l.ctx, req.InstanceId)
if !success {
return nil, errors.New("stop instance failed")
}
id, err := strconv.ParseInt(req.Id, 10, 64)
ins, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceById(id)
if err != nil {
@ -34,8 +38,5 @@ func (l *StopDeployInstanceLogic) StopDeployInstance(req *types.StopDeployInstan
l.svcCtx.Scheduler.AiStorages.UpdateInferDeployInstance(ins)
if !success {
return nil, errors.New("stop instance failed")
}
return resp, nil
}

View File

@ -481,7 +481,7 @@ func (s *AiStorage) GetTrainingTaskTotalNum() (int32, error) {
func (s *AiStorage) GetTrainingTaskRunningNum() (int32, error) {
var total int32
tx := s.DbEngin.Raw("select count(*) from task where `task_type_dict` = 11 and `status` = 'Running'").Scan(&total)
tx := s.DbEngin.Raw("select count(*) from task where `task_type_dict` = 10 and `status` = 'Running'").Scan(&total)
if tx.Error != nil {
logx.Errorf(tx.Error.Error())
return 0, tx.Error