diff --git a/pkg/scheduler/algorithm/predicates/guest/status_predicate.go b/pkg/scheduler/algorithm/predicates/guest/status_predicate.go index 30a7709a96..0eadfd5565 100644 --- a/pkg/scheduler/algorithm/predicates/guest/status_predicate.go +++ b/pkg/scheduler/algorithm/predicates/guest/status_predicate.go @@ -50,6 +50,10 @@ func (p *StatusPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core h.Exclude2("enable_status", curEnableStatus, true) } + if hc.Zone.Status != ExpectedEnableStatus { + h.Exclude2("zone_status", hc.Zone.Status, ExpectedEnableStatus) + } + if hc.Cloudprovider != nil { if hc.Cloudprovider.Status != models.CLOUD_PROVIDER_CONNECTED { h.Exclude2("cloud_provider_status", hc.Cloudprovider.Status, models.CLOUD_PROVIDER_CONNECTED) diff --git a/pkg/scheduler/cache/candidate/desc.go b/pkg/scheduler/cache/candidate/desc.go index 5779b97cf1..fe4fdf3f38 100644 --- a/pkg/scheduler/cache/candidate/desc.go +++ b/pkg/scheduler/cache/candidate/desc.go @@ -40,7 +40,7 @@ type baseHostDesc struct { NodeCount int64 `json:"node_count"` Tenants map[string]int64 `json:"tenants"` ZoneID string `json:"zone_id"` - Zone string `json:"zone"` + Zone *models.Zone `json:"zone"` PoolID string `json:"pool_id"` ClusterID string `json:"cluster_id"` Aggregates []*models.Aggregate `json:"aggregates"` @@ -110,7 +110,7 @@ func (b baseHostDesc) GetSchedDesc() *jsonutils.JSONDict { desc.Add(jsonutils.NewInt(b.MemSize), "mem_size") desc.Add(jsonutils.NewString(b.HostType), "host_type") desc.Add(jsonutils.NewString(b.ZoneID), "zone_id") - desc.Add(jsonutils.NewString(b.Zone), "zone") + desc.Add(jsonutils.NewString(b.Zone.Name), "zone") desc.Add(jsonutils.NewString(b.ResourceType), "resource_type") if b.Cloudprovider != nil { @@ -146,8 +146,7 @@ func (b *baseHostDesc) fillZone(host *models.Host) error { if err != nil { return err } - b.ZoneID = zone.ID - b.Zone = zone.Name + b.Zone = zone return nil } diff --git a/pkg/scheduler/db/models/zone.go b/pkg/scheduler/db/models/zone.go index b55a4f7737..745d7b2f27 100644 --- a/pkg/scheduler/db/models/zone.go +++ b/pkg/scheduler/db/models/zone.go @@ -6,6 +6,7 @@ import ( type Zone struct { StandaloneModel + Status string `json:"status" gorm:"column:status;not null"` Location string `gorm:"column:location"` ManagerUri string `gorm:"column:manager_uri"` CloudregionId string `gorm:"column:cloudregion_id"`