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

Refresh inserts wrong service IP #1

Open
synologic opened this issue Oct 14, 2023 · 2 comments
Open

Refresh inserts wrong service IP #1

synologic opened this issue Oct 14, 2023 · 2 comments

Comments

@synologic
Copy link

Hi,

Is there any particular reason for which at line 200 you are doing:

table.insert(addresses, node.Node.Address .. ":" .. node.Service.Port)

instead of

table.insert(addresses, node.Service.Address .. ":" .. node.Service.Port)

That will effectively add the Consul node address instead of the actual Service registration address ?

Thanks

@roman-vynar
Copy link
Contributor

@synologic Sorry, missed your question for some reason.

Yes, there is a reason for that.
balancer.set_current_peer() requires an IP address and hostnames do not make sense.
See https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/balancer.md#set_current_peer

node.Node.Address stands for IP address.
node.Service.Address stands for hostname (unless your Consul registrations are not doing that and still setting to an IP).

In the latest commit I have added 3rd arg to balancer.set_current_peer() to support SNI. This is not important for Go services on the backend but Java ones with the latest Dropwizard and default SNI enabled will not work otherwise.

@roman-vynar
Copy link
Contributor

In any case our setup is simple 1 node == 1 IP. In case you are doing something more specific, multiple IP addresses etc. it's all up to you. But we can change something here to make it in and useful for others.

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