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

gaea连接etcd,当第一个节点异常时,无法连接配置的其他节点 #244

Open
lulufeiacount opened this issue May 30, 2023 · 1 comment

Comments

@lulufeiacount
Copy link

  • gaea代码
        endpoints := strings.Split(addr, ",")
	config := clientv3.Config{
		Endpoints:            endpoints,
		Username:             username,
		Password:             passwd,
		DialTimeout:          timeout, // 只设定第一次连线时间的逾时,之后不用太担心连线,连线失败后,会自动重连
		DialKeepAliveTimeout: timeout, // 之后维持 etcd 连线的逾时
		TLS:                  tlsConf,
	}
	c, err := clientv3.New(config)
	if err != nil {
		return nil, err
	}
  • etcd中clientv3.New(config)源码
        client.balancer = newHealthBalancer(cfg.Endpoints, cfg.DialTimeout, func(ep string) (bool, error) {
		return grpcHealthCheck(client, ep)
	})

	// use Endpoints[0] so that for https:// without any tls config given, then
	// grpc will assume the certificate server name is the endpoint host.
	conn, err := client.dial(cfg.Endpoints[0], grpc.WithBalancer(client.balancer))
	if err != nil {
		client.cancel()
		client.balancer.Close()
		return nil, err
	}
	client.conn = conn

etcd客户端源码只对于endpoints[0],也就是第一个配置的节点进行连接,如果连接失败就直接返回异常了,这个是不是需要在gaea层面在获取etcd连接的时候进行额外判断,依次获取配置的每个节点的连接,直到获得可用连接为止呢?

@gongna-au
Copy link
Collaborator

  • gaea代码
        endpoints := strings.Split(addr, ",")
	config := clientv3.Config{
		Endpoints:            endpoints,
		Username:             username,
		Password:             passwd,
		DialTimeout:          timeout, // 只设定第一次连线时间的逾时,之后不用太担心连线,连线失败后,会自动重连
		DialKeepAliveTimeout: timeout, // 之后维持 etcd 连线的逾时
		TLS:                  tlsConf,
	}
	c, err := clientv3.New(config)
	if err != nil {
		return nil, err
	}
  • etcd中clientv3.New(config)源码
        client.balancer = newHealthBalancer(cfg.Endpoints, cfg.DialTimeout, func(ep string) (bool, error) {
		return grpcHealthCheck(client, ep)
	})

	// use Endpoints[0] so that for https:// without any tls config given, then
	// grpc will assume the certificate server name is the endpoint host.
	conn, err := client.dial(cfg.Endpoints[0], grpc.WithBalancer(client.balancer))
	if err != nil {
		client.cancel()
		client.balancer.Close()
		return nil, err
	}
	client.conn = conn

etcd客户端源码只对于endpoints[0],也就是第一个配置的节点进行连接,如果连接失败就直接返回异常了,这个是不是需要在gaea层面在获取etcd连接的时候进行额外判断,依次获取配置的每个节点的连接,直到获得可用连接为止呢?

感谢您提出这个问题!我们非常重视用户的反馈。
我们会先调研一下新版本的 etcd 是否已经修复了这个问题。如果发现仍然存在这个问题,我们会将其列入开发计划,并在 Gaea 中进行兼容性处理。
再次感谢您的关注和建议!如果您有其他问题或建议,请随时告诉我们。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants