diff --git a/pkg/apis/compute/host.go b/pkg/apis/compute/host.go index 27a371e5b5..a8c2447a45 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"` + // 允许开启宿主机健康检查 + 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 81e0fc0694..a49112d19e 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.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 {