refactor(host): host_health: do not import guestman

This commit is contained in:
Yousong Zhou
2020-12-10 11:48:05 +08:00
parent e7f618228b
commit 1e4c294fd9
3 changed files with 28 additions and 7 deletions
+2
View File
@@ -34,6 +34,7 @@ import (
"yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/appsrv"
"yunion.io/x/onecloud/pkg/hostman/guestman/types"
deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis"
"yunion.io/x/onecloud/pkg/hostman/hostutils"
"yunion.io/x/onecloud/pkg/hostman/options"
@@ -876,6 +877,7 @@ func Stop() {
func Init(host hostutils.IHost, serversPath string) {
if guestManager == nil {
guestManager = NewGuestManager(host, serversPath)
types.HealthCheckReactor = guestManager
}
}
+21
View File
@@ -0,0 +1,21 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package types
type IHealthCheckReactor interface {
ShutdownSharedStorageServers()
}
var HealthCheckReactor IHealthCheckReactor
+5 -7
View File
@@ -23,7 +23,7 @@ import (
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/utils"
"yunion.io/x/onecloud/pkg/hostman/guestman"
"yunion.io/x/onecloud/pkg/hostman/guestman/types"
"yunion.io/x/onecloud/pkg/hostman/options"
)
@@ -36,10 +36,9 @@ const (
)
type SHostHealthManager struct {
cli Client
status Status
guestManager *guestman.SGuestManager
onHostDown string
cli Client
status Status
onHostDown string
}
const SHUTDOWN_SERVERS = "shutdown-servers"
@@ -65,7 +64,6 @@ func InitHostHealthManager(hostId, onHostDown string) (*SHostHealthManager, erro
default:
return nil, fmt.Errorf("not support health driver %s", options.HostOptions.HealthDriver)
}
m.guestManager = guestman.GetGuestManager()
m.onHostDown = onHostDown
m.cli.SetOnUnhealthy(m.OnUnhealth)
if err := m.StartHealthCheck(); err != nil {
@@ -95,7 +93,7 @@ func (m *SHostHealthManager) SetOnHostDown(onHostDown string) {
// shutdown servers used shared storage
func (m *SHostHealthManager) shutdownServers() {
m.guestManager.ShutdownSharedStorageServers()
types.HealthCheckReactor.ShutdownSharedStorageServers()
}
func (m *SHostHealthManager) Stop() error {