profile
viewpoint

Ask questionsAPI: Autofill Service.Address with Node.Address if Service.Address is empty

Feature Description

Whenever the Consul API reports a ServiceAddress or Service.Address, if this value is blank/empty, default to the address of the Node instead of leaving the value blank.

We currently document that a blank value is expected behaviour in the catalog endpoint documentation, although changing this could improve DX and is therefore a feature request.

https://www.consul.io/api/catalog.html#serviceaddress

ServiceAddress is the IP address of the service host — if empty, node address should be used

Use Case(s)

Make it easier for API consumers/clients to retrieve the IP address of a service, even when there is no need for the registration of the service to provide an IP.

Also see:

https://github.com/hashicorp/consul-template/issues/587#issuecomment-232456696 https://github.com/hashicorp/consul/issues/4579

@mkeeler this is re: offline chat

hashicorp/consul

Answer questions jf

I agree with you on the initial issue, but I think that many tools are now doing assumptions based on this value being present or not, see my comment: #7782 (comment)

I'm late to this issue but... what tools would these be, and why would they care about it being empty (""?) vs being filled with an actual IP address? I fail to see why having the actual IP address reflected in Service.Address is a problem vs it's current "" value

useful!

Related questions

(code=exited, status=1/FAILURE) hot 2
rpc: can't find method Internal.ServiceDump from xxxx hot 2
Error getting server health - context deadline exceeded hot 2
Agent can't connect to server when server listens on non-default port hot 1
Error starting agent: AutoEncrypt failed: unknown private key type requested: on autoencrypt enabled client hot 1
cannot load github.com/hashicorp/consul/api: ambiguous import hot 1
TLS hostname validation failure with version 1.0.0 on Alpine Linux 3.6 hot 1
memberlist: Was able to connect to xxx but other probes failed, network may be misconfigured hot 1
documentation: auto encrypt on an existing Consul datacenter not possible? hot 1
Can same node act as client and server hot 1
==> Starting Consul agent... ==> Error starting agent: agent: timeout starting DNS servers hot 1
Consul cluster fails to recover in outage hot 1
Prepared queries that include results from multiple DCs hot 1
Running consul as window service, the process is getting terminated hot 1
Consul cluster fails to recover in outage hot 1
source:https://uonfu.com/
Github User Rank List