mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
define scheduler apis output and input structs
This commit is contained in:
@@ -63,7 +63,7 @@ func (p *AggregatePredicate) Execute(u *core.Unit, c core.Candidater) (bool, []c
|
||||
|
||||
type schedtagCandidateW struct {
|
||||
core.Candidater
|
||||
schedData *api.SchedData
|
||||
schedData *api.SchedInfo
|
||||
}
|
||||
|
||||
func (w schedtagCandidateW) GetDynamicSchedDesc() *jsonutils.JSONDict {
|
||||
@@ -96,25 +96,27 @@ func (p *AggregatePredicate) exec(h *PredicateHelper) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func SetCandidateScoreBySchedtag(u *core.Unit, c core.Candidater, aggCountMap map[string]int, postiveScore bool) {
|
||||
stepScore := core.PriorityStep
|
||||
if !postiveScore {
|
||||
stepScore = -stepScore
|
||||
}
|
||||
for n, count := range aggCountMap {
|
||||
u.SetFrontScore(
|
||||
c.IndexKey(),
|
||||
score.NewScore(score.TScore(count*stepScore), n),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *AggregatePredicate) OnPriorityEnd(u *core.Unit, c core.Candidater) {
|
||||
hostAggs := c.Getter().HostSchedtags()
|
||||
|
||||
avoidCountMap := GetSchedtagCount(p.SchedtagPredicate.GetAvoidTags(), hostAggs, api.AggregateStrategyAvoid)
|
||||
preferCountMap := GetSchedtagCount(p.SchedtagPredicate.GetPreferTags(), hostAggs, api.AggregateStrategyPrefer)
|
||||
|
||||
setScore := func(aggCountMap map[string]int, postiveScore bool) {
|
||||
stepScore := core.PriorityStep
|
||||
if !postiveScore {
|
||||
stepScore = -stepScore
|
||||
}
|
||||
for n, count := range aggCountMap {
|
||||
u.SetFrontScore(
|
||||
c.IndexKey(),
|
||||
score.NewScore(score.TScore(count*stepScore), n),
|
||||
)
|
||||
}
|
||||
}
|
||||
setScore := SetCandidateScoreBySchedtag
|
||||
|
||||
setScore(preferCountMap, true)
|
||||
setScore(avoidCountMap, false)
|
||||
setScore(u, c, preferCountMap, true)
|
||||
setScore(u, c, avoidCountMap, false)
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ func (p *CPUPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core.Pr
|
||||
d := u.SchedData()
|
||||
|
||||
freeCPUCount := h.GetInt64("FreeCPUCount", 0)
|
||||
reqCPUCount := d.VCPUCount
|
||||
if freeCPUCount < d.VCPUCount {
|
||||
reqCPUCount := int64(d.Ncpu)
|
||||
if freeCPUCount < reqCPUCount {
|
||||
totalCPUCount := h.GetInt64("CPUCount", 0)
|
||||
h.AppendInsufficientResourceError(reqCPUCount, totalCPUCount, freeCPUCount)
|
||||
h.SetCapacity(0)
|
||||
|
||||
@@ -22,7 +22,7 @@ func (p *MemoryPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core
|
||||
d := u.SchedData()
|
||||
|
||||
freeMemSize := h.GetInt64("FreeMemSize", 0)
|
||||
reqMemSize := d.VMEMSize
|
||||
reqMemSize := int64(d.Memory)
|
||||
if freeMemSize < reqMemSize {
|
||||
totalMemSize := h.GetInt64("MemSize", 0)
|
||||
h.AppendInsufficientResourceError(reqMemSize, totalMemSize, freeMemSize)
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
computeapi "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/algorithm/plugin"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/algorithm/predicates"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/api"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@ func (p *NetworkPredicate) PreExecute(u *core.Unit, cs []core.Candidater) (bool,
|
||||
|
||||
u.AppendSelectPlugin(p)
|
||||
d := u.SchedData()
|
||||
if len(d.HostID) > 0 && len(d.Networks) == 0 {
|
||||
if len(d.HostId) > 0 && len(d.Networks) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (p *NetworkPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
counters := core.NewCounters()
|
||||
|
||||
isMigrate := func() bool {
|
||||
return len(schedData.HostID) > 0
|
||||
return len(schedData.HostId) > 0
|
||||
}
|
||||
|
||||
isRandomNetworkAvailable := func(private bool, exit bool, wire string) string {
|
||||
@@ -69,7 +69,7 @@ func (p *NetworkPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
if wire != "" && !utils.HasPrefix(wire, network.WireId) && !utils.HasPrefix(wire, network.GetWire().GetName()) { // re
|
||||
appendError(predicates.ErrWireIsNotMatch)
|
||||
}
|
||||
if (!private && network.IsPublic) || (private && !network.IsPublic && network.ProjectId == schedData.OwnerTenantID) {
|
||||
if (!private && network.IsPublic) || (private && !network.IsPublic && network.ProjectId == schedData.Project) {
|
||||
// TODO: support reservedNetworks
|
||||
reservedNetworks := 0
|
||||
restPort := int64(network.GetPorts() - reservedNetworks)
|
||||
@@ -100,12 +100,12 @@ func (p *NetworkPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
h.SetCapacityCounter(counters)
|
||||
}
|
||||
|
||||
isNetworkAvaliable := func(network *api.Network) string {
|
||||
if network.Idx == "" {
|
||||
isNetworkAvaliable := func(network *computeapi.NetworkConfig) string {
|
||||
if network.Network == "" {
|
||||
return isRandomNetworkAvailable(network.Private, network.Exit, network.Wire)
|
||||
}
|
||||
for _, net := range candidate.Networks {
|
||||
if (network.Idx == net.Id || network.Idx == net.Name) && (net.IsPublic || net.ProjectId == schedData.OwnerTenantID) && (net.GetPorts() > 0 || isMigrate()) {
|
||||
if (network.Network == net.Id || network.Network == net.Name) && (net.IsPublic || net.ProjectId == schedData.Project) && (net.GetPorts() > 0 || isMigrate()) {
|
||||
h.SetCapacity(1)
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package baremetal
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
computeapi "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/compute/baremetal"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/algorithm/predicates"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/api"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
)
|
||||
|
||||
@@ -21,22 +21,19 @@ func (p *StoragePredicate) Clone() core.FitPredicate {
|
||||
return &StoragePredicate{}
|
||||
}
|
||||
|
||||
func toBaremetalDisks(disks []*api.Disk) []*baremetal.Disk {
|
||||
func toBaremetalDisks(disks []*computeapi.DiskConfig) []*baremetal.Disk {
|
||||
ret := make([]*baremetal.Disk, len(disks))
|
||||
for i, disk := range disks {
|
||||
ret[i] = &baremetal.Disk{
|
||||
Backend: disk.Backend,
|
||||
ImageID: disk.ImageID,
|
||||
Fs: disk.Fs,
|
||||
Os: disk.Os,
|
||||
OSDistribution: disk.OSDistribution,
|
||||
Format: disk.Format,
|
||||
MountPoint: disk.MountPoint,
|
||||
Driver: disk.Driver,
|
||||
Cache: disk.Cache,
|
||||
ImageDiskFormat: disk.ImageDiskFormat,
|
||||
Size: disk.Size,
|
||||
Storage: disk.Storage,
|
||||
Backend: disk.Backend,
|
||||
ImageID: disk.ImageId,
|
||||
Fs: &disk.Fs,
|
||||
Format: disk.Format,
|
||||
MountPoint: &disk.Mountpoint,
|
||||
Driver: &disk.Driver,
|
||||
Cache: &disk.Cache,
|
||||
Size: int64(disk.SizeMb),
|
||||
Storage: &disk.Storage,
|
||||
}
|
||||
}
|
||||
return ret
|
||||
|
||||
@@ -6,17 +6,70 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/util/errors"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
computeapi "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
schedapi "yunion.io/x/onecloud/pkg/apis/scheduler"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/algorithm/plugin"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/api"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
)
|
||||
|
||||
type DiskStoragesMap map[int][]*api.CandidateStorage
|
||||
type DiskStoragesMap map[int][]*PredicatedStorage
|
||||
|
||||
func (m DiskStoragesMap) getAllTags(isPrefer bool) []computeapi.SchedtagConfig {
|
||||
ret := make([]computeapi.SchedtagConfig, 0)
|
||||
for _, ss := range m {
|
||||
for _, s := range ss {
|
||||
var tags []computeapi.SchedtagConfig
|
||||
if isPrefer {
|
||||
tags = s.PreferTags
|
||||
} else {
|
||||
tags = s.AvoidTags
|
||||
}
|
||||
ret = append(ret, tags...)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (m DiskStoragesMap) GetPreferTags() []computeapi.SchedtagConfig {
|
||||
return m.getAllTags(true)
|
||||
}
|
||||
|
||||
func (m DiskStoragesMap) GetAvoidTags() []computeapi.SchedtagConfig {
|
||||
return m.getAllTags(false)
|
||||
}
|
||||
|
||||
type CandidateDiskStoragesMap map[string]DiskStoragesMap
|
||||
|
||||
type PredicatedStorage struct {
|
||||
*api.CandidateStorage
|
||||
PreferTags []computeapi.SchedtagConfig
|
||||
AvoidTags []computeapi.SchedtagConfig
|
||||
}
|
||||
|
||||
func newPredicatedStorage(s *api.CandidateStorage, preferTags, avoidTags []computeapi.SchedtagConfig) *PredicatedStorage {
|
||||
return &PredicatedStorage{
|
||||
CandidateStorage: s,
|
||||
PreferTags: preferTags,
|
||||
AvoidTags: avoidTags,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PredicatedStorage) isNoTag() bool {
|
||||
return len(s.PreferTags) == 0 && len(s.AvoidTags) == 0
|
||||
}
|
||||
|
||||
func (s *PredicatedStorage) hasPreferTags() bool {
|
||||
return len(s.PreferTags) != 0
|
||||
}
|
||||
|
||||
func (s *PredicatedStorage) hasAvoidTags() bool {
|
||||
return len(s.AvoidTags) != 0
|
||||
}
|
||||
|
||||
type DiskSchedtagPredicate struct {
|
||||
BasePredicate
|
||||
plugin.BasePlugin
|
||||
@@ -24,6 +77,8 @@ type DiskSchedtagPredicate struct {
|
||||
SchedtagPredicate *SchedtagPredicate
|
||||
|
||||
CandidateDiskStoragesMap CandidateDiskStoragesMap
|
||||
|
||||
Hypervisor string
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) Name() string {
|
||||
@@ -36,9 +91,9 @@ func (p *DiskSchedtagPredicate) Clone() core.FitPredicate {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) getSchedtagDisks(disks []*api.Disk) ([]*api.Disk, []*api.Disk) {
|
||||
noTagDisk := make([]*api.Disk, 0)
|
||||
tagDisk := make([]*api.Disk, 0)
|
||||
func (p *DiskSchedtagPredicate) getSchedtagDisks(disks []*computeapi.DiskConfig) ([]*computeapi.DiskConfig, []*computeapi.DiskConfig) {
|
||||
noTagDisk := make([]*computeapi.DiskConfig, 0)
|
||||
tagDisk := make([]*computeapi.DiskConfig, 0)
|
||||
for _, d := range disks {
|
||||
if len(d.Schedtags) != 0 {
|
||||
tagDisk = append(tagDisk, d)
|
||||
@@ -55,6 +110,8 @@ func (p *DiskSchedtagPredicate) PreExecute(u *core.Unit, cs []core.Candidater) (
|
||||
return false, nil
|
||||
}
|
||||
|
||||
p.Hypervisor = u.SchedData().Hypervisor
|
||||
|
||||
// always select each storages to disks
|
||||
u.AppendSelectPlugin(p)
|
||||
|
||||
@@ -63,11 +120,11 @@ func (p *DiskSchedtagPredicate) PreExecute(u *core.Unit, cs []core.Candidater) (
|
||||
|
||||
type schedtagStorageW struct {
|
||||
candidater *api.CandidateStorage
|
||||
disk *api.Disk
|
||||
disk *computeapi.DiskConfig
|
||||
}
|
||||
|
||||
func (w schedtagStorageW) IndexKey() string {
|
||||
return fmt.Sprintf("%d:%s", w.disk.Size, w.disk.Backend)
|
||||
return fmt.Sprintf("%s:%s", w.candidater.GetName(), w.candidater.StorageType)
|
||||
}
|
||||
|
||||
func (w schedtagStorageW) GetDynamicSchedDesc() *jsonutils.JSONDict {
|
||||
@@ -82,10 +139,10 @@ func (w schedtagStorageW) ResourceType() string {
|
||||
return models.StorageManager.KeywordPlural()
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) check(d *api.Disk, s *api.CandidateStorage) (bool, error) {
|
||||
func (p *DiskSchedtagPredicate) check(d *computeapi.DiskConfig, s *api.CandidateStorage) (*PredicatedStorage, error) {
|
||||
allTags, err := GetAllSchedtags(models.StorageManager.KeywordPlural())
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
tagPredicate := NewSchedtagPredicate(d.Schedtags, allTags)
|
||||
if err := tagPredicate.Check(
|
||||
@@ -94,22 +151,24 @@ func (p *DiskSchedtagPredicate) check(d *api.Disk, s *api.CandidateStorage) (boo
|
||||
disk: d,
|
||||
},
|
||||
); err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
return true, nil
|
||||
avoidTags := tagPredicate.GetAvoidTags()
|
||||
preferTags := tagPredicate.GetPreferTags()
|
||||
return newPredicatedStorage(s, preferTags, avoidTags), nil
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) checkStorages(d *api.Disk, storages []*api.CandidateStorage) ([]*api.CandidateStorage, error) {
|
||||
func (p *DiskSchedtagPredicate) checkStorages(d *computeapi.DiskConfig, storages []*api.CandidateStorage) ([]*PredicatedStorage, error) {
|
||||
errs := make([]error, 0)
|
||||
ret := make([]*api.CandidateStorage, 0)
|
||||
ret := make([]*PredicatedStorage, 0)
|
||||
for _, s := range storages {
|
||||
_, err := p.check(d, s)
|
||||
ps, err := p.check(d, s)
|
||||
if err != nil {
|
||||
// append err, storage not suit disk
|
||||
errs = append(errs, err)
|
||||
continue
|
||||
}
|
||||
ret = append(ret, s)
|
||||
ret = append(ret, ps)
|
||||
}
|
||||
if len(ret) == 0 {
|
||||
return nil, errors.NewAggregate(errs)
|
||||
@@ -120,7 +179,7 @@ func (p *DiskSchedtagPredicate) checkStorages(d *api.Disk, storages []*api.Candi
|
||||
func (p *DiskSchedtagPredicate) GetDiskStoragesMap(candidateId string) DiskStoragesMap {
|
||||
ret, ok := p.CandidateDiskStoragesMap[candidateId]
|
||||
if !ok {
|
||||
ret = make(map[int][]*api.CandidateStorage)
|
||||
ret = make(map[int][]*PredicatedStorage)
|
||||
p.CandidateDiskStoragesMap[candidateId] = ret
|
||||
}
|
||||
return ret
|
||||
@@ -129,40 +188,132 @@ func (p *DiskSchedtagPredicate) GetDiskStoragesMap(candidateId string) DiskStora
|
||||
func (p *DiskSchedtagPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core.PredicateFailureReason, error) {
|
||||
h := NewPredicateHelper(p, u, c)
|
||||
|
||||
//noTagDisks, tagDisks := p.getSchedtagDisks(u.SchedData().Disks)
|
||||
storages := c.Getter().Storages()
|
||||
ds := p.GetDiskStoragesMap(c.IndexKey())
|
||||
disks := u.SchedData().Disks
|
||||
for _, d := range disks {
|
||||
for idx, d := range disks {
|
||||
matchedStorages, err := p.checkStorages(d, storages)
|
||||
if err != nil {
|
||||
h.Exclude(err.Error())
|
||||
}
|
||||
ds[d.Index] = matchedStorages
|
||||
ds[idx] = matchedStorages
|
||||
}
|
||||
|
||||
return h.GetResult()
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) OnPriorityEnd(u *core.Unit, c core.Candidater) {
|
||||
storageTags := []models.SSchedtag{}
|
||||
for _, s := range c.Getter().Storages() {
|
||||
storageTags = append(storageTags, s.Schedtags...)
|
||||
}
|
||||
|
||||
ds := p.GetDiskStoragesMap(c.IndexKey())
|
||||
avoidTags := ds.GetAvoidTags()
|
||||
preferTags := ds.GetPreferTags()
|
||||
|
||||
avoidCountMap := GetSchedtagCount(avoidTags, storageTags, api.AggregateStrategyAvoid)
|
||||
preferCountMap := GetSchedtagCount(preferTags, storageTags, api.AggregateStrategyPrefer)
|
||||
|
||||
setScore := SetCandidateScoreBySchedtag
|
||||
|
||||
setScore(u, c, preferCountMap, true)
|
||||
setScore(u, c, avoidCountMap, false)
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) OnSelectEnd(u *core.Unit, c core.Candidater, count int64) {
|
||||
res := u.GetAllocatedResource(c.IndexKey())
|
||||
diskStorages := p.GetDiskStoragesMap(c.IndexKey())
|
||||
res.Disks = make([]*core.DiskAllocatedResource, len(diskStorages))
|
||||
res.Disks = make([]*schedapi.CandidateDisk, len(diskStorages))
|
||||
disks := u.SchedData().Disks
|
||||
for idx, ds := range diskStorages {
|
||||
res.Disks[idx] = p.allocatedDiskResource(c, disks[idx], ds)
|
||||
}
|
||||
log.Errorf("============OnSelectEnd %s called: %#v", c.Getter().Name(), jsonutils.Marshal(res.Disks).String())
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) allocatedDiskResource(c core.Candidater, disk *api.Disk, storages []*api.CandidateStorage) *core.DiskAllocatedResource {
|
||||
func (p *DiskSchedtagPredicate) allocatedDiskResource(c core.Candidater, disk *computeapi.DiskConfig, storages []*PredicatedStorage) *schedapi.CandidateDisk {
|
||||
storage := p.selectStorage(disk, storages)
|
||||
return &core.DiskAllocatedResource{
|
||||
log.Debugf("Select storage %s:%s for disk: %s", storage.Id, storage.Name, disk.Index)
|
||||
return &schedapi.CandidateDisk{
|
||||
Index: disk.Index,
|
||||
StorageId: storage.Id,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) selectStorage(d *api.Disk, storages []*api.CandidateStorage) *api.CandidateStorage {
|
||||
return storages[0]
|
||||
func (p *DiskSchedtagPredicate) selectStorage(d *computeapi.DiskConfig, storages []*PredicatedStorage) *api.CandidateStorage {
|
||||
preferStorages := []*api.CandidateStorage{}
|
||||
noTagStorages := []*api.CandidateStorage{}
|
||||
avoidStorages := []*api.CandidateStorage{}
|
||||
for _, storage := range storages {
|
||||
if p.isStorageFitDisk(storage, d) {
|
||||
candi := storage.CandidateStorage
|
||||
if storage.isNoTag() {
|
||||
noTagStorages = append(noTagStorages, candi)
|
||||
} else if storage.hasPreferTags() {
|
||||
preferStorages = append(preferStorages, candi)
|
||||
} else if storage.hasAvoidTags() {
|
||||
avoidStorages = append(avoidStorages, candi)
|
||||
}
|
||||
}
|
||||
}
|
||||
sortStorages := []*api.CandidateStorage{}
|
||||
sortStorages = append(sortStorages, preferStorages...)
|
||||
sortStorages = append(sortStorages, noTagStorages...)
|
||||
sortStorages = append(sortStorages, avoidStorages...)
|
||||
return p.GetLeastUsedStorage(sortStorages, d.Backend)
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) GetLeastUsedStorage(storages []*api.CandidateStorage, backend string) *api.CandidateStorage {
|
||||
var backends []string
|
||||
if backend == computeapi.STORAGE_LOCAL {
|
||||
backends = []string{computeapi.STORAGE_NAS, computeapi.STORAGE_LOCAL}
|
||||
} else if len(backend) > 0 {
|
||||
backends = []string{backend}
|
||||
} else {
|
||||
backends = []string{}
|
||||
}
|
||||
return p.getLeastUsedStorage(storages, backends)
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) getLeastUsedStorage(storages []*api.CandidateStorage, backends []string) *api.CandidateStorage {
|
||||
var best *api.CandidateStorage
|
||||
var bestCap int
|
||||
for i := 0; i < len(storages); i++ {
|
||||
s := storages[i]
|
||||
if len(backends) > 0 {
|
||||
in, _ := utils.InStringArray(s.StorageType, backends)
|
||||
if !in {
|
||||
continue
|
||||
}
|
||||
}
|
||||
capa := s.GetFreeCapacity()
|
||||
if best == nil || bestCap < capa {
|
||||
bestCap = capa
|
||||
best = s
|
||||
}
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) GetHypervisorDriver() models.IGuestDriver {
|
||||
return models.GetDriver(p.Hypervisor)
|
||||
}
|
||||
|
||||
func (p *DiskSchedtagPredicate) isStorageFitDisk(storage *PredicatedStorage, d *computeapi.DiskConfig) bool {
|
||||
if d.Storage != "" {
|
||||
if storage.Id == d.Storage || storage.Name == d.Storage {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
if storage.StorageType == d.Backend {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, stype := range p.GetHypervisorDriver().GetStorageTypes() {
|
||||
if storage.StorageType == stype {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func (f *CPUPredicate) PreExecute(u *core.Unit, cs []core.Candidater) (bool, err
|
||||
|
||||
data := u.SchedData()
|
||||
|
||||
if data.VCPUCount <= 0 {
|
||||
if data.Ncpu <= 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func (f *CPUPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core.Pr
|
||||
|
||||
useRsvd := h.UseReserved()
|
||||
freeCPUCount := hc.GetFreeCPUCount(useRsvd)
|
||||
reqCPUCount := d.VCPUCount
|
||||
reqCPUCount := int64(d.Ncpu)
|
||||
if freeCPUCount < reqCPUCount {
|
||||
totalCPUCount := hc.GetTotalCPUCount(useRsvd)
|
||||
h.AppendInsufficientResourceError(reqCPUCount, totalCPUCount, freeCPUCount)
|
||||
|
||||
@@ -37,13 +37,13 @@ func (p *GroupPredicate) PreExecute(u *core.Unit, cs []core.Candidater) (bool, e
|
||||
|
||||
for _, r := range d.GroupRelations {
|
||||
if r.Strategy == "exclude" {
|
||||
p.ExcludeGroups = append(p.ExcludeGroups, r.GroupID)
|
||||
p.ExcludeGroups = append(p.ExcludeGroups, r.GroupId)
|
||||
} else if r.Strategy == "require" {
|
||||
p.RequireGroups = append(p.RequireGroups, r.GroupID)
|
||||
p.RequireGroups = append(p.RequireGroups, r.GroupId)
|
||||
} else if r.Strategy == "avoid" {
|
||||
p.AvoidGroups = append(p.AvoidGroups, r.GroupID)
|
||||
p.AvoidGroups = append(p.AvoidGroups, r.GroupId)
|
||||
} else if r.Strategy == "prefer" {
|
||||
p.PreferGroups = append(p.PreferGroups, r.GroupID)
|
||||
p.PreferGroups = append(p.PreferGroups, r.GroupId)
|
||||
}
|
||||
}
|
||||
u.AppendSelectPlugin(p)
|
||||
|
||||
@@ -41,16 +41,16 @@ func (f *IsolatedDevicePredicate) Execute(u *core.Unit, c core.Candidater) (bool
|
||||
|
||||
// check by specify device id
|
||||
for _, dev := range reqIsoDevs {
|
||||
if len(dev.ID) == 0 {
|
||||
if len(dev.Id) == 0 {
|
||||
continue
|
||||
}
|
||||
if fDev := hc.GetIsolatedDevice(dev.ID); fDev != nil {
|
||||
if fDev := hc.GetIsolatedDevice(dev.Id); fDev != nil {
|
||||
if len(fDev.GuestID) != 0 {
|
||||
h.Exclude(fmt.Sprintf("IsolatedDevice %q already used by guest %q", dev.ID, fDev.GuestID))
|
||||
h.Exclude(fmt.Sprintf("IsolatedDevice %q already used by guest %q", dev.Id, fDev.GuestID))
|
||||
return h.GetResult()
|
||||
}
|
||||
} else {
|
||||
h.Exclude(fmt.Sprintf("Not found IsolatedDevice %q", dev.ID))
|
||||
h.Exclude(fmt.Sprintf("Not found IsolatedDevice %q", dev.Id))
|
||||
return h.GetResult()
|
||||
}
|
||||
minCapacity = 1
|
||||
@@ -72,8 +72,8 @@ func (f *IsolatedDevicePredicate) Execute(u *core.Unit, c core.Candidater) (bool
|
||||
// check host device by type
|
||||
devTypeRequest := make(map[string]int, 0)
|
||||
for _, dev := range reqIsoDevs {
|
||||
if len(dev.Type) != 0 {
|
||||
devTypeRequest[dev.Type] += 1
|
||||
if len(dev.DevType) != 0 {
|
||||
devTypeRequest[dev.DevType] += 1
|
||||
}
|
||||
}
|
||||
for devType, reqCount := range devTypeRequest {
|
||||
|
||||
@@ -27,7 +27,7 @@ func (p *MemoryPredicate) PreExecute(u *core.Unit, cs []core.Candidater) (bool,
|
||||
|
||||
data := u.SchedData()
|
||||
|
||||
if data.VMEMSize <= 0 {
|
||||
if data.Memory <= 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func (p *MemoryPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core
|
||||
|
||||
useRsvd := h.UseReserved()
|
||||
freeMemSize := hc.GetFreeMemSize(useRsvd)
|
||||
reqMemSize := d.VMEMSize
|
||||
reqMemSize := int64(d.Memory)
|
||||
if freeMemSize < reqMemSize {
|
||||
totalMemSize := hc.GetTotalMemSize(useRsvd)
|
||||
h.AppendInsufficientResourceError(reqMemSize, totalMemSize, freeMemSize)
|
||||
|
||||
@@ -19,13 +19,13 @@ func (p *MigratePredicate) Clone() core.FitPredicate {
|
||||
}
|
||||
|
||||
func (p *MigratePredicate) PreExecute(u *core.Unit, cs []core.Candidater) (bool, error) {
|
||||
return len(u.SchedData().HostID) > 0, nil
|
||||
return len(u.SchedData().HostId) > 0, nil
|
||||
}
|
||||
|
||||
func (p *MigratePredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core.PredicateFailureReason, error) {
|
||||
h := predicates.NewPredicateHelper(p, u, c)
|
||||
|
||||
if u.SchedData().HostID == c.IndexKey() {
|
||||
if u.SchedData().HostId == c.IndexKey() {
|
||||
h.Exclude(predicates.ErrHostIsSpecifiedForMigration)
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func (p *NestPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core.P
|
||||
|
||||
d := u.SchedData()
|
||||
|
||||
if d.Meta["kvm"] == "enabled" {
|
||||
if d.Metadata["kvm"] == "enabled" {
|
||||
if hc.Metadata["nest"] != "enabled" {
|
||||
h.Exclude(predicates.ErrNotSupportNest)
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
|
||||
computeapi "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/algorithm/plugin"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/algorithm/predicates"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/api"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@ func (p *NetworkPredicate) Clone() core.FitPredicate {
|
||||
|
||||
func (p *NetworkPredicate) PreExecute(u *core.Unit, cs []core.Candidater) (bool, error) {
|
||||
data := u.SchedData()
|
||||
if len(data.HostID) > 0 && len(data.Networks) == 0 {
|
||||
if len(data.HostId) > 0 && len(data.Networks) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func (p *NetworkPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
d := u.SchedData()
|
||||
|
||||
isMigrate := func() bool {
|
||||
return len(d.HostID) > 0
|
||||
return len(d.HostId) > 0
|
||||
}
|
||||
|
||||
// ServerType's value is 'guest', 'container' or ''(support all type) will return true.
|
||||
@@ -98,7 +98,7 @@ func (p *NetworkPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
appendError(predicates.ErrWireIsNotMatch)
|
||||
}
|
||||
|
||||
if !((!private && n.IsPublic) || (private && !n.IsPublic && n.ProjectId == d.OwnerTenantID)) {
|
||||
if !((!private && n.IsPublic) || (private && !n.IsPublic && n.ProjectId == d.Project)) {
|
||||
appendError(predicates.ErrNotOwner)
|
||||
}
|
||||
|
||||
@@ -131,9 +131,9 @@ func (p *NetworkPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
h.SetCapacityCounter(counters)
|
||||
}
|
||||
|
||||
isNetworkAvaliable := func(n *api.Network, counters *core.MinCounters,
|
||||
isNetworkAvaliable := func(n *computeapi.NetworkConfig, counters *core.MinCounters,
|
||||
networks []models.SNetwork) string {
|
||||
if n.Idx == "" {
|
||||
if n.Network == "" {
|
||||
counters0 := core.NewCounters()
|
||||
ret_msg := isRandomNetworkAvailable(n.Private, n.Exit, n.Wire, counters0)
|
||||
counters.Add(counters0)
|
||||
@@ -150,17 +150,17 @@ func (p *NetworkPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
errMsgs = append(errMsgs, fmt.Sprintf("%v(%v): server type not matched", net.Name, net.ID))
|
||||
continue
|
||||
}*/
|
||||
if !(n.Idx == net.GetId() || n.Idx == net.GetName()) {
|
||||
if !(n.Network == net.GetId() || n.Network == net.GetName()) {
|
||||
errMsgs = append(errMsgs, fmt.Sprintf("%v(%v): id/name not matched", net.Name, net.Id))
|
||||
} else if !(net.IsPublic || net.ProjectId == d.OwnerTenantID) {
|
||||
errMsgs = append(errMsgs, fmt.Sprintf("%v(%v): not owner (%v != %v)", net.Name, net.Id, net.ProjectId, d.OwnerTenantID))
|
||||
} else if !(net.IsPublic || net.ProjectId == d.Project) {
|
||||
errMsgs = append(errMsgs, fmt.Sprintf("%v(%v): not owner (%v != %v)", net.Name, net.Id, net.ProjectId, d.Project))
|
||||
} else if !(net.GetPorts() > 0 || isMigrate()) {
|
||||
errMsgs = append(errMsgs, fmt.Sprintf("%v(%v): ports use up", net.Name, net.Id))
|
||||
} else {
|
||||
// add resource
|
||||
reservedNetworks := 0
|
||||
counter := counterOfNetwork(u, &net, reservedNetworks)
|
||||
if counter.GetCount() < d.Count {
|
||||
if counter.GetCount() < int64(d.Count) {
|
||||
errMsgs = append(errMsgs, fmt.Sprintf("%s: ports not enough, free: %d, required: %d", net.Name, counter.GetCount(), d.Count))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func (p *StoragePredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
d := u.SchedData()
|
||||
|
||||
isMigrate := func() bool {
|
||||
return len(d.HostID) > 0
|
||||
return len(d.HostId) > 0
|
||||
}
|
||||
|
||||
isLocalhostBackend := func(backend string) bool {
|
||||
@@ -72,7 +72,7 @@ func (p *StoragePredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
ss := make([]string, 0, len(d.Disks))
|
||||
for _, disk := range d.Disks {
|
||||
if disk.Backend == backend {
|
||||
ss = append(ss, fmt.Sprintf("%v", disk.Size))
|
||||
ss = append(ss, fmt.Sprintf("%v", disk.SizeMb))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,16 +97,16 @@ func (p *StoragePredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
storeRequest := make(map[string]int64, 0)
|
||||
for _, disk := range d.Disks {
|
||||
if isMigrate() && !isLocalhostBackend(disk.Backend) {
|
||||
storeRequest[*disk.Storage] = 1
|
||||
storeRequest[disk.Storage] = 1
|
||||
} else {
|
||||
if _, ok := sizeRequest[disk.Backend]; !ok {
|
||||
sizeRequest[disk.Backend] = map[string]int64{"max": -1, "total": 0}
|
||||
}
|
||||
max := sizeRequest[disk.Backend]["max"]
|
||||
if max < disk.Size {
|
||||
sizeRequest[disk.Backend]["max"] = disk.Size
|
||||
if max < int64(disk.SizeMb) {
|
||||
sizeRequest[disk.Backend]["max"] = int64(disk.SizeMb)
|
||||
}
|
||||
sizeRequest[disk.Backend]["total"] += disk.Size
|
||||
sizeRequest[disk.Backend]["total"] += int64(disk.SizeMb)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
computeapi "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/api"
|
||||
"yunion.io/x/onecloud/pkg/util/conditionparser"
|
||||
)
|
||||
|
||||
type ISchedtagPredicate interface {
|
||||
GetExcludeTags() []api.Schedtag
|
||||
GetRequireTags() []api.Schedtag
|
||||
GetAvoidTags() []api.Schedtag
|
||||
GetPreferTags() []api.Schedtag
|
||||
GetExcludeTags() []computeapi.SchedtagConfig
|
||||
GetRequireTags() []computeapi.SchedtagConfig
|
||||
GetAvoidTags() []computeapi.SchedtagConfig
|
||||
GetPreferTags() []computeapi.SchedtagConfig
|
||||
}
|
||||
|
||||
type ISchedtagCandidate interface {
|
||||
@@ -28,14 +28,14 @@ type ISchedtagCandidate interface {
|
||||
}
|
||||
|
||||
type SchedtagPredicate struct {
|
||||
requireTags []api.Schedtag
|
||||
execludeTags []api.Schedtag
|
||||
preferTags []api.Schedtag
|
||||
avoidTags []api.Schedtag
|
||||
requireTags []computeapi.SchedtagConfig
|
||||
execludeTags []computeapi.SchedtagConfig
|
||||
preferTags []computeapi.SchedtagConfig
|
||||
avoidTags []computeapi.SchedtagConfig
|
||||
checker *SchedtagChecker
|
||||
}
|
||||
|
||||
func NewSchedtagPredicate(reqTags []api.Schedtag, allTags []models.SSchedtag) *SchedtagPredicate {
|
||||
func NewSchedtagPredicate(reqTags []*computeapi.SchedtagConfig, allTags []models.SSchedtag) *SchedtagPredicate {
|
||||
p := new(SchedtagPredicate)
|
||||
requireTags, execludeTags, preferTags, avoidTags := GetRequestSchedtags(reqTags, allTags)
|
||||
p.requireTags = requireTags
|
||||
@@ -46,19 +46,19 @@ func NewSchedtagPredicate(reqTags []api.Schedtag, allTags []models.SSchedtag) *S
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *SchedtagPredicate) GetExcludeTags() []api.Schedtag {
|
||||
func (p *SchedtagPredicate) GetExcludeTags() []computeapi.SchedtagConfig {
|
||||
return p.execludeTags
|
||||
}
|
||||
|
||||
func (p *SchedtagPredicate) GetRequireTags() []api.Schedtag {
|
||||
func (p *SchedtagPredicate) GetRequireTags() []computeapi.SchedtagConfig {
|
||||
return p.requireTags
|
||||
}
|
||||
|
||||
func (p *SchedtagPredicate) GetAvoidTags() []api.Schedtag {
|
||||
func (p *SchedtagPredicate) GetAvoidTags() []computeapi.SchedtagConfig {
|
||||
return p.avoidTags
|
||||
}
|
||||
|
||||
func (p *SchedtagPredicate) GetPreferTags() []api.Schedtag {
|
||||
func (p *SchedtagPredicate) GetPreferTags() []computeapi.SchedtagConfig {
|
||||
return p.preferTags
|
||||
}
|
||||
|
||||
@@ -66,12 +66,12 @@ func (p *SchedtagPredicate) Check(candidate ISchedtagCandidate) error {
|
||||
return p.checker.Check(p, candidate)
|
||||
}
|
||||
|
||||
func GetSchedtagCount(inTags []api.Schedtag, objTags []models.SSchedtag, strategy string) (countMap map[string]int) {
|
||||
func GetSchedtagCount(inTags []computeapi.SchedtagConfig, objTags []models.SSchedtag, strategy string) (countMap map[string]int) {
|
||||
countMap = make(map[string]int)
|
||||
|
||||
in := func(objTag models.SSchedtag, inTags []api.Schedtag) bool {
|
||||
in := func(objTag models.SSchedtag, inTags []computeapi.SchedtagConfig) bool {
|
||||
for _, tag := range inTags {
|
||||
if tag.Idx == objTag.Id || tag.Idx == objTag.Name {
|
||||
if tag.Id == objTag.Id || tag.Id == objTag.Name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -94,31 +94,31 @@ func GetAllSchedtags(resType string) ([]models.SSchedtag, error) {
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
func GetRequestSchedtags(reqTags []api.Schedtag, allTags []models.SSchedtag) (requireTags, execludeTags, preferTags, avoidTags []api.Schedtag) {
|
||||
requireTags = make([]api.Schedtag, 0)
|
||||
execludeTags = make([]api.Schedtag, 0)
|
||||
preferTags = make([]api.Schedtag, 0)
|
||||
avoidTags = make([]api.Schedtag, 0)
|
||||
func GetRequestSchedtags(reqTags []*computeapi.SchedtagConfig, allTags []models.SSchedtag) (requireTags, execludeTags, preferTags, avoidTags []computeapi.SchedtagConfig) {
|
||||
requireTags = make([]computeapi.SchedtagConfig, 0)
|
||||
execludeTags = make([]computeapi.SchedtagConfig, 0)
|
||||
preferTags = make([]computeapi.SchedtagConfig, 0)
|
||||
avoidTags = make([]computeapi.SchedtagConfig, 0)
|
||||
|
||||
appendedTagIds := make(map[string]int)
|
||||
|
||||
appendTagByStrategy := func(tag api.Schedtag) {
|
||||
appendTagByStrategy := func(tag *computeapi.SchedtagConfig) {
|
||||
switch tag.Strategy {
|
||||
case models.STRATEGY_REQUIRE:
|
||||
requireTags = append(requireTags, tag)
|
||||
requireTags = append(requireTags, *tag)
|
||||
case models.STRATEGY_EXCLUDE:
|
||||
execludeTags = append(execludeTags, tag)
|
||||
execludeTags = append(execludeTags, *tag)
|
||||
case models.STRATEGY_PREFER:
|
||||
preferTags = append(preferTags, tag)
|
||||
preferTags = append(preferTags, *tag)
|
||||
case models.STRATEGY_AVOID:
|
||||
avoidTags = append(avoidTags, tag)
|
||||
avoidTags = append(avoidTags, *tag)
|
||||
}
|
||||
}
|
||||
|
||||
for _, tag := range reqTags {
|
||||
appendTagByStrategy(tag)
|
||||
|
||||
appendedTagIds[tag.Idx] = 1
|
||||
appendedTagIds[tag.Id] = 1
|
||||
}
|
||||
|
||||
for _, tag := range allTags {
|
||||
@@ -126,7 +126,7 @@ func GetRequestSchedtags(reqTags []api.Schedtag, allTags []models.SSchedtag) (re
|
||||
_, idOk := appendedTagIds[tag.Id]
|
||||
|
||||
if !(nameOk || idOk) {
|
||||
apiTag := api.Schedtag{Idx: tag.Id, Strategy: tag.DefaultStrategy}
|
||||
apiTag := &computeapi.SchedtagConfig{Id: tag.Id, Strategy: tag.DefaultStrategy}
|
||||
appendTagByStrategy(apiTag)
|
||||
}
|
||||
}
|
||||
@@ -136,11 +136,11 @@ func GetRequestSchedtags(reqTags []api.Schedtag, allTags []models.SSchedtag) (re
|
||||
|
||||
type SchedtagChecker struct{}
|
||||
|
||||
type apiTags []api.Schedtag
|
||||
type apiTags []computeapi.SchedtagConfig
|
||||
|
||||
func (t apiTags) contains(objTag models.SSchedtag) bool {
|
||||
for _, tag := range t {
|
||||
if tag.Idx == objTag.Id || tag.Idx == objTag.Name {
|
||||
if tag.Id == objTag.Id || tag.Id == objTag.Name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -149,25 +149,25 @@ func (t apiTags) contains(objTag models.SSchedtag) bool {
|
||||
|
||||
type objTags []models.SSchedtag
|
||||
|
||||
func (t objTags) contains(atag api.Schedtag) bool {
|
||||
func (t objTags) contains(atag computeapi.SchedtagConfig) bool {
|
||||
for _, tag := range t {
|
||||
if tag.Id == atag.Idx || tag.Name == atag.Idx {
|
||||
if tag.Id == atag.Id || tag.Name == atag.Id {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *SchedtagChecker) contains(tags []api.Schedtag, objTag models.SSchedtag) bool {
|
||||
func (c *SchedtagChecker) contains(tags []computeapi.SchedtagConfig, objTag models.SSchedtag) bool {
|
||||
for _, tag := range tags {
|
||||
if tag.Idx == objTag.Id || tag.Idx == objTag.Name {
|
||||
if tag.Id == objTag.Id || tag.Id == objTag.Name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *SchedtagChecker) HasIntersection(tags []api.Schedtag, objTags []models.SSchedtag) (bool, *models.SSchedtag) {
|
||||
func (c *SchedtagChecker) HasIntersection(tags []computeapi.SchedtagConfig, objTags []models.SSchedtag) (bool, *models.SSchedtag) {
|
||||
var atags apiTags = tags
|
||||
for _, objTag := range objTags {
|
||||
if atags.contains(objTag) {
|
||||
@@ -177,7 +177,7 @@ func (c *SchedtagChecker) HasIntersection(tags []api.Schedtag, objTags []models.
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (c *SchedtagChecker) Contains(objectTags []models.SSchedtag, tags []api.Schedtag) (bool, *api.Schedtag) {
|
||||
func (c *SchedtagChecker) Contains(objectTags []models.SSchedtag, tags []computeapi.SchedtagConfig) (bool, *computeapi.SchedtagConfig) {
|
||||
var otags objTags = objectTags
|
||||
for _, tag := range tags {
|
||||
if !otags.contains(tag) {
|
||||
@@ -245,17 +245,21 @@ func (c *SchedtagChecker) Check(p ISchedtagPredicate, candidate ISchedtagCandida
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
execludeTags := p.GetExcludeTags()
|
||||
requireTags := p.GetRequireTags()
|
||||
|
||||
log.V(10).Debugf("[SchedtagChecker] check candidate: %s requireTags: %#v, execludeTags: %#v, candidateTags: %#v", candidate.IndexKey(), requireTags, execludeTags, candidateTags)
|
||||
|
||||
if len(execludeTags) > 0 {
|
||||
if ok, tag := c.HasIntersection(execludeTags, candidateTags); ok {
|
||||
return fmt.Errorf("Execlude by schedtag: '%s:%s'", tag.Name, tag.Id)
|
||||
}
|
||||
}
|
||||
|
||||
requireTags := p.GetRequireTags()
|
||||
if len(requireTags) > 0 {
|
||||
if ok, tag := c.Contains(candidateTags, requireTags); !ok {
|
||||
return fmt.Errorf("Need schedtag: '%s'", tag.Idx)
|
||||
return fmt.Errorf("Need schedtag: '%s'", tag.Id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ func (p *AvoidSameHostPriority) Map(u *core.Unit, c core.Candidater) (core.HostP
|
||||
return core.HostPriority{}, err
|
||||
}
|
||||
|
||||
ownerTenantID := u.SchedData().OwnerTenantID
|
||||
ownerTenantID := u.SchedData().Project
|
||||
if count, ok := hc.Tenants[ownerTenantID]; ok && count > 0 {
|
||||
h.SetFrontRawScore(-1 * int(count))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user