Merge remote-tracking branch 'origin/master'
Former-commit-id: 8efc2320a5c1eb935b1f8ede5e6de91ff5da3480
This commit is contained in:
commit
2cb3826f64
|
@ -59,23 +59,21 @@ func (l *DeployInstanceListLogic) DeployInstanceList(req *types.DeployInstanceLi
|
||||||
}
|
}
|
||||||
list := common.ConcatMultipleSlices(slices)
|
list := common.ConcatMultipleSlices(slices)
|
||||||
|
|
||||||
if len(list) == 0 {
|
if len(list) != 0 {
|
||||||
return
|
go updater.UpdateDeployInstanceStatusBatch(l.svcCtx, list)
|
||||||
}
|
|
||||||
|
|
||||||
go updater.UpdateDeployInstanceStatusBatch(l.svcCtx, list)
|
ins := list[0]
|
||||||
|
for i := range list {
|
||||||
ins := list[0]
|
uTime, _ := time.Parse(time.RFC3339, ins.UpdateTime)
|
||||||
for i := range list {
|
latest, _ := time.Parse(time.RFC3339, list[i].UpdateTime)
|
||||||
uTime, _ := time.Parse(time.RFC3339, ins.UpdateTime)
|
if latest.After(uTime) {
|
||||||
latest, _ := time.Parse(time.RFC3339, list[i].UpdateTime)
|
ins = list[i]
|
||||||
if latest.After(uTime) {
|
}
|
||||||
ins = list[i]
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
go updater.UpdateDeployInstanceStatus(l.svcCtx, ins, true)
|
go updater.UpdateDeployInstanceStatus(l.svcCtx, ins, true)
|
||||||
go updater.UpdateDeployTaskStatus(l.svcCtx)
|
go updater.UpdateDeployTaskStatus(l.svcCtx)
|
||||||
|
}
|
||||||
|
|
||||||
resp.List = &deployTasks
|
resp.List = &deployTasks
|
||||||
resp.PageSize = req.PageSize
|
resp.PageSize = req.PageSize
|
||||||
|
|
|
@ -3,6 +3,8 @@ package inference
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||||
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||||
|
@ -36,6 +38,47 @@ func (l *GetDeployTasksByTypeLogic) GetDeployTasksByType(req *types.GetDeployTas
|
||||||
return nil, errors.New("实列不存在")
|
return nil, errors.New("实列不存在")
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.List = list
|
listcopy := make([]*models.AiDeployInstanceTask, len(list))
|
||||||
|
copy(listcopy, list)
|
||||||
|
|
||||||
|
for _, task := range list {
|
||||||
|
inslist, err := l.svcCtx.Scheduler.AiStorages.GetInstanceListByDeployTaskId(task.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(inslist) == 0 {
|
||||||
|
removeItem(&listcopy, task.Id)
|
||||||
|
}
|
||||||
|
var count int
|
||||||
|
for _, ins := range inslist {
|
||||||
|
if ins.Status == constants.Running {
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if count >= 1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
removeItem(&listcopy, task.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.List = listcopy
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeItem(items *[]*models.AiDeployInstanceTask, id int64) {
|
||||||
|
if len(*items) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(*items) == 1 {
|
||||||
|
if (*items)[0].Id == id {
|
||||||
|
(*items) = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i := len(*items) - 1; i >= 0; i-- {
|
||||||
|
if (*items)[i].Id == id {
|
||||||
|
*items = append((*items)[:i], (*items)[i+1:]...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -136,6 +136,7 @@ func (l *ImageInferenceLogic) ImageInfer(r *http.Request, req *types.ImageInfere
|
||||||
return nil, errors.New("clusters is nil")
|
return nil, errors.New("clusters is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//remove empty replica
|
||||||
for i := len(clusters) - 1; i >= 0; i-- {
|
for i := len(clusters) - 1; i >= 0; i-- {
|
||||||
if clusters[i].Replicas == 0 {
|
if clusters[i].Replicas == 0 {
|
||||||
clusters = append(clusters[:i], clusters[i+1:]...)
|
clusters = append(clusters[:i], clusters[i+1:]...)
|
||||||
|
|
Loading…
Reference in New Issue