Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 950574 - net-proxy/haproxy init script handles reload improperly
Summary: net-proxy/haproxy init script handles reload improperly
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal minor
Assignee: Christian Ruppert (idl0r)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-04 10:21 UTC by Deniss Gaplevsky
Modified: 2025-03-20 15:57 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
haproxy.initd-r9 (haproxy.initd-r9,1.81 KB, text/plain)
2025-03-14 13:07 UTC, Christian Ruppert (idl0r)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Deniss Gaplevsky 2025-03-04 10:21:56 UTC
net-proxy/haproxy init script designed to handle reload with custom user function *reload_seamless*

the default reload command is still run anyway where *reload_seamless* is present or not.

Reproducible: Always

Steps to Reproduce:
1. create reload_seamless function to call custom code to reload the haproxy
2. run /etc/init.d/haproxy reload
3. 
Actual Results:  
function reload_seamless is executed
default reload command is executed as well

Expected Results:  
only reload_seamless should be executed

moreover default "reload" command RESTARTs haproxy indeed
Comment 1 Christian Ruppert (idl0r) gentoo-dev 2025-03-12 08:34:52 UTC
Hi Deniss,

is the reload_seamless hook even required nowadays? For HAProxy itself it's not, actually. Wouldn't be a pre/post hook be enough? Like already possible, you can have your own pre/post reload function.

Why do you think it actually *restarts* HAProxy? It does not in the shipped version.
Comment 2 Deniss Gaplevsky 2025-03-12 11:52:42 UTC
reload does 
"$command $command_args -sf $(cat "${pidfile}")"

from haproxy man:
       -sf <pidlist>
              Send  FINISH  signal to the pids in pidlist after startup. The processes which receive this
              signal will wait for all sessions to finish before exiting.


note "before exiting" in text above
Comment 3 Deniss Gaplevsky 2025-03-12 11:56:50 UTC
There should be a way to skip default command in reload() func that force haproxy process to exit.

for sure it is possible to call exit inside reload_seamless but it feels hacky
Comment 4 Christian Ruppert (idl0r) gentoo-dev 2025-03-12 12:05:31 UTC
You're not using master-worker mode, don't you?

Can you show me your custom function by chance? I'm curious whether it's still required at all.
Comment 5 Deniss Gaplevsky 2025-03-12 13:24:28 UTC
net-proxy/haproxy-3.0.8

reload_seamless() {
    kill -s USR2 $(cat /run/haproxy.pid)
    exit $?
}


master-worker mode is a default mode in the init script:
command_args="-D -W -p ${pidfile} ${configs} ${HAPROXY_OPTS}"

I run with following config :

# grep HAPROXY_OPTS /etc/conf.d/haproxy
HAPROXY_OPTS="-S /run/haproxy-master.sock"

# head -9 /etc/haproxy/haproxy.cfg
global
  daemon
  maxconn 262144
  user haproxy
  ssl-server-verify none
  log /dev/log local0 debug

defaults
  mode http
Comment 6 Christian Ruppert (idl0r) gentoo-dev 2025-03-14 13:07:04 UTC
Created attachment 920760 [details]
haproxy.initd-r9

Can you please try this init script?
Does that solve your problem entirely?
Comment 7 Deniss Gaplevsky 2025-03-18 19:21:15 UTC
looks fine to me
Comment 8 Larry the Git Cow gentoo-dev 2025-03-20 15:46:14 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0ff48e295842df204280fb58b4e20de8b1c215aa

commit 0ff48e295842df204280fb58b4e20de8b1c215aa
Author:     Christian Ruppert <idl0r@gentoo.org>
AuthorDate: 2025-03-20 15:45:54 +0000
Commit:     Christian Ruppert <idl0r@gentoo.org>
CommitDate: 2025-03-20 15:46:11 +0000

    net-proxy/haproxy: Bump to 3.0.9 and 3.1.6; Also send USR2 on reload
    
    Bug: https://bugs.gentoo.org/950574
    Signed-off-by: Christian Ruppert <idl0r@gentoo.org>

 net-proxy/haproxy/Manifest                |   2 +
 net-proxy/haproxy/files/haproxy.initd-r9  |  86 ++++++++++++
 net-proxy/haproxy/haproxy-2.6.9999.ebuild |   4 +-
 net-proxy/haproxy/haproxy-2.8.9999.ebuild |   4 +-
 net-proxy/haproxy/haproxy-2.9.9999.ebuild |   4 +-
 net-proxy/haproxy/haproxy-3.0.9.ebuild    | 217 ++++++++++++++++++++++++++++++
 net-proxy/haproxy/haproxy-3.0.9999.ebuild |   4 +-
 net-proxy/haproxy/haproxy-3.1.6.ebuild    | 216 +++++++++++++++++++++++++++++
 net-proxy/haproxy/haproxy-3.1.9999.ebuild |   4 +-
 net-proxy/haproxy/haproxy-9999.ebuild     |   4 +-
 10 files changed, 533 insertions(+), 12 deletions(-)
Comment 9 Christian Ruppert (idl0r) gentoo-dev 2025-03-20 15:57:09 UTC
Should be fixed then. Thanks! :)