|
|
@@ -24,10 +24,8 @@ import ( |
|
|
tool "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils" |
|
|
tool "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils" |
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice" |
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice" |
|
|
"gorm.io/gorm" |
|
|
"gorm.io/gorm" |
|
|
"math/rand" |
|
|
|
|
|
"strconv" |
|
|
"strconv" |
|
|
"strings" |
|
|
"strings" |
|
|
"time" |
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
type scheduler struct { |
|
|
type scheduler struct { |
|
|
@@ -105,37 +103,10 @@ func (s *scheduler) TempAssign() error { |
|
|
for _, resource := range resources { |
|
|
for _, resource := range resources { |
|
|
//如果是Deployment,需要对副本数做分发 |
|
|
//如果是Deployment,需要对副本数做分发 |
|
|
if resource.(map[string]interface{})["kind"].(string) == "Deployment" || resource.(map[string]interface{})["kind"].(string) == "Replicaset" { |
|
|
if resource.(map[string]interface{})["kind"].(string) == "Deployment" || resource.(map[string]interface{})["kind"].(string) == "Replicaset" { |
|
|
//replicas := int(resource.(map[string]interface{})["spec"].(map[string]interface{})["replicas"].(float64)) |
|
|
|
|
|
|
|
|
|
|
|
rand.Seed(time.Now().UnixNano()) |
|
|
|
|
|
|
|
|
|
|
|
//// 生成pID对应副本数 数组 |
|
|
|
|
|
//arrReplica := make(map[int64]int, len(s.participantIds)) |
|
|
|
|
|
//for i := 0; i < len(s.participantIds)-1; i++ { |
|
|
|
|
|
// arrReplica[s.participantIds[i]] = rand.Intn(replicas) |
|
|
|
|
|
// replicas -= arrReplica[s.participantIds[i]] // 更新剩余的和 |
|
|
|
|
|
//} |
|
|
|
|
|
//arrReplica[s.participantIds[len(s.participantIds)-1]] = replicas |
|
|
|
|
|
// |
|
|
|
|
|
////将副本数依次写入新的yaml中并生成result数据 |
|
|
|
|
|
//yamlArray := make(map[int64]string, len(s.participantIds)) |
|
|
|
|
|
// |
|
|
|
|
|
//for i := 0; i < len(s.participantIds)-1; i++ { |
|
|
|
|
|
// //调整yaml |
|
|
|
|
|
// yamlArray[s.participantIds[i]] = "sds" |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resource.(map[string]interface{})["spec"].(map[string]interface{})["replicas"] = s.task.Replicas |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
s.result[s.participantIds[0]] = "" |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//var crd = s.task.Metadata |
|
|
|
|
|
//for i := 0; i < len(s.task.Metadata); i++ { |
|
|
|
|
|
// |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s.task.Metadata = resources |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|