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"`
|
NsID string `json:"nsId,omitempty" db:"ns_id"`
|
||||||
TenantId string `json:"tenantId,omitempty" db:"tenant_id"`
|
TenantId string `json:"tenantId,omitempty" db:"tenant_id"`
|
||||||
CreateTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
CreateTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
||||||
|
AdapterTypeDict int `json:"adapterTypeDict" db:"create_time" gorm:"adapter_type_dict"` //任务类型(对应字典表的值
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,11 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er
|
||||||
err = tx.Raw(sqlStr, req.Strategy).Scan(&strategy).Error
|
err = tx.Raw(sqlStr, req.Strategy).Scan(&strategy).Error
|
||||||
taskModel := models.Task{
|
taskModel := models.Task{
|
||||||
Id: utils.GenSnowflakeID(),
|
Id: utils.GenSnowflakeID(),
|
||||||
Status: constants.Pending,
|
Status: constants.Saved,
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
CommitTime: time.Now(),
|
CommitTime: time.Now(),
|
||||||
YamlString: strings.Join(req.ReqBody, "\n---\n"),
|
YamlString: strings.Join(req.ReqBody, "\n---\n"),
|
||||||
TaskTypeDict: 0,
|
AdapterTypeDict: 0,
|
||||||
SynergyStatus: synergyStatus,
|
SynergyStatus: synergyStatus,
|
||||||
Strategy: strategy,
|
Strategy: strategy,
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er
|
||||||
taskCloud.AdapterId = uint(adapterId)
|
taskCloud.AdapterId = uint(adapterId)
|
||||||
taskCloud.ClusterId = uint(clusterId)
|
taskCloud.ClusterId = uint(clusterId)
|
||||||
taskCloud.ClusterName = r.ClusterName
|
taskCloud.ClusterName = r.ClusterName
|
||||||
taskCloud.Status = constants.Pending
|
taskCloud.Status = constants.Saved
|
||||||
taskCloud.YamlString = string(unString)
|
taskCloud.YamlString = string(unString)
|
||||||
taskCloud.Kind = sStruct.GetKind()
|
taskCloud.Kind = sStruct.GetKind()
|
||||||
taskCloud.Namespace = sStruct.GetNamespace()
|
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 = 'Succeeded' THEN 1 END) AS Succeeded,
|
||||||
COUNT(CASE WHEN status = 'Failed' THEN 1 END) AS Failed,
|
COUNT(CASE WHEN status = 'Failed' THEN 1 END) AS Failed,
|
||||||
COUNT(CASE WHEN status = 'Running' THEN 1 END) AS Running,
|
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;`
|
FROM task;`
|
||||||
err = l.svcCtx.DbEngin.Raw(sqlStr).Scan(&resp).Error
|
err = l.svcCtx.DbEngin.Raw(sqlStr).Scan(&resp).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package core
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/timeutils"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"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 {
|
if err != nil {
|
||||||
return nil, result.NewDefaultError(err.Error())
|
return nil, result.NewDefaultError(err.Error())
|
||||||
}
|
}
|
||||||
const layout = "2006-01-02 15:04:05"
|
|
||||||
for _, model := range list {
|
for _, model := range list {
|
||||||
if model.EndTime != "" && model.StartTime != "" {
|
if model.EndTime != "" && model.StartTime != "" {
|
||||||
starTime, _ := time.Parse(layout, model.StartTime)
|
startTime := timeutils.TimeStringToGoTime(model.StartTime)
|
||||||
endTime, _ := time.Parse(layout, model.EndTime)
|
endTime := timeutils.TimeStringToGoTime(model.EndTime)
|
||||||
model.RunningTime = int64(endTime.Sub(starTime).Seconds())
|
model.RunningTime = int64(endTime.Sub(startTime).Seconds())
|
||||||
}
|
}
|
||||||
if model.StartTime != "" {
|
if model.StartTime != "" {
|
||||||
starTime, _ := time.Parse(layout, model.StartTime)
|
startTime := timeutils.TimeStringToGoTime(model.StartTime)
|
||||||
model.RunningTime = int64(time.Now().Sub(starTime).Seconds())
|
model.RunningTime = int64(time.Now().Sub(startTime).Seconds())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resp.List = &list
|
resp.List = &list
|
||||||
|
|
|
@ -34,7 +34,7 @@ func (l *TaskDetailsLogic) TaskDetails(req *types.FId) (resp *types.TaskDetailsR
|
||||||
}
|
}
|
||||||
clusterIds := make([]int64, 0)
|
clusterIds := make([]int64, 0)
|
||||||
var cList []*types.ClusterInfo
|
var cList []*types.ClusterInfo
|
||||||
switch task.TaskTypeDict {
|
switch task.AdapterTypeDict {
|
||||||
case 0:
|
case 0:
|
||||||
l.svcCtx.DbEngin.Table("task_cloud").Select("cluster_id").Where("task_id", task.Id).Scan(&clusterIds)
|
l.svcCtx.DbEngin.Table("task_cloud").Select("cluster_id").Where("task_id", task.Id).Scan(&clusterIds)
|
||||||
case 1:
|
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/scheduler/strategy/param"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response"
|
"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/models/cloud"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
||||||
|
@ -60,7 +61,7 @@ func (as *CloudScheduler) GetNewStructForDb(task *response.TaskInfo, resource st
|
||||||
c := cloud.TaskCloudModel{
|
c := cloud.TaskCloudModel{
|
||||||
AdapterId: uint(participantId),
|
AdapterId: uint(participantId),
|
||||||
TaskId: uint(task.TaskId),
|
TaskId: uint(task.TaskId),
|
||||||
Status: "Pending",
|
Status: constants.Saved,
|
||||||
YamlString: as.yamlString,
|
YamlString: as.yamlString,
|
||||||
}
|
}
|
||||||
utils.Convert(task.Metadata, &c)
|
utils.Convert(task.Metadata, &c)
|
||||||
|
|
|
@ -277,6 +277,7 @@ type TaskModel struct {
|
||||||
NsID string `json:"nsId,omitempty" db:"ns_id"`
|
NsID string `json:"nsId,omitempty" db:"ns_id"`
|
||||||
TenantId string `json:"tenantId,omitempty" db:"tenant_id"`
|
TenantId string `json:"tenantId,omitempty" db:"tenant_id"`
|
||||||
CreateTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
CreateTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
||||||
|
AdapterTypeDict int `json:"adapterTypeDict" db:"create_time" gorm:"adapter_type_dict"` //任务类型(对应字典表的值
|
||||||
}
|
}
|
||||||
|
|
||||||
type TaskDetailReq struct {
|
type TaskDetailReq struct {
|
||||||
|
|
|
@ -49,7 +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"` //任务类型(对应字典表的值)
|
AdapterTypeDict int `db:"adapter_type_dict"` //任务类型(对应字典表的值)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var timeTemplates = []string{
|
var timeTemplates = []string{
|
||||||
|
"2006-01-02T15:04:05Z07:00", //RFC3339
|
||||||
"2006-01-02 15:04:05", //常规类型
|
"2006-01-02 15:04:05", //常规类型
|
||||||
|
"2006/01/02T15:04:05Z07:00", //RFC3339
|
||||||
"2006/01/02 15:04:05",
|
"2006/01/02 15:04:05",
|
||||||
"2006-01-02",
|
"2006-01-02",
|
||||||
"2006/01/02",
|
"2006/01/02",
|
||||||
|
|
Loading…
Reference in New Issue