From db2d02fe00c5953ede1dfcb58a402a5a5246b32f Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Thu, 30 Apr 2020 15:04:59 +0800 Subject: [PATCH 1/2] fix host details output --- pkg/apis/compute/host.go | 2 ++ pkg/compute/models/hosts.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/pkg/apis/compute/host.go b/pkg/apis/compute/host.go index 27a371e5b5..b1c3b5ff30 100644 --- a/pkg/apis/compute/host.go +++ b/pkg/apis/compute/host.go @@ -163,6 +163,8 @@ type HostDetails struct { IsPrepaidRecycle bool `json:"is_prepaid_recycle"` CanPrepare bool `json:"can_prepare"` PrepareFailReason string `json:"prepare_fail_reason"` + // 允许开启宿主机健康检查 + EnableHealthCheck bool `json:"enable_health_check"` // 标签 Metadata map[string]string `json:"metadata"` diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index 81e0fc0694..97ca9c8405 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -2606,6 +2606,9 @@ func (self *SHost) getMoreDetails(ctx context.Context, out api.HostDetails, show } } + if self.EnableHealthCheck && hostHealthChecker != nil { + out.EnableHealthCheck = true + } return out } From 9652c97dce2f724107ec03244b22c022b9bb895c Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Thu, 30 Apr 2020 18:33:56 +0800 Subject: [PATCH 2/2] fix host init without etcd --- pkg/apis/compute/host.go | 2 +- pkg/compute/models/hosts.go | 2 +- pkg/hostman/host_services.go | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/apis/compute/host.go b/pkg/apis/compute/host.go index b1c3b5ff30..a8c2447a45 100644 --- a/pkg/apis/compute/host.go +++ b/pkg/apis/compute/host.go @@ -164,7 +164,7 @@ type HostDetails struct { CanPrepare bool `json:"can_prepare"` PrepareFailReason string `json:"prepare_fail_reason"` // 允许开启宿主机健康检查 - EnableHealthCheck bool `json:"enable_health_check"` + AllowHealthCheck bool `json:"allow_health_check"` // 标签 Metadata map[string]string `json:"metadata"` diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index 97ca9c8405..a49112d19e 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -2607,7 +2607,7 @@ func (self *SHost) getMoreDetails(ctx context.Context, out api.HostDetails, show } if self.EnableHealthCheck && hostHealthChecker != nil { - out.EnableHealthCheck = true + out.AllowHealthCheck = true } return out } diff --git a/pkg/hostman/host_services.go b/pkg/hostman/host_services.go index a198ffd134..da8e2a2429 100644 --- a/pkg/hostman/host_services.go +++ b/pkg/hostman/host_services.go @@ -141,6 +141,9 @@ func (host *SHostService) initEtcdConfig() error { if err != nil { return errors.Wrap(err, "fetch etcd service info") } + if etcdEndpoint == nil { + return nil + } if len(options.HostOptions.EtcdEndpoints) == 0 { options.HostOptions.EtcdEndpoints = []string{etcdEndpoint.Url} if len(etcdEndpoint.CertId) > 0 {