On Thu, Apr 04, 2024 at 04:00:16PM +0200, Tim Düsterhus wrote:
> Hi
> 
> On 4/4/24 14:35, William Lallemand wrote:
> > I'm not against merging this, but I don't see any change comparing to the
> > current model?
> > 
> 
> I mainly stumbled upon this new mode in the documentation while looking into
> replacing libsystemd, where you beat me to it :-)
> 
> My understanding is that it improves the situation insofar that systemd
> knows that the reload (attempt) is not yet finished even if the kill command
> exits.
> 
> Currently it's the following:
> 
> - systemd executes the kill.
> - kill exists.
> - systemd believes the reload finished.
> - HAProxy sees the signal, sends RELOADING=1.
> - systemd believes a second reload started.
> - HAProxy finishes reloading, sends READY=1.
> - systemd believes the second reload finished.
> With the new mode it's:
> 
> - systemd sends the signal.
> - systemd waits for RELOADING=1.
> - HAProxy sees the signal, sends RELOADING=1.
> - HAProxy finishes reloading, sends READY=1.
> - systemd believes the reload finished.
> 
> The new mode is only available with very recent systemd versions, but we can
> future-proof the implementation by already including the MONOTONIC_USEC
> field in the message. Unknown fields are explicitly ignored by systemd, thus
> this patch makes the situation no worse.

I thought systemd was already waiting the READY=1 message in fact, I
made a few tests which confirms your explanation, thanks, merged!

What I find stupid is that it's not possible to have the red
"systemd[1]: Reload failed for haproxy.service" message when using all
these reload method...

For example if you replace `kill`by `false` in the unit file, you will
have:

        wla@kikyo:~% systemctl status haproxy
        ● haproxy.service - HAProxy Load Balancer
             Loaded: loaded (/etc/systemd/system/haproxy.service; enabled; 
preset: enabled)
             Active: active (running) since Thu 2024-04-04 15:04:20 CEST; 1h 
4min ago
               Docs: man:haproxy(1)
                     file:/usr/share/doc/haproxy/configuration.txt.gz
            Process: 58596 ExecReload=/usr/bin/false (code=exited, 
status=1/FAILURE)
           Main PID: 57180 (haproxy)
             Status: "Ready."
              Tasks: 9 (limit: 18702)
             Memory: 74.6M
                CPU: 1.624s
             CGroup: /system.slice/haproxy.service
                     ├─57180 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg 
-p /run/haproxy.pid -S /run/haproxy-master.sock
                     └─57601 /usr/sbin/haproxy -sf 57557 -x sockpair@5 -Ws -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock
        
        Apr 04 15:14:12 kikyo systemd[1]: Reload failed for haproxy.service - 
HAProxy Load Balancer.
        Apr 04 15:14:33 kikyo systemd[1]: Reloading haproxy.service - HAProxy 
Load Balancer...
        Apr 04 15:14:33 kikyo systemd[1]: haproxy.service: Control process 
exited, code=exited, status=1/FAILURE
        Apr 04 15:14:33 kikyo systemd[1]: Reload failed for haproxy.service - 
HAProxy Load Balancer.
        Apr 04 15:14:48 kikyo systemd[1]: Reloading haproxy.service - HAProxy 
Load Balancer...
        Apr 04 15:14:48 kikyo systemd[1]: haproxy.service: Control process 
exited, code=exited, status=1/FAILURE
        Apr 04 15:14:48 kikyo systemd[1]: Reload failed for haproxy.service - 
HAProxy Load Balancer.
        Apr 04 15:17:20 kikyo systemd[1]: Reloading haproxy.service - HAProxy 
Load Balancer...
        Apr 04 15:17:20 kikyo systemd[1]: haproxy.service: Control process 
exited, code=exited, status=1/FAILURE
        Apr 04 15:17:20 kikyo systemd[1]: Reload failed for haproxy.service - 
HAProxy Load Balancer.

With messages hilighted in red, and a clear failure of the reload on the
"Process" line.

I can't find a way of achieving the same thing with sd_notify() :(

-- 
William Lallemand

Reply via email to