|
|
|
@@ -10,7 +10,7 @@ import ( |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" |
|
|
|
"gopkg.in/yaml.v3" |
|
|
|
"slices" |
|
|
|
"strings" |
|
|
|
@@ -49,6 +49,11 @@ func (l *ScheduleCreateTaskLogic) ScheduleCreateTask(req *types.CreateTaskReq) ( |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
taskName, err := l.handleDuplicateTaskName(req.Name) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
var clusters []string |
|
|
|
if len(req.JobResources.Clusters) == 1 { |
|
|
|
clusters = append(clusters, req.JobResources.Clusters[0].ClusterID) |
|
|
|
@@ -61,7 +66,7 @@ func (l *ScheduleCreateTaskLogic) ScheduleCreateTask(req *types.CreateTaskReq) ( |
|
|
|
ClusterId: req.JobResources.Clusters[0].ClusterID, |
|
|
|
}}, req.JobResources.Clusters) |
|
|
|
|
|
|
|
taskId, err := l.createTask("SCHEDULE_TASK_"+utils.RandomString(TRAINNING_TASK_SUFFIX_LEN), req.JobResources.ScheduleStrategy, assignedClusters, req.Token) |
|
|
|
taskId, err := l.createTask(taskName, req.Description, req.JobResources.ScheduleStrategy, assignedClusters, req.Token) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
@@ -87,7 +92,7 @@ func (l *ScheduleCreateTaskLogic) ScheduleCreateTask(req *types.CreateTaskReq) ( |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
taskId, err := l.createTask("SCHEDULE_TASK_"+utils.RandomString(TRAINNING_TASK_SUFFIX_LEN), req.JobResources.ScheduleStrategy, assignedClusters, req.Token) |
|
|
|
taskId, err := l.createTask(taskName, req.Description, req.JobResources.ScheduleStrategy, assignedClusters, req.Token) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
@@ -120,6 +125,19 @@ func validateJobResources(resources types.JobResources) error { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func (l *ScheduleCreateTaskLogic) handleDuplicateTaskName(name string) (string, error) { |
|
|
|
exist, err := l.svcCtx.Scheduler.AiStorages.DoesTaskNameExist(name) |
|
|
|
if err != nil { |
|
|
|
return "", err |
|
|
|
} |
|
|
|
|
|
|
|
if exist { |
|
|
|
return name + "_" + time.Now().Format(constants.Layout_Time_Suffix), nil |
|
|
|
} |
|
|
|
|
|
|
|
return name, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (l *ScheduleCreateTaskLogic) getAssignedClustersByStrategy(resources *types.JobResources, dataDistribute *types.DataDistribute) ([]*strategy.AssignedCluster, error) { |
|
|
|
var assignedClusters []*strategy.AssignedCluster |
|
|
|
switch resources.ScheduleStrategy { |
|
|
|
@@ -210,7 +228,7 @@ func copyParams(clusters []*strategy.AssignedCluster, clusterInfos []*types.JobC |
|
|
|
return result |
|
|
|
} |
|
|
|
|
|
|
|
func (l *ScheduleCreateTaskLogic) createTask(taskName string, strategyName string, clusters []*strategy.AssignedCluster, token string) (int64, error) { |
|
|
|
func (l *ScheduleCreateTaskLogic) createTask(taskName string, desc string, strategyName string, clusters []*strategy.AssignedCluster, token string) (int64, error) { |
|
|
|
var synergyStatus int64 |
|
|
|
if len(clusters) > 1 { |
|
|
|
synergyStatus = 1 |
|
|
|
@@ -221,7 +239,7 @@ func (l *ScheduleCreateTaskLogic) createTask(taskName string, strategyName strin |
|
|
|
fmt.Printf("Error while Marshaling. %v", err) |
|
|
|
} |
|
|
|
|
|
|
|
taskId, err := l.svcCtx.Scheduler.CreateTask(taskName, synergyStatus, strategyName, string(y), token, &l.svcCtx.Config) |
|
|
|
taskId, err := l.svcCtx.Scheduler.CreateTask(taskName, desc, synergyStatus, strategyName, string(y), token, &l.svcCtx.Config) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
|