forked from JointCloud/pcm-coordinator
fix runtask api types
This commit is contained in:
parent
db9d21bfa1
commit
0abdf06f2f
|
@ -238,7 +238,7 @@ type (
|
|||
// 启动任务(资源已就绪):/runTask
|
||||
RunTaskReq {
|
||||
TaskID int64 `json:"taskID"`
|
||||
ScheduledDatas []*DataScheduleResults `json:"scheduledDatas"`
|
||||
ScheduledDatas []*DataScheduleResults `json:"scheduledDatas,optional"`
|
||||
}
|
||||
|
||||
DataScheduleResults {
|
||||
|
|
|
@ -126,101 +126,108 @@ func (l *ScheduleRunTaskLogic) SaveResult(task *models.Task, results []*schedule
|
|||
|
||||
func updateClustersByScheduledDatas(taskId int64, clustersWithDataDistributes *ClustersWithDataDistributes, scheduledDatas []*types.DataScheduleResults) ([]*strategy.AssignedCluster, error) {
|
||||
assignedClusters := make([]*strategy.AssignedCluster, 0)
|
||||
// handle pass-in scheduledDatas
|
||||
for _, cluster := range clustersWithDataDistributes.Clusters {
|
||||
for _, data := range scheduledDatas {
|
||||
switch data.DataType {
|
||||
case "dataset":
|
||||
for _, result := range data.Results {
|
||||
if !result.Status {
|
||||
continue
|
||||
}
|
||||
for _, c := range result.Clusters {
|
||||
if cluster.ClusterId == c.ClusterID {
|
||||
if c.JsonData == "" {
|
||||
continue
|
||||
|
||||
if len(scheduledDatas) == 0 {
|
||||
for _, cluster := range clustersWithDataDistributes.Clusters {
|
||||
assignedClusters = append(assignedClusters, cluster)
|
||||
}
|
||||
} else {
|
||||
// handle pass-in scheduledDatas
|
||||
for _, cluster := range clustersWithDataDistributes.Clusters {
|
||||
for _, data := range scheduledDatas {
|
||||
switch data.DataType {
|
||||
case "dataset":
|
||||
for _, result := range data.Results {
|
||||
if !result.Status {
|
||||
continue
|
||||
}
|
||||
for _, c := range result.Clusters {
|
||||
if cluster.ClusterId == c.ClusterID {
|
||||
if c.JsonData == "" {
|
||||
continue
|
||||
}
|
||||
jsonData := struct {
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
}{}
|
||||
err := json.Unmarshal([]byte(c.JsonData), &jsonData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "dataset")
|
||||
}
|
||||
cluster.DatasetId = jsonData.Id
|
||||
}
|
||||
jsonData := struct {
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
}{}
|
||||
err := json.Unmarshal([]byte(c.JsonData), &jsonData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "dataset")
|
||||
}
|
||||
cluster.DatasetId = jsonData.Id
|
||||
}
|
||||
}
|
||||
}
|
||||
case "image":
|
||||
for _, result := range data.Results {
|
||||
if !result.Status {
|
||||
continue
|
||||
}
|
||||
for _, c := range result.Clusters {
|
||||
if cluster.ClusterId == c.ClusterID {
|
||||
if c.JsonData == "" {
|
||||
continue
|
||||
case "image":
|
||||
for _, result := range data.Results {
|
||||
if !result.Status {
|
||||
continue
|
||||
}
|
||||
for _, c := range result.Clusters {
|
||||
if cluster.ClusterId == c.ClusterID {
|
||||
if c.JsonData == "" {
|
||||
continue
|
||||
}
|
||||
jsonData := struct {
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
}{}
|
||||
err := json.Unmarshal([]byte(c.JsonData), &jsonData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "image")
|
||||
}
|
||||
cluster.ImageId = jsonData.Id
|
||||
}
|
||||
jsonData := struct {
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
}{}
|
||||
err := json.Unmarshal([]byte(c.JsonData), &jsonData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "image")
|
||||
}
|
||||
cluster.ImageId = jsonData.Id
|
||||
}
|
||||
}
|
||||
}
|
||||
case "code":
|
||||
for _, result := range data.Results {
|
||||
if !result.Status {
|
||||
continue
|
||||
}
|
||||
for _, c := range result.Clusters {
|
||||
if cluster.ClusterId == c.ClusterID {
|
||||
if c.JsonData == "" {
|
||||
continue
|
||||
case "code":
|
||||
for _, result := range data.Results {
|
||||
if !result.Status {
|
||||
continue
|
||||
}
|
||||
for _, c := range result.Clusters {
|
||||
if cluster.ClusterId == c.ClusterID {
|
||||
if c.JsonData == "" {
|
||||
continue
|
||||
}
|
||||
jsonData := struct {
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
}{}
|
||||
err := json.Unmarshal([]byte(c.JsonData), &jsonData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "code")
|
||||
}
|
||||
cluster.CodeId = jsonData.Id
|
||||
}
|
||||
jsonData := struct {
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
}{}
|
||||
err := json.Unmarshal([]byte(c.JsonData), &jsonData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "code")
|
||||
}
|
||||
cluster.CodeId = jsonData.Id
|
||||
}
|
||||
}
|
||||
}
|
||||
case "model":
|
||||
for _, result := range data.Results {
|
||||
if !result.Status {
|
||||
continue
|
||||
}
|
||||
for _, c := range result.Clusters {
|
||||
if cluster.ClusterId == c.ClusterID {
|
||||
if c.JsonData == "" {
|
||||
continue
|
||||
case "model":
|
||||
for _, result := range data.Results {
|
||||
if !result.Status {
|
||||
continue
|
||||
}
|
||||
for _, c := range result.Clusters {
|
||||
if cluster.ClusterId == c.ClusterID {
|
||||
if c.JsonData == "" {
|
||||
continue
|
||||
}
|
||||
jsonData := struct {
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
}{}
|
||||
err := json.Unmarshal([]byte(c.JsonData), &jsonData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "model")
|
||||
}
|
||||
cluster.ModelId = jsonData.Id
|
||||
}
|
||||
jsonData := struct {
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
}{}
|
||||
err := json.Unmarshal([]byte(c.JsonData), &jsonData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "model")
|
||||
}
|
||||
cluster.ModelId = jsonData.Id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assignedClusters = append(assignedClusters, cluster)
|
||||
}
|
||||
assignedClusters = append(assignedClusters, cluster)
|
||||
}
|
||||
|
||||
// handle db yaml clustersWithDataDistributes
|
||||
|
|
Loading…
Reference in New Issue