Service address does not default to the IP address of the agent
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
I have the following service definition:
``` json
{
"service": {
"checks": [
{
"interval": "5s",
"tcp": "0.0.0.0:6081"
}
],
"id": "varnish_cache",
"name": "varnish_cache",
"port": 6081,
"tags": []
}
}
```
According to the [documentation](https://www.consul.io/docs/agent/services.html), the `Address` field should be optional:
> The address field can be used to specify a service-specific IP address. By default, the IP address of the agent is used, and this does not need to be provided. The port field can be used as well to make a service-oriented architecture simpler to configure; this way, the address and port of a service can be discovered.
However, the field doesn't seem to be correctly populated when querying the API:
```
> curl http://127.0.0.1:8500/v1/catalog/service/varnish_cache?pretty=true
[
{
"Node": "REDACTED",
"Address": "REDACTED",
"ServiceID": "varnish_cache",
"ServiceName": "varnish_cache",
"ServiceTags": [],
"ServiceAddress": "",
"ServicePort": 6081,
"ServiceEnableTagOverride": false,
"CreateIndex": 1474983,
"ModifyIndex": 1475619
}
]
> curl http://127.0.0.1:8500/v1/health/service/varnish_cache?pretty=true
[
{
"Node": {
"Node": "REDACTED",
"Address": "REDACTED",
"TaggedAddresses": {
"wan": "REDACTED"
},
"CreateIndex": 1474982,
"ModifyIndex": 1638580
},
"Service": {
"ID": "varnish_cache",
"Service": "varnish_cache",
"Tags": [],
"Address": "",
"Port": 6081,
"EnableTagOverride": false,
"CreateIndex": 1474983,
"ModifyIndex": 1475619
},
"Checks": [
{
"Node": "REDACTED",
"CheckID": "serfHealth",
"Name": "Serf Health Status",
"Status": "passing",
"Notes": "",
"Output": "Agent alive and reachable",
"ServiceID": "",
"ServiceName": "",
"CreateIndex": 1474982,
"ModifyIndex": 1638570
},
{
"Node": "REDACTED",
"CheckID": "service:varnish_cache",
"Name": "Service 'varnish_cache' check",
"Status": "passing",
"Notes": "",
"Output": "TCP connect 0.0.0.0:6081: Success",
"ServiceID": "varnish_cache",
"ServiceName": "varnish_cache",
"CreateIndex": 1474983,
"ModifyIndex": 1475619
}
]
}
]
```
Contributor guide
Assessment
This issue has not been assessed yet.