Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using lease for cluster remote server healthz checker. #249

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 20 additions & 23 deletions cmd/yurthub/app/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/openyurtio/openyurt/pkg/yurthub/cachemanager"
"github.com/openyurtio/openyurt/pkg/yurthub/certificate"
"github.com/openyurtio/openyurt/pkg/yurthub/certificate/hubself"
"github.com/openyurtio/openyurt/pkg/yurthub/certificate/initializer"
"github.com/openyurtio/openyurt/pkg/yurthub/certificate/kubelet"
"github.com/openyurtio/openyurt/pkg/yurthub/gc"
"github.com/openyurtio/openyurt/pkg/yurthub/healthchecker"
Expand Down Expand Up @@ -89,16 +88,25 @@ func Run(cfg *config.YurtHubConfiguration, stopCh <-chan struct{}) error {
}
trace++

klog.Infof("%d. create health checker for remote servers ", trace)
healthChecker, err := healthchecker.NewHealthChecker(cfg.RemoteServers, transportManager, cfg.HeartbeatFailedRetry, cfg.HeartbeatHealthyThreshold, stopCh)
klog.Infof("%d. create storage manager", trace)
storageManager, err := factory.CreateStorage()
if err != nil {
klog.Errorf("could not new health checker, %v", err)
klog.Errorf("could not create storage manager, %v", err)
return err
}
storageWrapper := cachemanager.NewStorageWrapper(storageManager)
trace++

klog.Infof("%d. new serializer manager", trace)
serializerManager := serializer.NewSerializerManager()
trace++

klog.Infof("%d. init cert initializer", trace)
cmInitializer := initializer.NewCMInitializer(healthChecker)
klog.Infof("%d. new cache manager with storage wrapper and serializer manager", trace)
cacheMgr, err := cachemanager.NewCacheManager(storageWrapper, serializerManager)
if err != nil {
klog.Errorf("could not new cache manager, %v", err)
return err
}
trace++

klog.Infof("%d. register cert managers", trace)
Expand All @@ -108,7 +116,7 @@ func Run(cfg *config.YurtHubConfiguration, stopCh <-chan struct{}) error {
trace++

klog.Infof("%d. create cert manager with %s mode", trace, cfg.CertMgrMode)
certManager, err := cmr.New(cfg.CertMgrMode, cfg, cmInitializer)
certManager, err := cmr.New(cfg.CertMgrMode, cfg)
if err != nil {
klog.Errorf("could not create certificate manager, %v", err)
return err
Expand All @@ -123,25 +131,13 @@ func Run(cfg *config.YurtHubConfiguration, stopCh <-chan struct{}) error {
}
trace++

klog.Infof("%d. create storage manager", trace)
storageManager, err := factory.CreateStorage()
if err != nil {
klog.Errorf("could not create storage manager, %v", err)
return err
}
storageWrapper := cachemanager.NewStorageWrapper(storageManager)
trace++

klog.Infof("%d. new serializer manager", trace)
serializerManager := serializer.NewSerializerManager()
trace++

klog.Infof("%d. new cache manager with storage wrapper and serializer manager", trace)
cacheMgr, err := cachemanager.NewCacheManager(storageWrapper, serializerManager)
klog.Infof("%d. create health checker for remote servers ", trace)
healthChecker, err := healthchecker.NewHealthChecker(cfg, transportManager, storageWrapper, stopCh)
if err != nil {
klog.Errorf("could not new cache manager, %v", err)
klog.Errorf("could not new health checker, %v", err)
return err
}
healthChecker.Run()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not add healthChecker.Run() after healthchecker.NewHealthChecker()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

trace++

klog.Infof("%d. new gc manager for node %s, and gc frequency is a random time between %d min and %d min", trace, cfg.NodeName, cfg.GCFrequency, 3*cfg.GCFrequency)
Expand All @@ -164,6 +160,7 @@ func Run(cfg *config.YurtHubConfiguration, stopCh <-chan struct{}) error {
klog.Infof("%d. new %s server and begin to serve, proxy server: %s, hub server: %s", trace, projectinfo.GetHubName(), cfg.YurtHubProxyServerAddr, cfg.YurtHubServerAddr)
s := server.NewYurtHubServer(cfg, certManager, yurtProxyHandler)
s.Run()

<-stopCh
return nil
}
11 changes: 10 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,35 @@ go 1.13
require (
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.61.355
github.com/beorn7/perks v1.0.1 // indirect
github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd
github.com/docker/docker v17.12.0-ce-rc1.0.20200531234253-77e06fda0c94+incompatible // indirect
github.com/emicklei/go-restful v2.12.0+incompatible // indirect
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/go-openapi/spec v0.19.8 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.1
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/gorilla/mux v1.7.4
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.9 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/ginkgo v1.13.0
github.com/onsi/gomega v1.10.1
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/prometheus/client_golang v1.7.1
github.com/prometheus/procfs v0.0.11 // indirect
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect
google.golang.org/grpc v1.27.0
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
k8s.io/api v0.17.7
k8s.io/apiextensions-apiserver v0.17.7 // indirect
k8s.io/apimachinery v0.17.7
k8s.io/apiserver v0.16.9
k8s.io/client-go v0.17.7
Expand All @@ -34,7 +44,6 @@ require (
k8s.io/kubernetes v1.18.3
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451
sigs.k8s.io/apiserver-network-proxy v0.0.15
sigs.k8s.io/controller-runtime v0.5.7
sigs.k8s.io/yaml v1.2.0 // indirect
)

Expand Down
Loading