提交代码

This commit is contained in:
zhouqunjie 2023-11-29 17:27:51 +08:00
parent 5db33d3353
commit 8710013a83
5 changed files with 5 additions and 35 deletions

View File

@ -180,6 +180,7 @@ type (
Description string `yaml:"description"`
tenantId int64 `yaml:"tenantId"`
nsID string `yaml:"nsID"`
replicas int64 `yaml:"replicas"`
tasks []TaskYaml `yaml:"tasks"`
}
TaskYaml {

View File

@ -55,10 +55,6 @@ func (l *CloudMq) Consume(val string) error {
//todo 屏蔽原调度算法,因为监控数据暂未上报,临时采用随机调度
schdl.TempAssign()
//err = schdl.AssignAndSchedule()
//if err != nil {
// return err
//}
// 存储数据
err = schdl.SaveToDb()

View File

@ -161,6 +161,7 @@ type ScheduleTaskByYamlReq struct {
Description string `yaml:"description"`
TenantId int64 `yaml:"tenantId"`
NsID string `yaml:"nsID"`
Replicas int64 `yaml:"replicas"`
Tasks []TaskYaml `yaml:"tasks"`
}

View File

@ -24,6 +24,7 @@ type TaskInfo struct {
ParticipantId int64 `json:"participantId,optional"` //湘江预留字段
Clusters []string `json:"clusters,optional"` //云际平台传入集群名称列表
TenantId int64 `json:"tenantId"`
Replicas int64 `json:"replicas"`
Metadata interface{} `json:"metadata"`
}

View File

@ -24,10 +24,8 @@ import (
tool "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice"
"gorm.io/gorm"
"math/rand"
"strconv"
"strings"
"time"
)
type scheduler struct {
@ -105,37 +103,10 @@ func (s *scheduler) TempAssign() error {
for _, resource := range resources {
//如果是Deployment需要对副本数做分发
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
}