提交代码
Former-commit-id: 8710013a832280ba3418fe451ead53c47559430c
This commit is contained in:
parent
7cacc5347a
commit
f16396c746
|
@ -180,6 +180,7 @@ type (
|
||||||
Description string `yaml:"description"`
|
Description string `yaml:"description"`
|
||||||
tenantId int64 `yaml:"tenantId"`
|
tenantId int64 `yaml:"tenantId"`
|
||||||
nsID string `yaml:"nsID"`
|
nsID string `yaml:"nsID"`
|
||||||
|
replicas int64 `yaml:"replicas"`
|
||||||
tasks []TaskYaml `yaml:"tasks"`
|
tasks []TaskYaml `yaml:"tasks"`
|
||||||
}
|
}
|
||||||
TaskYaml {
|
TaskYaml {
|
||||||
|
|
|
@ -55,10 +55,6 @@ func (l *CloudMq) Consume(val string) error {
|
||||||
|
|
||||||
//todo 屏蔽原调度算法,因为监控数据暂未上报,临时采用随机调度
|
//todo 屏蔽原调度算法,因为监控数据暂未上报,临时采用随机调度
|
||||||
schdl.TempAssign()
|
schdl.TempAssign()
|
||||||
//err = schdl.AssignAndSchedule()
|
|
||||||
//if err != nil {
|
|
||||||
// return err
|
|
||||||
//}
|
|
||||||
|
|
||||||
// 存储数据
|
// 存储数据
|
||||||
err = schdl.SaveToDb()
|
err = schdl.SaveToDb()
|
||||||
|
|
|
@ -161,6 +161,7 @@ type ScheduleTaskByYamlReq struct {
|
||||||
Description string `yaml:"description"`
|
Description string `yaml:"description"`
|
||||||
TenantId int64 `yaml:"tenantId"`
|
TenantId int64 `yaml:"tenantId"`
|
||||||
NsID string `yaml:"nsID"`
|
NsID string `yaml:"nsID"`
|
||||||
|
Replicas int64 `yaml:"replicas"`
|
||||||
Tasks []TaskYaml `yaml:"tasks"`
|
Tasks []TaskYaml `yaml:"tasks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ type TaskInfo struct {
|
||||||
ParticipantId int64 `json:"participantId,optional"` //湘江预留字段
|
ParticipantId int64 `json:"participantId,optional"` //湘江预留字段
|
||||||
Clusters []string `json:"clusters,optional"` //云际平台传入集群名称列表
|
Clusters []string `json:"clusters,optional"` //云际平台传入集群名称列表
|
||||||
TenantId int64 `json:"tenantId"`
|
TenantId int64 `json:"tenantId"`
|
||||||
|
Replicas int64 `json:"replicas"`
|
||||||
Metadata interface{} `json:"metadata"`
|
Metadata interface{} `json:"metadata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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))
|
resource.(map[string]interface{})["spec"].(map[string]interface{})["replicas"] = s.task.Replicas
|
||||||
|
|
||||||
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"
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s.result[s.participantIds[0]] = ""
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
s.task.Metadata = resources
|
||||||
//var crd = s.task.Metadata
|
|
||||||
//for i := 0; i < len(s.task.Metadata); i++ {
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue