Am Do., 13. Sep. 2018 um 15:23 Uhr schrieb Peter Fröhlich
<[email protected]>:
>
> Am Do., 13. Sep. 2018 um 10:06 Uhr schrieb Willy Tarreau <[email protected]>:
> > On Thu, Sep 13, 2018 at 09:29:42AM +0200, Peter Fröhlich wrote:
> > > Would our use case of setting the backend servers only through the
socket,
> > > and the necessary workaround of setting the server entries to
'localhost'
> > > be worth a 'Notes:' entry in the 'load-server-state-from-file'
section?
> >
> > Yes, very likely. Feel free to propose a patch for the doc. Generally
doc
> > written by users who were bitten by a problem is much clearer than the
one
> > written by the initial developer!
> >
For your consideration, the doc patch with context.
Please give me feedback if I should incorporate some other aspects.
Peter
--- configuration.txt 2018-09-14 17:35:35.000000000 +0200
+++ configuration.txt.edited 2018-09-14 17:35:29.000000000 +0200
@@ -4894,69 +4894,79 @@
load-server-state-from-file { global | local | none }
Allow seamless reload of HAProxy
May be used in sections: defaults | frontend | listen | backend
yes | no | yes | yes
This directive points HAProxy to a file where server state from previous
running process has been saved. That way, when starting up, before
handling
traffic, the new process can apply old states to servers exactly has if
no
reload occurred. The purpose of the "load-server-state-from-file"
directive is
to tell haproxy which file to use. For now, only 2 arguments to either
prevent
loading state or load states from a file containing all backends and
servers.
The state file can be generated by running the command "show servers
state"
over the stats socket and redirect output.
The format of the file is versioned and is very specific. To understand
it,
please read the documentation of the "show servers state" command
(chapter
9.3 of Management Guide).
Arguments:
global load the content of the file pointed by the global directive
named "server-state-file".
local load the content of the file pointed by the directive
"server-state-file-name" if set. If not set, then the
backend
name is used as a file name.
none don't load any stat for this backend
Notes:
- - server's IP address is preserved across reloads by default, but the
- order can be changed thanks to the server's "init-addr" setting. This
- means that an IP address change performed on the CLI at run time will
+ - a servers IP address will only be applied from the state file if the
+ servers config file line refers to a DNS address. If the server has a
+ static IP configured in the config file the IP from the state file
gets
+ ignored silently (the other settings get restored).
+
+ - the resolved IP address of a server is preserved across reloads by
default,
+ but the order can be changed thanks to the servers "init-addr"
setting.
+ This means that an IP address change performed on the CLI at run
time will
be preserved, and that any change to the local resolver (e.g.
/etc/hosts)
will possibly not have any effect if the state file is in use.
- - server's weight is applied from previous running process unless it
has
- has changed between previous and new configuration files.
+ - a continuous reconfiguration of server IPs + ports over the state
socket
+ could require to always restore the IP from the state file at reload.
+ To enable this use a safe default DNS name (like "localhost") in the
+ servers config line, that gets resolved over the local resolver.
+ - servers weight is applied from previous running process unless it has
+ has changed between previous and new configuration files.
+
Example: Minimal configuration
global
stats socket /tmp/socket
server-state-file /tmp/server_state
defaults
load-server-state-from-file global
backend bk
server s1 127.0.0.1:22 check weight 11
server s2 127.0.0.1:22 check weight 12
Then one can run :
socat /tmp/socket - <<< "show servers state" > /tmp/server_state
Content of the file /tmp/server_state would be like this:
1
# <field names skipped for the doc example>
1 bk 1 s1 127.0.0.1 2 0 11 11 4 6 3 4 6 0 0
1 bk 2 s2 127.0.0.1 2 0 12 12 4 6 3 4 6 0 0
Example: Minimal configuration
global
stats socket /tmp/socket
server-state-base /etc/haproxy/states