From 2c515a7edd2db6ab308a41fc7ed5eae1211bf5ec Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Mon, 1 Apr 2019 20:39:34 +0800 Subject: [PATCH] fix: exclude hosts whose cloud provider's status not in CLOUD_PROVIDER_VALID_STATUS --- .../algorithm/predicates/guest/status_predicate.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/scheduler/algorithm/predicates/guest/status_predicate.go b/pkg/scheduler/algorithm/predicates/guest/status_predicate.go index 4902db81cb..86f791d08f 100644 --- a/pkg/scheduler/algorithm/predicates/guest/status_predicate.go +++ b/pkg/scheduler/algorithm/predicates/guest/status_predicate.go @@ -15,6 +15,8 @@ package guest import ( + "yunion.io/x/pkg/utils" + api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/scheduler/algorithm/predicates" "yunion.io/x/onecloud/pkg/scheduler/core" @@ -68,8 +70,8 @@ func (p *StatusPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core } if hc.Cloudprovider != nil { - if hc.Cloudprovider.Status != api.CLOUD_PROVIDER_CONNECTED { - h.Exclude2("cloud_provider_status", hc.Cloudprovider.Status, api.CLOUD_PROVIDER_CONNECTED) + if !utils.IsInStringArray(hc.Cloudprovider.Status, api.CLOUD_PROVIDER_VALID_STATUS) { + h.Exclude2("cloud_provider_status", hc.Cloudprovider.Status, api.CLOUD_PROVIDER_VALID_STATUS) } if hc.Cloudprovider.HealthStatus != api.CLOUD_PROVIDER_HEALTH_NORMAL { h.Exclude2("cloud_provider_health_status", hc.Cloudprovider.HealthStatus, api.CLOUD_PROVIDER_HEALTH_NORMAL)