Browse Source

提交代码

Former-commit-id: 8710013a83
scheduler_restruct
zhouqunjie 2 years ago
parent
commit
f16396c746
5 changed files with 5 additions and 35 deletions
  1. +1
    -0
      api/desc/core/pcm-core.api
  2. +0
    -4
      api/internal/mqs/ScheduleCloud.go
  3. +1
    -0
      api/internal/types/types.go
  4. +1
    -0
      api/pkg/response/TaskInfo.go
  5. +2
    -31
      pkg/scheduler/scheduler.go

+ 1
- 0
api/desc/core/pcm-core.api 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 {


+ 0
- 4
api/internal/mqs/ScheduleCloud.go 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()


+ 1
- 0
api/internal/types/types.go 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"`
}



+ 1
- 0
api/pkg/response/TaskInfo.go 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"`
}



+ 2
- 31
pkg/scheduler/scheduler.go 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
}



Loading…
Cancel
Save