Bug 1444709

Summary: haproxy status failed after stopping the service
Product: Red Hat Enterprise Linux 7 Reporter: Marko Myllynen <myllynen>
Component: haproxyAssignee: Ryan O'Hara <rohara>
Status: CLOSED ERRATA QA Contact: Brandon Perkins <bperkins>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 7.3CC: fdinitto, ffotorel, jeharris, rohara
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: haproxy-1.5.18-6.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 21:31:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Marko Myllynen 2017-04-24 04:49:57 UTC
Description of problem:
[root@lb01 ~]# systemctl stop haproxy
[root@lb01 ~]# systemctl status haproxy
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/usr/lib/systemd/system/haproxy.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2017-04-21 12:16:38 UTC; 2s ago
  Process: 2238 ExecStart=/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid $OPTIONS (code=exited, status=143)
 Main PID: 2238 (code=exited, status=143)
...

While at it, perhaps consider removing the -p switch from the command line / pidfile from example configuration, should not be needed with systemd.

Version-Release number of selected component (if applicable):
haproxy-1.5.18-3.el7_3.1.x86_64

Comment 2 Ryan O'Hara 2017-04-28 11:25:11 UTC
Need more information. Does this happen every time you attempt to stop haproxy? Do you have logs? Etc.

Comment 3 Marko Myllynen 2017-04-28 11:28:17 UTC
Yes, this happens every time and is trivial to reproduce:

# rpm -V haproxy
# systemctl start haproxy
# systemctl status haproxy
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/usr/lib/systemd/system/haproxy.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2017-04-28 14:26:28 EEST; 3s ago
 Main PID: 9396 (haproxy-systemd)
   CGroup: /system.slice/haproxy.service
           ├─9396 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
           ├─9397 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
           └─9398 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds

Apr 28 14:26:28 mars systemd[1]: Started HAProxy Load Balancer.
Apr 28 14:26:28 mars systemd[1]: Starting HAProxy Load Balancer...
Apr 28 14:26:28 mars haproxy-systemd-wrapper[9396]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
# systemctl stop haproxy  
# systemctl status haproxy
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/usr/lib/systemd/system/haproxy.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2017-04-28 14:26:38 EEST; 1s ago
  Process: 9396 ExecStart=/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid $OPTIONS (code=exited, status=143)
 Main PID: 9396 (code=exited, status=143)

Apr 28 14:26:28 mars systemd[1]: Started HAProxy Load Balancer.
Apr 28 14:26:28 mars systemd[1]: Starting HAProxy Load Balancer...
Apr 28 14:26:28 mars haproxy-systemd-wrapper[9396]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
Apr 28 14:26:38 mars systemd[1]: Stopping HAProxy Load Balancer...
Apr 28 14:26:38 mars haproxy-systemd-wrapper[9396]: haproxy-systemd-wrapper: SIGTERM -> 9398.
Apr 28 14:26:38 mars haproxy-systemd-wrapper[9396]: haproxy-systemd-wrapper: exit, haproxy RC=143
Apr 28 14:26:38 mars systemd[1]: haproxy.service: main process exited, code=exited, status=143/n/a
Apr 28 14:26:38 mars systemd[1]: Stopped HAProxy Load Balancer.
Apr 28 14:26:38 mars systemd[1]: Unit haproxy.service entered failed state.
Apr 28 14:26:38 mars systemd[1]: haproxy.service failed.
zsh: exit 3     systemctl status haproxy
# 

thanks.

Comment 4 Ryan O'Hara 2017-04-28 12:54:10 UTC
OK. This is strange since we patched haproxy not too long ago and verified that we were exited with RC=0. Anyway, it appears that the solution is to simple use KillMode=mixed in the haproxy.service file:

# cat /usr/lib/systemd/system/haproxy.service 
[Unit]
Description=HAProxy Load Balancer
After=syslog.target network.target

[Service]
EnvironmentFile=/etc/sysconfig/haproxy
ExecStart=/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid $OPTIONS
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed

[Install]
WantedBy=multi-user.target

# systemctl start haproxy
# systemctl stop haproxy
# systemctl status haproxy
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/usr/lib/systemd/system/haproxy.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Apr 28 07:37:24 mesa-01 systemd[1]: Stopped HAProxy Load Balancer.
Apr 28 07:37:24 mesa-01 systemd[1]: Unit haproxy.service entered failed state.
Apr 28 07:37:24 mesa-01 systemd[1]: haproxy.service failed.
Apr 28 07:51:16 mesa-01 systemd[1]: Started HAProxy Load Balancer.
Apr 28 07:51:16 mesa-01 systemd[1]: Starting HAProxy Load Balancer...
Apr 28 07:51:16 mesa-01 haproxy-systemd-wrapper[36180]: haproxy-systemd-wrapper: executing /usr...Ds
Apr 28 07:51:27 mesa-01 haproxy-systemd-wrapper[36180]: haproxy-systemd-wrapper: SIGTERM -> 36182.
Apr 28 07:51:27 mesa-01 systemd[1]: Stopping HAProxy Load Balancer...
Apr 28 07:51:27 mesa-01 haproxy-systemd-wrapper[36180]: haproxy-systemd-wrapper: exit, haproxy RC=0
Apr 28 07:51:27 mesa-01 systemd[1]: Stopped HAProxy Load Balancer.
Hint: Some lines were ellipsized, use -l to show in full.

Comment 7 errata-xmlrpc 2017-08-01 21:31:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:2170