HAProxy community

Problem when using dynamic service discovery via DNS and SRV Records

#1

I’m using Consul for dynamic service discovery.

If application port is bigger than 32767, srv_port is not correct.

Configuration:

server-template srv 4 _testsrv._tcp.service.consul inter 1s resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip check

“show servers state” Result:

# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port srvrecord

4 [testsrv.configuration.abc.com](http://testsrv.configuration.abc.com/) 1 srv1 10.90.21.103 0 96 1 1 20373 15 3 0 14 0 0 0 - 4294934534 _testsrv._tcp.service.consul
4 [testsrv.configuration.abc.com](http://testsrv.configuration.abc.com/) 2 srv2 10.90.21.107 0 96 1 1 20365 15 3 0 14 0 0 0 - 4294934530 _testsrv._tcp.service.consul
4 [testsrv.configuration.abc.com](http://testsrv.configuration.abc.com/) 3 srv3 10.90.21.103 0 96 1 1 20409 15 3 0 14 0 0 0 - 4294934533 _testsrv._tcp.service.consul
4 [testsrv.configuration.abc.com](http://testsrv.configuration.abc.com/) 4 srv4 10.90.21.103 2 0 1 1 20554 15 3 4 6 0 0 0 consul-node-10-90-21-103.node.ayt.consul 4294934535 _testsrv._tcp.service.consul

HAProxy Stat UI gives: 10.90.21.103:-32761 (Negative I think it minus 65536)

IP Address is ok but the port is wrong it should be 32775

I read the code. I think It’s related with this http://git.haproxy.org/?p=haproxy-1.9.git;a=blob;f=src/server.c;h=20f03cefe3deaed01472a24f28374de9f8a4f9b9;hb=HEAD#l2978

#2

What’s the platform/CPU? amd64?

Can you provide the output of haproxy -vv and uname -a please?

#3
haproxy -vv
HA-Proxy version 1.9.8 2019/05/13 - https://haproxy.org/
Build options :
  TARGET  = linux2628
  CPU     = generic
  CC      = gcc
  CFLAGS  = -O2 -g -fno-strict-aliasing -Wdeclaration-after-statement -fwrapv -Wno-unused-label -Wno-sign-compare -Wno-unused-parameter -Wno-old-style-declaration -Wno-ignored-qualifiers -Wno-clobbered -Wno-missing-field-initializers -Wtype-limits
  OPTIONS = USE_ZLIB=1 USE_PCRE2=1 USE_TFO=1 USE_NS=1

Default settings :
  maxconn = 2000, bufsize = 16384, maxrewrite = 1024, maxpollevents = 200

Built with network namespace support.
Built with transparent proxy support using: IP_TRANSPARENT IPV6_TRANSPARENT IP_FREEBIND
Built with zlib version : 1.2.7
Running on zlib version : 1.2.7
Compression algorithms supported : identity("identity"), deflate("deflate"), raw-deflate("deflate"), gzip("gzip")
Built with PCRE2 version : 10.23 2017-02-14
PCRE2 library supports JIT : no (USE_PCRE2_JIT not set)
Encrypted password support via crypt(3): yes
Built with multi-threading support.

Available polling systems :
      epoll : pref=300,  test result OK
       poll : pref=200,  test result OK
     select : pref=150,  test result OK
Total: 3 (3 usable), will use epoll.

Available multiplexer protocols :
(protocols marked as <default> cannot be specified using 'proto' keyword)
              h2 : mode=HTX        side=FE|BE
              h2 : mode=HTTP       side=FE
       <default> : mode=HTX        side=FE|BE
       <default> : mode=TCP|HTTP   side=FE|BE

Available filters :
	[SPOE] spoe
	[COMP] compression
	[CACHE] cache
	[TRACE] trace

uname -a
Linux haproxy 4.14.35-1844.4.5.el7uek.x86_64 #2 SMP Tue Apr 9 00:29:47 PDT 2019 x86_64 x86_64 x86_64 GNU/Linux
#4

Thanks for the report, I filed the following bug on github:

#5

Thank @lukastribus, I’ll check github issue.