optimized(scheduler): reduce sql query of mysql (#15878)

This commit is contained in:
Zexi Li
2023-01-31 19:30:58 +08:00
committed by GitHub
parent 99d250399a
commit 407c90ccfb
33 changed files with 971 additions and 313 deletions
@@ -22,6 +22,7 @@ import (
"yunion.io/x/onecloud/pkg/scheduler/algorithm/predicates"
"yunion.io/x/onecloud/pkg/scheduler/api"
"yunion.io/x/onecloud/pkg/scheduler/core"
"yunion.io/x/onecloud/pkg/scheduler/data_manager/schedtag"
)
const (
@@ -43,9 +44,9 @@ func (f *HypervisorPredicate) Clone() core.FitPredicate {
}
func hostHasContainerTag(c core.Candidater) bool {
aggs := c.Getter().HostSchedtags()
aggs := schedtag.GetCandidateSchedtags("hosts", c.Getter().Host().GetId())
for _, agg := range aggs {
if agg.Name == CONTAINER_ALLOWED_TAG {
if agg.GetName() == CONTAINER_ALLOWED_TAG {
return true
}
}
@@ -96,10 +96,6 @@ func (r hostSchedtagResW) Keyword() string {
return r.Candidater.Getter().Host().Keyword()
}
func (r hostSchedtagResW) GetSchedtags() []computemodels.SSchedtag {
return r.Candidater.Getter().HostSchedtags()
}
func (r hostSchedtagResW) GetSchedtagJointManager() computemodels.ISchedtagJointManager {
return r.Candidater.Getter().Host().GetSchedtagJointManager()
}
@@ -96,11 +96,6 @@ func (r zoneSchedtagResW) Keyword() string {
return r.zone.Keyword()
}
func (r zoneSchedtagResW) GetSchedtags() []computemodels.SSchedtag {
// TODO: not fetch schedtags from database, should get zone schedtags from r.c cache candidater
return r.zone.GetSchedtags()
}
func (r zoneSchedtagResW) GetSchedtagJointManager() computemodels.ISchedtagJointManager {
return r.zone.GetSchedtagJointManager()
}