From c0102d0a32bfe2c0307c3cf4d71e0aa9eadfbe66 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Sat, 5 Jan 2019 17:50:53 +0800 Subject: [PATCH] =?UTF-8?q?scheduler:=20host=20=E7=9A=84=20zone=20status?= =?UTF-8?q?=20=E4=B8=BA=20enable=20=E6=97=B6=E6=89=8D=E8=83=BD=E8=B0=83?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithm/predicates/guest/status_predicate.go | 4 ++++ pkg/scheduler/cache/candidate/desc.go | 7 +++---- pkg/scheduler/db/models/zone.go | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) 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"`