HAProxy community

Using `stopping` variable from internal state together with `monitor fail`

Hi,

I’m using Haproxy 2.0.9.

I’m having some issues with intermittent connection issues because of a loadbalancer that doesn’t update healthchecks too frequently, I’ve been using the Haproxy stats page in my healthchecks.

I thought I would be able to send SIGUSR1 to Haproxy to shut down gracefully, but it seems like it doesn’t pick up quickly enough, so I stumbled upon the documentation which mentions the stopping variable described here: https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#7.3.2-stopping

I couldn’t find much about that variable, but I assume it would be true if Haproxy have recieved SIGUSR1, right?

However, I came up with this brilliant configuration:

listen fe_ingress
  bind *:8887
  mode http
  stats enable
  stats uri /

  grace 10s
  monitor-uri /healthy
  monitor fail if stopping

Grace will keep the listen alive for 10 seconds after SIGUSR1 has been issued, but the monitor uri will return failing if the process is stopping.

However, if I’m running a config check it gives me the following error:

haproxy -c -f /usr/local/etc/haproxy/haproxy.cfg
[ALERT] 346/020934 (7) : parsing [/usr/local/etc/haproxy/haproxy.cfg:58] : error detected while parsing a ‘monitor fail’ condition : no such ACL : ‘stopping’.
[ALERT] 346/020934 (7) : Error(s) found in configuration file : /usr/local/etc/haproxy/haproxy.cfg
[ALERT] 346/020934 (7) : Fatal errors found in configuration.
The command ‘/bin/sh -c haproxy -c -f /usr/local/etc/haproxy/haproxy.cfg’ returned a non-zero code: 1

Is that right? Or is there another way to solve my issue if stopping can’t be used as an ACL?

Eurgh… I guess I am tired, this worked:

acl going_down stopping
grace 10s
monitor-uri /healthy
monitor fail if going_down