Add task details
Signed-off-by: jagger <cossjie@foxmail.com> Former-commit-id: 570946ed4885c23913cc81e64098437e338f8f23
This commit is contained in:
parent
ec5a02955d
commit
8aba7624a6
|
@ -1099,4 +1099,14 @@ type TaskStatusResp {
|
||||||
Failed int `json:"Failed"`
|
Failed int `json:"Failed"`
|
||||||
Running int `json:"Running"`
|
Running int `json:"Running"`
|
||||||
Pause int `json:"Pause"`
|
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
|
@handler homeOverviewHandler
|
||||||
get /core/homeOverview (HomeOverviewReq) returns (HomeOverviewResp)
|
get /core/homeOverview (HomeOverviewReq) returns (HomeOverviewResp)
|
||||||
|
|
||||||
@doc "task details"
|
@doc "task details"
|
||||||
@handler taskDetails
|
@handler taskDetails
|
||||||
get /core/task/details (CId) returns(TaskStatusResp)
|
get /core/task/details (FId) returns(TaskDetailsResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//hpc二级接口
|
//hpc二级接口
|
||||||
|
@ -218,7 +218,7 @@ service pcm {
|
||||||
|
|
||||||
@doc "Create cloud computing common tasks"
|
@doc "Create cloud computing common tasks"
|
||||||
@handler commitGeneralTask
|
@handler commitGeneralTask
|
||||||
post /cloud/task/create (GeneralTaskReq) returns()
|
post /cloud/task/create (GeneralTaskReq) returns ()
|
||||||
}
|
}
|
||||||
|
|
||||||
//智算二级接口
|
//智算二级接口
|
||||||
|
@ -986,7 +986,7 @@ service pcm {
|
||||||
|
|
||||||
@doc "alert rules"
|
@doc "alert rules"
|
||||||
@handler alertRulesHandler
|
@handler alertRulesHandler
|
||||||
get /monitoring/alert/rule (AlertRulesReq)returns (AlertRulesResp)
|
get /monitoring/alert/rule (AlertRulesReq) returns (AlertRulesResp)
|
||||||
|
|
||||||
@doc "cluster resource load"
|
@doc "cluster resource load"
|
||||||
@handler clustersLoadHandler
|
@handler clustersLoadHandler
|
||||||
|
@ -1004,9 +1004,9 @@ service pcm {
|
||||||
@handler syncClusterAlertHandler
|
@handler syncClusterAlertHandler
|
||||||
post /core/syncClusterAlert (SyncClusterAlertReq)
|
post /core/syncClusterAlert (SyncClusterAlertReq)
|
||||||
|
|
||||||
@handler taskNumHandler
|
@handler taskNumHandler
|
||||||
get /monitoring/task/num (taskNumReq) returns (taskNumResp)
|
get /monitoring/task/num (taskNumReq) returns (taskNumResp)
|
||||||
|
|
||||||
@handler adapterInfoHandler
|
@handler adapterInfoHandler
|
||||||
get /monitoring/adapter/info (adapterInfoReq) returns (adapterInfoResp)
|
get /monitoring/adapter/info (adapterInfoReq) returns (adapterInfoResp)
|
||||||
}
|
}
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
func TaskDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func TaskDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.CId
|
var req types.FId
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
result.ParamErrorResult(r, w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -1259,7 +1259,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodPost,
|
Method: http.MethodPost,
|
||||||
Path: "/monitoring/syncClusterAlert",
|
Path: "/core/syncClusterAlert",
|
||||||
Handler: monitoring.SyncClusterAlertHandler(serverCtx),
|
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
|
var task models.Task
|
||||||
if errors.Is(l.svcCtx.DbEngin.Where("id", req.Id).First(&task).Error, gorm.ErrRecordNotFound) {
|
if errors.Is(l.svcCtx.DbEngin.Where("id", req.Id).First(&task).Error, gorm.ErrRecordNotFound) {
|
||||||
return nil, errors.New("记录不存在")
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package option
|
package option
|
||||||
|
|
||||||
type CloudOption struct {
|
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 {
|
func (c CloudOption) GetOptionType() string {
|
||||||
|
|
|
@ -1064,6 +1064,16 @@ type TaskStatusResp struct {
|
||||||
Pause int `json:"Pause"`
|
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 {
|
type CommitHpcTaskReq struct {
|
||||||
Name string `json:"name"` // paratera:jobName
|
Name string `json:"name"` // paratera:jobName
|
||||||
Description string `json:"description,optional"`
|
Description string `json:"description,optional"`
|
||||||
|
|
|
@ -49,6 +49,7 @@ type (
|
||||||
Result string `db:"result"` // 作业结果
|
Result string `db:"result"` // 作业结果
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
NsID string `db:"ns_id"`
|
NsID string `db:"ns_id"`
|
||||||
|
TaskTypeDict int `db:"task_type_dict"` //任务类型(对应字典表的值)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue