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

[BUG]负载均衡无法切换节点 #260

Closed
dougsong opened this issue Nov 18, 2022 · 0 comments · Fixed by #261
Closed

[BUG]负载均衡无法切换节点 #260

dougsong opened this issue Nov 18, 2022 · 0 comments · Fixed by #261
Assignees
Labels

Comments

@dougsong
Copy link
Contributor

dougsong commented Nov 18, 2022

请简单描述bug的场景
config 设置 IP 为 ConfigService 集群中其中一个节点的 IP;停止该节点 ConfigService 后,SDK 负载均衡不会切换到其他节点。

如何重现

func TestRun(t *testing.T) {
	var ch = make(chan int, 0)
	_, err := StartWithConfig(func() (*config.AppConfig, error) {
		return &config.AppConfig{
			AppID:         "test-app",
			Cluster:       "default",
			NamespaceName: "application",
			IP:            "http://IP1",
			Secret:        "xxx",
		}, nil
	})
	if err != nil {
		panic(err)
	}
	<-ch
}

再现行为的步骤:

  1. IP1 节点停止 ConfigService

期望
负载均衡切换到其他节点

其他上下文

RequestRecovery 里判断 host == appConfig.GetHost() 直接返回了,SetDownNode 里的 s.nextTryConnTime = nextTryConnectPeriod 应该不会生效,导致 IsConnectDirectly 永远返回 false,loadBalance 方法一直使用 appConfig 里的配置,而不是通过 services/config 获取的节点列表。

server.SetDownNode(host, appConfig.GetHost()),这里参数传递是否写反了,SetDownNode 里使用第一个参数去获取 Server 列表,所以我理解第一个参数应该传入 appConfig.GetHost() 才对

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

Successfully merging a pull request may close this issue.

2 participants