Merge pull request 'fix' (#140) from devad/pcm-coordinator:master into master
Former-commit-id: 0a4bd04078cae7d9715f41bd5a4216d253a9fb08
This commit is contained in:
commit
40b55c952f
|
@ -354,6 +354,7 @@ type (
|
|||
NsID string `json:"nsId,omitempty" db:"ns_id"`
|
||||
TenantId string `json:"tenantId,omitempty" db:"tenant_id"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
||||
AdapterTypeDict int `json:"adapterTypeDict" db:"create_time" gorm:"adapter_type_dict"` //任务类型(对应字典表的值
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -89,14 +89,14 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er
|
|||
//查询调度策略
|
||||
err = tx.Raw(sqlStr, req.Strategy).Scan(&strategy).Error
|
||||
taskModel := models.Task{
|
||||
Id: utils.GenSnowflakeID(),
|
||||
Status: constants.Pending,
|
||||
Name: req.Name,
|
||||
CommitTime: time.Now(),
|
||||
YamlString: strings.Join(req.ReqBody, "\n---\n"),
|
||||
TaskTypeDict: 0,
|
||||
SynergyStatus: synergyStatus,
|
||||
Strategy: strategy,
|
||||
Id: utils.GenSnowflakeID(),
|
||||
Status: constants.Saved,
|
||||
Name: req.Name,
|
||||
CommitTime: time.Now(),
|
||||
YamlString: strings.Join(req.ReqBody, "\n---\n"),
|
||||
AdapterTypeDict: 0,
|
||||
SynergyStatus: synergyStatus,
|
||||
Strategy: strategy,
|
||||
}
|
||||
var taskClouds []cloud.TaskCloudModel
|
||||
for _, r := range rs {
|
||||
|
@ -109,7 +109,7 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er
|
|||
taskCloud.AdapterId = uint(adapterId)
|
||||
taskCloud.ClusterId = uint(clusterId)
|
||||
taskCloud.ClusterName = r.ClusterName
|
||||
taskCloud.Status = constants.Pending
|
||||
taskCloud.Status = constants.Saved
|
||||
taskCloud.YamlString = string(unString)
|
||||
taskCloud.Kind = sStruct.GetKind()
|
||||
taskCloud.Namespace = sStruct.GetNamespace()
|
||||
|
|
|
@ -30,7 +30,7 @@ func (l *CountTaskStatusLogic) CountTaskStatus() (resp *types.TaskStatusResp, er
|
|||
COUNT(CASE WHEN status = 'Succeeded' THEN 1 END) AS Succeeded,
|
||||
COUNT(CASE WHEN status = 'Failed' THEN 1 END) AS Failed,
|
||||
COUNT(CASE WHEN status = 'Running' THEN 1 END) AS Running,
|
||||
COUNT(CASE WHEN status = 'Pause' THEN 1 END) AS Pause
|
||||
COUNT(CASE WHEN status = 'Saved' THEN 1 END) AS Saved
|
||||
FROM task;`
|
||||
err = l.svcCtx.DbEngin.Raw(sqlStr).Scan(&resp).Error
|
||||
if err != nil {
|
||||
|
|
|
@ -3,6 +3,7 @@ package core
|
|||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/timeutils"
|
||||
"time"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
|
@ -49,16 +50,15 @@ func (l *PageListTaskLogic) PageListTask(req *types.PageTaskReq) (resp *types.Pa
|
|||
if err != nil {
|
||||
return nil, result.NewDefaultError(err.Error())
|
||||
}
|
||||
const layout = "2006-01-02 15:04:05"
|
||||
for _, model := range list {
|
||||
if model.EndTime != "" && model.StartTime != "" {
|
||||
starTime, _ := time.Parse(layout, model.StartTime)
|
||||
endTime, _ := time.Parse(layout, model.EndTime)
|
||||
model.RunningTime = int64(endTime.Sub(starTime).Seconds())
|
||||
startTime := timeutils.TimeStringToGoTime(model.StartTime)
|
||||
endTime := timeutils.TimeStringToGoTime(model.EndTime)
|
||||
model.RunningTime = int64(endTime.Sub(startTime).Seconds())
|
||||
}
|
||||
if model.StartTime != "" {
|
||||
starTime, _ := time.Parse(layout, model.StartTime)
|
||||
model.RunningTime = int64(time.Now().Sub(starTime).Seconds())
|
||||
startTime := timeutils.TimeStringToGoTime(model.StartTime)
|
||||
model.RunningTime = int64(time.Now().Sub(startTime).Seconds())
|
||||
}
|
||||
}
|
||||
resp.List = &list
|
||||
|
|
|
@ -34,7 +34,7 @@ func (l *TaskDetailsLogic) TaskDetails(req *types.FId) (resp *types.TaskDetailsR
|
|||
}
|
||||
clusterIds := make([]int64, 0)
|
||||
var cList []*types.ClusterInfo
|
||||
switch task.TaskTypeDict {
|
||||
switch task.AdapterTypeDict {
|
||||
case 0:
|
||||
l.svcCtx.DbEngin.Table("task_cloud").Select("cluster_id").Where("task_id", task.Id).Scan(&clusterIds)
|
||||
case 1:
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy/param"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models/cloud"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
||||
|
@ -60,7 +61,7 @@ func (as *CloudScheduler) GetNewStructForDb(task *response.TaskInfo, resource st
|
|||
c := cloud.TaskCloudModel{
|
||||
AdapterId: uint(participantId),
|
||||
TaskId: uint(task.TaskId),
|
||||
Status: "Pending",
|
||||
Status: constants.Saved,
|
||||
YamlString: as.yamlString,
|
||||
}
|
||||
utils.Convert(task.Metadata, &c)
|
||||
|
|
|
@ -261,22 +261,23 @@ type PageTaskReq struct {
|
|||
}
|
||||
|
||||
type TaskModel struct {
|
||||
Id int64 `json:"id,omitempty,string" db:"id"` // id
|
||||
Name string `json:"name,omitempty" db:"name"` // 作业名称
|
||||
Description string `json:"description,omitempty" db:"description"` // 作业描述
|
||||
Status string `json:"status,omitempty" db:"status"` // 作业状态
|
||||
Strategy int64 `json:"strategy" db:"strategy"` // 策略
|
||||
SynergyStatus int64 `json:"synergyStatus" db:"synergy_status"` // 协同状态(0-未协同、1-已协同)
|
||||
CommitTime string `json:"commitTime,omitempty" db:"commit_time"` // 提交时间
|
||||
StartTime string `json:"startTime,omitempty" db:"start_time"` // 开始时间
|
||||
EndTime string `json:"endTime,omitempty" db:"end_time"` // 结束运行时间
|
||||
RunningTime int64 `json:"runningTime" db:"running_time"` // 已运行时间(单位秒)
|
||||
YamlString string `json:"yamlString,omitempty" db:"yaml_string"`
|
||||
Result string `json:"result,omitempty" db:"result"` // 作业结果
|
||||
DeletedAt string `json:"deletedAt,omitempty" gorm:"index" db:"deleted_at"`
|
||||
NsID string `json:"nsId,omitempty" db:"ns_id"`
|
||||
TenantId string `json:"tenantId,omitempty" db:"tenant_id"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
||||
Id int64 `json:"id,omitempty,string" db:"id"` // id
|
||||
Name string `json:"name,omitempty" db:"name"` // 作业名称
|
||||
Description string `json:"description,omitempty" db:"description"` // 作业描述
|
||||
Status string `json:"status,omitempty" db:"status"` // 作业状态
|
||||
Strategy int64 `json:"strategy" db:"strategy"` // 策略
|
||||
SynergyStatus int64 `json:"synergyStatus" db:"synergy_status"` // 协同状态(0-未协同、1-已协同)
|
||||
CommitTime string `json:"commitTime,omitempty" db:"commit_time"` // 提交时间
|
||||
StartTime string `json:"startTime,omitempty" db:"start_time"` // 开始时间
|
||||
EndTime string `json:"endTime,omitempty" db:"end_time"` // 结束运行时间
|
||||
RunningTime int64 `json:"runningTime" db:"running_time"` // 已运行时间(单位秒)
|
||||
YamlString string `json:"yamlString,omitempty" db:"yaml_string"`
|
||||
Result string `json:"result,omitempty" db:"result"` // 作业结果
|
||||
DeletedAt string `json:"deletedAt,omitempty" gorm:"index" db:"deleted_at"`
|
||||
NsID string `json:"nsId,omitempty" db:"ns_id"`
|
||||
TenantId string `json:"tenantId,omitempty" db:"tenant_id"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
||||
AdapterTypeDict int `json:"adapterTypeDict" db:"create_time" gorm:"adapter_type_dict"` //任务类型(对应字典表的值
|
||||
}
|
||||
|
||||
type TaskDetailReq struct {
|
||||
|
|
|
@ -35,21 +35,21 @@ type (
|
|||
}
|
||||
|
||||
Task struct {
|
||||
Id int64 `db:"id"` // id
|
||||
Name string `db:"name"` // 作业名称
|
||||
Description string `db:"description"` // 作业描述
|
||||
Status string `db:"status"` // 作业状态
|
||||
Strategy int64 `db:"strategy"` // 策略
|
||||
SynergyStatus int64 `db:"synergy_status"` // 协同状态(0-未协同、1-已协同)
|
||||
CommitTime time.Time `db:"commit_time"` // 提交时间
|
||||
StartTime string `db:"start_time"` // 开始时间
|
||||
EndTime string `db:"end_time"` // 结束运行时间
|
||||
RunningTime int64 `db:"running_time"` // 已运行时间(单位秒)
|
||||
YamlString string `db:"yaml_string"`
|
||||
Result string `db:"result"` // 作业结果
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
NsID string `db:"ns_id"`
|
||||
TaskTypeDict int `db:"task_type_dict"` //任务类型(对应字典表的值)
|
||||
Id int64 `db:"id"` // id
|
||||
Name string `db:"name"` // 作业名称
|
||||
Description string `db:"description"` // 作业描述
|
||||
Status string `db:"status"` // 作业状态
|
||||
Strategy int64 `db:"strategy"` // 策略
|
||||
SynergyStatus int64 `db:"synergy_status"` // 协同状态(0-未协同、1-已协同)
|
||||
CommitTime time.Time `db:"commit_time"` // 提交时间
|
||||
StartTime string `db:"start_time"` // 开始时间
|
||||
EndTime string `db:"end_time"` // 结束运行时间
|
||||
RunningTime int64 `db:"running_time"` // 已运行时间(单位秒)
|
||||
YamlString string `db:"yaml_string"`
|
||||
Result string `db:"result"` // 作业结果
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
NsID string `db:"ns_id"`
|
||||
AdapterTypeDict int `db:"adapter_type_dict"` //任务类型(对应字典表的值)
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@ import (
|
|||
)
|
||||
|
||||
var timeTemplates = []string{
|
||||
"2006-01-02 15:04:05", //常规类型
|
||||
"2006-01-02T15:04:05Z07:00", //RFC3339
|
||||
"2006-01-02 15:04:05", //常规类型
|
||||
"2006/01/02T15:04:05Z07:00", //RFC3339
|
||||
"2006/01/02 15:04:05",
|
||||
"2006-01-02",
|
||||
"2006/01/02",
|
||||
|
|
Loading…
Reference in New Issue