mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #12248 from ioito/automated-cherry-pick-of-#12247-upstream-release-3.8
Automated cherry pick of #12247: fix(scheduler): openstack scheduler options
This commit is contained in:
@@ -35,6 +35,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/compute/options"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
scheduler "yunion.io/x/onecloud/pkg/scheduler/options"
|
||||
"yunion.io/x/onecloud/pkg/util/billing"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
@@ -49,19 +50,19 @@ func init() {
|
||||
}
|
||||
|
||||
func (self *SOpenStackGuestDriver) DoScheduleCPUFilter() bool {
|
||||
return options.Options.SchedulerOptions.OpenStackSchedulerCPUFilter
|
||||
return scheduler.GetOptions().OpenstackSchedulerCPUFilter
|
||||
}
|
||||
|
||||
func (self *SOpenStackGuestDriver) DoScheduleMemoryFilter() bool {
|
||||
return options.Options.SchedulerOptions.OpenStackSchedulerMemoryFilter
|
||||
return scheduler.GetOptions().OpenstackSchedulerMemoryFilter
|
||||
}
|
||||
|
||||
func (self *SOpenStackGuestDriver) DoScheduleSKUFilter() bool {
|
||||
return options.Options.SchedulerOptions.OpenStackSchedulerSKUFilter
|
||||
return scheduler.GetOptions().OpenstackSchedulerSKUFilter
|
||||
}
|
||||
|
||||
func (self *SOpenStackGuestDriver) DoScheduleStorageFilter() bool {
|
||||
return options.Options.SchedulerOptions.OpenStackSchedulerStorageFilter
|
||||
return scheduler.GetOptions().OpenstackSchedulerStorageFilter
|
||||
}
|
||||
|
||||
func (self *SOpenStackGuestDriver) GetHypervisor() string {
|
||||
|
||||
@@ -176,15 +176,6 @@ type ComputeOptions struct {
|
||||
ProhibitRefreshingCloudImage bool `help:"Prohibit refreshing cloud image"`
|
||||
|
||||
esxi.EsxiOptions
|
||||
|
||||
SchedulerOptions
|
||||
}
|
||||
|
||||
type SchedulerOptions struct {
|
||||
OpenStackSchedulerCPUFilter bool `help:"Scheduler OpenStack usable host by cpu" default:"true"`
|
||||
OpenStackSchedulerMemoryFilter bool `help:"Scheduler OpenStack usable host by memory" default:"true"`
|
||||
OpenStackSchedulerStorageFilter bool `help:"Scheduler OpenStack usable host by storage" default:"true"`
|
||||
OpenStackSchedulerSKUFilter bool `help:"Scheduler OpenStack usable host by sku" default:"false"`
|
||||
}
|
||||
|
||||
type SCapabilityOptions struct {
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"os"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/scheduler"
|
||||
common_optoins "yunion.io/x/onecloud/pkg/cloudcommon/options"
|
||||
common_options "yunion.io/x/onecloud/pkg/cloudcommon/options"
|
||||
"yunion.io/x/onecloud/pkg/compute/options"
|
||||
)
|
||||
|
||||
@@ -89,6 +89,34 @@ type SchedOptions struct {
|
||||
WireDBCachePeriod string `help:"Wire database cache period" default:"5m"`
|
||||
|
||||
SkuRefreshInterval string `help:"Server SKU refresh interval" default:"12h"`
|
||||
|
||||
OpenstackOptions
|
||||
}
|
||||
|
||||
type OpenstackOptions struct {
|
||||
OpenstackSchedulerCPUFilter bool `help:"Scheduler OpenStack usable host by cpu" default:"true"`
|
||||
OpenstackSchedulerMemoryFilter bool `help:"Scheduler OpenStack usable host by memory" default:"true"`
|
||||
OpenstackSchedulerStorageFilter bool `help:"Scheduler OpenStack usable host by storage" default:"true"`
|
||||
OpenstackSchedulerSKUFilter bool `help:"Scheduler OpenStack usable host by sku" default:"false"`
|
||||
}
|
||||
|
||||
func OnOpenstackOptionsChange(oOpts, nOpts interface{}) bool {
|
||||
oldOpts := oOpts.(*OpenstackOptions)
|
||||
newOpts := nOpts.(*OpenstackOptions)
|
||||
|
||||
if oldOpts.OpenstackSchedulerCPUFilter != newOpts.OpenstackSchedulerCPUFilter {
|
||||
return true
|
||||
}
|
||||
if oldOpts.OpenstackSchedulerMemoryFilter != newOpts.OpenstackSchedulerMemoryFilter {
|
||||
return true
|
||||
}
|
||||
if oldOpts.OpenstackSchedulerStorageFilter != newOpts.OpenstackSchedulerStorageFilter {
|
||||
return true
|
||||
}
|
||||
if oldOpts.OpenstackSchedulerSKUFilter != newOpts.OpenstackSchedulerSKUFilter {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -100,6 +128,25 @@ func GetOptions() *SchedulerOptions {
|
||||
}
|
||||
|
||||
func Init() {
|
||||
common_optoins.ParseOptions(&opt, os.Args, "region.conf", api.SERVICE_TYPE)
|
||||
common_options.ParseOptions(&opt, os.Args, "region.conf", api.SERVICE_TYPE)
|
||||
options.Options = opt.ComputeOptions
|
||||
}
|
||||
|
||||
func OnOptionsChange(oldO, newO interface{}) bool {
|
||||
oldOpts := oldO.(*SchedulerOptions)
|
||||
newOpts := newO.(*SchedulerOptions)
|
||||
|
||||
changed := false
|
||||
if common_options.OnCommonOptionsChange(&oldOpts.CommonOptions, &newOpts.CommonOptions) {
|
||||
changed = true
|
||||
}
|
||||
if common_options.OnDBOptionsChange(&oldOpts.DBOptions, &newOpts.DBOptions) {
|
||||
changed = true
|
||||
}
|
||||
|
||||
if OnOptionsChange(&oldOpts.OpenstackOptions, &newOpts.OpenstackOptions) {
|
||||
changed = true
|
||||
}
|
||||
|
||||
return changed
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import (
|
||||
_ "yunion.io/x/onecloud/pkg/compute/guestdrivers"
|
||||
_ "yunion.io/x/onecloud/pkg/compute/hostdrivers"
|
||||
computemodels "yunion.io/x/onecloud/pkg/compute/models"
|
||||
compute_options "yunion.io/x/onecloud/pkg/compute/options"
|
||||
_ "yunion.io/x/onecloud/pkg/scheduler/algorithmprovider"
|
||||
skuman "yunion.io/x/onecloud/pkg/scheduler/data_manager/sku"
|
||||
schedhandler "yunion.io/x/onecloud/pkg/scheduler/handler"
|
||||
@@ -91,7 +90,7 @@ func StartService() error {
|
||||
startSched()
|
||||
})
|
||||
|
||||
common_options.StartOptionManager(&opts.ComputeOptions, opts.ConfigSyncPeriodSeconds, compute_api.SERVICE_TYPE, compute_api.SERVICE_VERSION, compute_options.OnOptionsChange)
|
||||
common_options.StartOptionManager(&opts, opts.ConfigSyncPeriodSeconds, compute_api.SERVICE_TYPE, compute_api.SERVICE_VERSION, o.OnOptionsChange)
|
||||
|
||||
app := app_common.InitApp(&opts.BaseOptions, true)
|
||||
cloudcommon.AppDBInit(app)
|
||||
|
||||
Reference in New Issue
Block a user