This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch v1.x
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/v1.x by this push:
new 898cee0 Feature: add cluster member list check option (#1154)
898cee0 is described below
commit 898cee00df0bad9f2929de415db3a96a24aef050
Author: little-cui <[email protected]>
AuthorDate: Fri Sep 17 09:51:33 2021 +0800
Feature: add cluster member list check option (#1154)
---
etc/conf/app.conf | 2 ++
server/plugin/registry/config.go | 2 ++
server/plugin/registry/etcd/etcd.go | 4 +++-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/etc/conf/app.conf b/etc/conf/app.conf
index d40cc50..c9e5675 100644
--- a/etc/conf/app.conf
+++ b/etc/conf/app.conf
@@ -79,6 +79,8 @@ auto_sync_interval = 30s
connect_timeout = 10s
# the timeout for failing to read response of registry
registry_timeout = 30s
+# check whether the cluster members list is the same as the 'manager_cluster'
+registry_check_cluster = true
# indicate how many revision you want to keep in etcd
compact_index_delta = 100
diff --git a/server/plugin/registry/config.go b/server/plugin/registry/config.go
index 2d17f34..70e0666 100644
--- a/server/plugin/registry/config.go
+++ b/server/plugin/registry/config.go
@@ -37,6 +37,7 @@ type Config struct {
ClusterName string `json:"manageName,omitempty"`
ClusterAddresses string `json:"manageClusters,omitempty"` //
the raw string of cluster configuration
Clusters types.Clusters `json:"-"` //
parsed from ClusterAddresses
+ ClusterCheck bool `json:"checkCluster,omitempty"`
DialTimeout time.Duration `json:"connectTimeout"`
RequestTimeOut time.Duration `json:"registryTimeout"`
AutoSyncInterval time.Duration `json:"autoSyncInterval"`
@@ -89,6 +90,7 @@ func Configuration() *Config {
defaultRegistryConfig.ClusterName =
beego.AppConfig.DefaultString("manager_name", DefaultClusterName)
defaultRegistryConfig.ManagerAddress =
beego.AppConfig.String("manager_addr")
defaultRegistryConfig.ClusterAddresses =
beego.AppConfig.DefaultString("manager_cluster", "http://127.0.0.1:2379")
+ defaultRegistryConfig.ClusterCheck =
beego.AppConfig.DefaultBool("registry_check_cluster", true)
defaultRegistryConfig.InitClusterInfo()
registryAddresses :=
strings.Join(defaultRegistryConfig.RegistryAddresses(), ",")
diff --git a/server/plugin/registry/etcd/etcd.go
b/server/plugin/registry/etcd/etcd.go
index 157bf62..837c4af 100644
--- a/server/plugin/registry/etcd/etcd.go
+++ b/server/plugin/registry/etcd/etcd.go
@@ -57,6 +57,7 @@ type Client struct {
DialTimeout time.Duration
TLSConfig *tls.Config
AutoSyncInterval time.Duration
+ ClusterCheck bool
err chan error
ready chan struct{}
@@ -87,6 +88,7 @@ func (c *Client) Initialize() (err error) {
if c.AutoSyncInterval == 0 {
c.AutoSyncInterval = registry.Configuration().AutoSyncInterval
}
+ c.ClusterCheck = registry.Configuration().ClusterCheck
c.Client, err = c.newClient()
if err != nil {
@@ -139,7 +141,7 @@ func (c *Client) newClient() (*clientv3.Client, error) {
registry.ReportBackendInstance(len(resp.Members))
- if len(c.Endpoints) == 1 {
+ if !c.ClusterCheck || len(c.Endpoints) == 1 {
// no need to check remote endpoints
return client, nil
}