Hi gurus

we are using HAProxy 1.8.13 on Centos 7 with dynamically assigned
backends (backend server IPs and ports assigned over stats socket by
some python glue accessing namerd). This works fine.

We needed a method to make the dynamically assigned stuff stick over
restarts and try to use the "load-server-state-from-file" directive.

Sadly we are running into a bug:
HAProxy does not restore the configured IP address present in the
state file but falls back to the one in the config file at startup.
Other information like uptime counter, state, port get restored.
This only happens if the default server address in the config file is
an IP. This does not happen with DNS names. If we switch out the
default server addresses '127.0.0.1' in the config with 'localhost' it
works as expected. We found this behavior with all tested versions
(1.8.7, 1.8.13, 1.9-dev).

The test config and example output are available in a Stack Exchange
question I opened:
https://serverfault.com/questions/930422/haproxy-use-saved-state-to-restore-backend-ips-possible

You'll find two tiny patches attached, one for 1.8.13 and one for
1.9-dev. They work for our system and use case.

Thanks for your great work
Peter

pe...@froehlich.cc
---

1.9-dev
--- src/server.c 2018-09-12 12:02:48.000000000 +0000
+++ server.c 2018-09-12 12:02:41.000000000 +0000
@@ -4143,7 +4143,7 @@
  goto srv_init_addr_next;

  for (srv = curproxy->srv; srv; srv = srv->next)
- if (srv->hostname)
+ if (srv->hostname || srv->lastaddr)
  return_code |= srv_iterate_initaddr(srv);

  srv_init_addr_next:


1.8.13
--- server.c 2018-09-12 12:25:47.000000000 +0000
+++ src/server.c 2018-09-12 12:26:05.000000000 +0000
@@ -3957,7 +3957,7 @@
  goto srv_init_addr_next;

  for (srv = curproxy->srv; srv; srv = srv->next)
- if (srv->hostname)
+ if (srv->hostname || srv->lastaddr)
  return_code |= srv_iterate_initaddr(srv);

  srv_init_addr_next:

Reply via email to