forked from JointCloud/pcm-coordinator
Add task details
Signed-off-by: jagger <cossjie@foxmail.com>
This commit is contained in:
parent
71b2870ead
commit
570946ed48
|
@ -1099,4 +1099,14 @@ type TaskStatusResp {
|
|||
Failed int `json:"Failed"`
|
||||
Running int `json:"Running"`
|
||||
Pause int `json:"Pause"`
|
||||
}
|
||||
|
||||
type TaskDetailsResp {
|
||||
Name string `json:"name"`
|
||||
description string `json:"description"`
|
||||
StartTime string `json:"startTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
Strategy int64 `json:"strategy,string"`
|
||||
SynergyStatus int64 `json:"synergyStatus,string"`
|
||||
ClusterInfos []*ClusterInfo `json:"clusterInfos"`
|
||||
}
|
|
@ -142,9 +142,9 @@ service pcm {
|
|||
@handler homeOverviewHandler
|
||||
get /core/homeOverview (HomeOverviewReq) returns (HomeOverviewResp)
|
||||
|
||||
@doc "task details"
|
||||
@handler taskDetails
|
||||
get /core/task/details (CId) returns(TaskStatusResp)
|
||||
@doc "task details"
|
||||
@handler taskDetails
|
||||
get /core/task/details (FId) returns(TaskDetailsResp)
|
||||
}
|
||||
|
||||
//hpc二级接口
|
||||
|
@ -218,7 +218,7 @@ service pcm {
|
|||
|
||||
@doc "Create cloud computing common tasks"
|
||||
@handler commitGeneralTask
|
||||
post /cloud/task/create (GeneralTaskReq) returns()
|
||||
post /cloud/task/create (GeneralTaskReq) returns ()
|
||||
}
|
||||
|
||||
//智算二级接口
|
||||
|
@ -986,7 +986,7 @@ service pcm {
|
|||
|
||||
@doc "alert rules"
|
||||
@handler alertRulesHandler
|
||||
get /monitoring/alert/rule (AlertRulesReq)returns (AlertRulesResp)
|
||||
get /monitoring/alert/rule (AlertRulesReq) returns (AlertRulesResp)
|
||||
|
||||
@doc "cluster resource load"
|
||||
@handler clustersLoadHandler
|
||||
|
@ -1004,9 +1004,9 @@ service pcm {
|
|||
@handler syncClusterAlertHandler
|
||||
post /core/syncClusterAlert (SyncClusterAlertReq)
|
||||
|
||||
@handler taskNumHandler
|
||||
get /monitoring/task/num (taskNumReq) returns (taskNumResp)
|
||||
@handler taskNumHandler
|
||||
get /monitoring/task/num (taskNumReq) returns (taskNumResp)
|
||||
|
||||
@handler adapterInfoHandler
|
||||
get /monitoring/adapter/info (adapterInfoReq) returns (adapterInfoResp)
|
||||
@handler adapterInfoHandler
|
||||
get /monitoring/adapter/info (adapterInfoReq) returns (adapterInfoResp)
|
||||
}
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
func TaskDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CId
|
||||
var req types.FId
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
|
|
|
@ -1259,7 +1259,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/monitoring/syncClusterAlert",
|
||||
Path: "/core/syncClusterAlert",
|
||||
Handler: monitoring.SyncClusterAlertHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
|
|
|
@ -26,11 +26,36 @@ func NewTaskDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TaskD
|
|||
}
|
||||
}
|
||||
|
||||
func (l *TaskDetailsLogic) TaskDetails(req *types.CId) (resp *types.TaskStatusResp, err error) {
|
||||
func (l *TaskDetailsLogic) TaskDetails(req *types.FId) (resp *types.TaskDetailsResp, err error) {
|
||||
|
||||
var task models.Task
|
||||
if errors.Is(l.svcCtx.DbEngin.Where("id", req.Id).First(&task).Error, gorm.ErrRecordNotFound) {
|
||||
return nil, errors.New("记录不存在")
|
||||
}
|
||||
|
||||
clusterIds := make([]int64, 0)
|
||||
var cList []*types.ClusterInfo
|
||||
switch task.TaskTypeDict {
|
||||
case 0:
|
||||
l.svcCtx.DbEngin.Table("task_cloud").Select("cluster_id").Where("task_id", task.Id).Scan(&clusterIds)
|
||||
case 1:
|
||||
l.svcCtx.DbEngin.Table("task_ai").Select("cluster_id").Where("task_id", task.Id).Scan(&clusterIds)
|
||||
case 2:
|
||||
l.svcCtx.DbEngin.Table("task_hpc").Select("cluster_id").Where("task_id", task.Id).Scan(&clusterIds)
|
||||
case 3:
|
||||
l.svcCtx.DbEngin.Table("task_vm").Select("cluster_id").Where("task_id", task.Id).Find(&clusterIds)
|
||||
}
|
||||
err = l.svcCtx.DbEngin.Table("t_cluster").Where("id in ?", clusterIds).Scan(&cList).Error
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
resp = &types.TaskDetailsResp{
|
||||
Name: task.Name,
|
||||
Description: task.Description,
|
||||
StartTime: task.StartTime,
|
||||
EndTime: task.EndTime,
|
||||
Strategy: task.Strategy,
|
||||
SynergyStatus: task.SynergyStatus,
|
||||
ClusterInfos: cList,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package option
|
||||
|
||||
type CloudOption struct {
|
||||
task interface{}
|
||||
Name string `json:"name"`
|
||||
AdapterIds []string `json:"adapterIds"`
|
||||
ClusterIds []string `json:"clusterIds"`
|
||||
Strategy string `json:"strategy"`
|
||||
StaticWeightMap map[string]int32 `json:"staticWeightMap,optional"`
|
||||
ReqBody []string `json:"reqBody"`
|
||||
}
|
||||
|
||||
func (c CloudOption) GetOptionType() string {
|
||||
|
|
|
@ -1064,6 +1064,16 @@ type TaskStatusResp struct {
|
|||
Pause int `json:"Pause"`
|
||||
}
|
||||
|
||||
type TaskDetailsResp struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
StartTime string `json:"startTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
Strategy int64 `json:"strategy,string"`
|
||||
SynergyStatus int64 `json:"synergyStatus,string"`
|
||||
ClusterInfos []*ClusterInfo `json:"clusterInfos"`
|
||||
}
|
||||
|
||||
type CommitHpcTaskReq struct {
|
||||
Name string `json:"name"` // paratera:jobName
|
||||
Description string `json:"description,optional"`
|
||||
|
|
|
@ -49,6 +49,7 @@ type (
|
|||
Result string `db:"result"` // 作业结果
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
NsID string `db:"ns_id"`
|
||||
TaskTypeDict int `db:"task_type_dict"` //任务类型(对应字典表的值)
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue