mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix(scheduler): cloudprovider predicate (#20313)
This commit is contained in:
@@ -45,7 +45,7 @@ func (p *CloudproviderSchedtagPredicate) Clone() core.FitPredicate {
|
||||
|
||||
func (p *CloudproviderSchedtagPredicate) PreExecute(ctx context.Context, u *core.Unit, cs []core.Candidater) (bool, error) {
|
||||
driver := u.GetHypervisorDriver()
|
||||
if driver != nil && !driver.DoScheduleCloudproviderTagFilter() {
|
||||
if driver == nil || !driver.DoScheduleCloudproviderTagFilter() {
|
||||
return false, nil
|
||||
}
|
||||
return p.ServerBaseSchedtagPredicate.PreExecute(ctx, u, cs)
|
||||
|
||||
@@ -60,7 +60,8 @@ func (b *BasePredicate) PreExecute(ctx context.Context, unit *core.Unit, candis
|
||||
}
|
||||
|
||||
func (b *BasePredicate) GetHypervisorDriver(u *core.Unit) models.IGuestDriver {
|
||||
driver, _ := models.GetDriver(u.GetHypervisor(), u.SchedInfo.Provider)
|
||||
hypervisor := u.GetHypervisor()
|
||||
driver, _ := models.GetDriver(hypervisor, u.SchedInfo.Provider)
|
||||
return driver
|
||||
}
|
||||
|
||||
@@ -346,7 +347,11 @@ func (w SchedtagResourceW) GetDynamicSchedDesc() *jsonutils.JSONDict {
|
||||
}
|
||||
|
||||
func (p *BaseSchedtagPredicate) GetHypervisorDriver() models.IGuestDriver {
|
||||
driver, _ := models.GetDriver(p.Hypervisor, p.Provider)
|
||||
hypervisor := p.Hypervisor
|
||||
if hypervisor == api.HostHypervisorForKvm {
|
||||
hypervisor = api.SchedTypeKvm
|
||||
}
|
||||
driver, _ := models.GetDriver(hypervisor, p.Provider)
|
||||
return driver
|
||||
}
|
||||
|
||||
@@ -413,6 +418,7 @@ func (p *BaseSchedtagPredicate) PreExecute(ctx context.Context, sp ISchedtagPred
|
||||
}
|
||||
|
||||
p.Hypervisor = u.GetHypervisor()
|
||||
p.Provider = u.SchedInfo.Provider
|
||||
|
||||
// always do select step
|
||||
u.AppendSelectPlugin(sp)
|
||||
|
||||
@@ -163,6 +163,9 @@ func NewSchedInfo(input *api.ScheduleInput) *SchedInfo {
|
||||
data.Provider = region.Provider
|
||||
}
|
||||
}
|
||||
if len(data.Provider) == 0 {
|
||||
data.Provider = computeapi.CLOUD_PROVIDER_ONECLOUD
|
||||
}
|
||||
|
||||
if data.Backup {
|
||||
if data.PreferBackupHost != "" {
|
||||
|
||||
@@ -447,11 +447,16 @@ func (u *Unit) SchedData() *api.SchedInfo {
|
||||
}
|
||||
|
||||
func (u *Unit) GetHypervisor() string {
|
||||
driver, _ := models.GetHostDriver(u.SchedInfo.Hypervisor, u.SchedInfo.Provider)
|
||||
if driver != nil {
|
||||
return driver.GetHypervisor()
|
||||
}
|
||||
return u.SchedData().Hypervisor
|
||||
}
|
||||
|
||||
func (u *Unit) GetHypervisorDriver() models.IGuestDriver {
|
||||
driver, _ := models.GetDriver(u.GetHypervisor(), u.SchedInfo.Provider)
|
||||
hypervisor := u.GetHypervisor()
|
||||
driver, _ := models.GetDriver(hypervisor, u.SchedInfo.Provider)
|
||||
return driver
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user