HAProxy community

Backend goes into MAINT when DNS fails and does not come back UP

HAProxy version 1.8.19-1

I have configured a backend with one server in it. When resolving of that server (nginx.default.svc.k8s.test.com) fails (according kubernetes service is deleted), the backend goes into L4-DOWN. So far so good.
But when the according kubernetes service is recreated, which means that the hostname is resolveable again, the backend goes into MAINT status and not UP.

If the backend server is resolveable again before the backend goes DOWN, it also comes back UP again, but if this takes longer, it just stays in MAINT.

I don’t understand this behavior. I want the backend server to be UP when it is resolved, regardless of how long it takes until its hostname is resolveable again. Is there a way to achieve this?

The following config parts are - in my opinion - enough for elaboration:

default-server init-addr libc,none resolvers dns

resolvers dns
  nameserver dns01 10.254.205.31:53
  nameserver dns02 10.254.205.32:53
  resolve_retries       3
  timeout retry         1s
  hold valid            5s

backend test
  mode http
  option httpchk HEAD /
  server testhost nginx.default.svc.k8s.test.com:80 check

Here are the logfiles showing the backend switching to MAINT:

Apr 30 14:19:46 load01 haproxy[26347]: Server test/testhost is DOWN, reason: Layer4 timeout, check duration: 2001ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Apr 30 14:19:46 load01 haproxy[26347]: Server test/testhost is DOWN, reason: Layer4 timeout, check duration: 2001ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Apr 30 14:19:46 load01 haproxy[26347]: backend test has no server available!
Apr 30 14:19:46 load01 haproxy[26347]: backend test has no server available!
Apr 30 14:20:04 load01 haproxy[26347]: Server test/testhost was DOWN and now enters maintenance (DNS NX status).
Apr 30 14:20:04 load01 haproxy[26347]: Server test/testhost was DOWN and now enters maintenance (DNS NX status).

edit: haproxy version added

Can you remove this “init-addr” statement. It’s unrelated to your issue but I don’t see the point to set it to this value.

can you run a tcpdump and see if you see HAProxy sending DNS queries?

haproxy is indeed sending dns queries all the time. it sends them when the backend server is up, it sends them while the backend server is down and it sends them while the backend server is in maint status.

just for disclosure, I am using this in global configuration. I read that it could cause problems in general:

  nbproc 1
  nbthread 4
  cpu-map 1/1 1
  cpu-map 1/2 2
  cpu-map 1/3 3
  cpu-map 1/4 4

if i remove init-addr libc,none the backend goes straight to “maint resolution”, not to “down”.