Using SRV Record - number of records in DNS not limiting server-template count

Hi,

It looks like HAProxy 1.8.3 doesn’t obey the number of SRV records and instead just uses the server-template num servers.

For the following 3 SRV records:

;; ANSWER SECTION:
_app._tcp.marathon.mesos. 15 IN SRV 10 0 11016 host3.marathon.mesos.
_app._tcp.marathon.mesos. 15 IN SRV 10 0 24353 host1.marathon.mesos.
_app._tcp.marathon.mesos. 15 IN SRV 10 0 11751 host5.marathon.mesos.

And the following HAProxy config:

server-template www 5 _app._tcp.marathon.mesos check resolvers mydns resolve-prefer ipv4

It initialized 5 servers, 3 from the DNS records but also 2 others:

[WARNING] 037/130543 (7409) : Server nodes/www1 is DOWN, reason: Socket error, check duration: 0ms. 4 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 037/130543 (7409) : nodes/www1 changed its IP from to 192.168.0.163 by mydns/dns1.
[WARNING] 037/130543 (7409) : nodes/www2 changed its IP from to 192.168.0.165 by mydns/dns1.
[WARNING] 037/130543 (7409) : nodes/www3 changed its IP from to 192.168.0.207 by mydns/dns1.
[WARNING] 037/130543 (7409) : Server nodes/www2 is DOWN, reason: Layer4 connection problem, info: “Connection refused”, check duration: 50ms. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 037/130544 (7409) : Server nodes/www3 is DOWN, reason: Layer4 connection problem, info: “Connection refused”, check duration: 49ms. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 037/130544 (7409) : Server nodes/www4 is DOWN, reason: Socket error, check duration: 0ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 037/130545 (7409) : Server nodes/www5 is DOWN, reason: Socket error, check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.

I think the expected behavior would be to configure only 3 servers? Please let me know if you need more information.

Thanks,
scarey

No, this is exactly what it is supposed to do. You are configuring the number of server slots in the configuration, and then you can scale up and down via DNS. If you we would limit itself to the number of SRV records at haproxy startup, you could never scale up at all.