Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
DESCRIPTION OF PROBLEM:
When building a simple Type=notify service, using python to write directly to the sd_notify socket works; however, using the systemd-notify wrapper command to send READY=1 fails.
VERSION-RELEASE NUMBER OF SELECTED COMPONENT (IF APPLICABLE):
[root@r73beta ~]# rpm -qa systemd\*
systemd-219-26.el7.x86_64
systemd-sysv-219-26.el7.x86_64
systemd-libs-219-26.el7.x86_64
systemd-python-219-26.el7.x86_64
I tested this on both RHEL 7.2 and RHEL 7.3beta.
HOW REPRODUCIBLE:
100%
STEPS TO REPRODUCE:
1. Create service unit
[root@r73beta ~]# cat /etc/systemd/system/zz.service
[Unit]
Description=Test that systemd-notify works
[Service]
Type=notify
ExecStart=/usr/local/sbin/zz.sh
TimeoutStartSec=1
StartLimitInterval=0
NotifyAccess=all
[Install]
WantedBy=multi-user.target
2. Create ExecStart script
[root@r73beta ~]# cat /usr/local/sbin/zz.sh
#!/bin/bash
systemd-notify --status="zz service up and running"
systemd-notify --ready
sleep 9d
[root@r73beta ~]# chmod +x /usr/local/sbin/zz.sh
3. Reload daemon and try to start
[root@r73beta ~]# systemctl daemon-reload
[root@r73beta ~]# systemctl start zz
Job for zz.service failed because a timeout was exceeded. See "systemctl status zz.service" and "journalctl -xe" for details.
[root@r73beta ~]# while :; do systemctl restart zz &>/dev/null && printf . || printf X; done
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX^C
ADDITIONAL INFO:
* The short TimeoutStartSec=1 is just to make testing easier. This is an unloaded system so it's not like the message queue is getting backed up. It still doesn't work if I wait for 20s every time.
* Using "systemd-notify READY=1" instead of --ready makes no difference.
* The same test always succeeds in Fedora 24 with systemd-229-15.fc24 (though I have to move StartLimitInterval=0 to the [Unit] section of course).
* Using python to talk directly to the socket, all is well:
[root@r73beta ~]# sed -i '/ExecStart/s/sh/py/' /etc/systemd/system/zz.service
[root@r73beta ~]# systemctl daemon-reload
[root@r73beta ~]# cat /usr/local/sbin/zz.py
#!/bin/python2
import socket
from os import getenv
from time import sleep
s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
e = getenv('NOTIFY_SOCKET')
s.connect(e)
s.sendall("READY=1")
s.close()
sleep(900)
[root@r73beta ~]# chmod +x /usr/local/sbin/zz.py
[root@r73beta ~]# systemctl start zz
[root@r73beta ~]# while :; do systemctl restart zz &>/dev/null && printf . || printf X; done
.............................................................................^C
(In reply to Jan Synacek from comment #2)
> I can't reproduce this with systemd-219-30.el7. Could you please verify?
Uhh what??
Yes if I follow the exact steps from description I can still reproduce. I just tried:
- fresh rhel 7.3 (systemd-219-30.el7)
- updated rhel 7.3 (systemd-219-30.el7_3.9)
- fresh rhel 7.4beta (systemd-219-39.el7)
Everything behaves the same as how I described back on 2016-10-04. `systemd-notify --ready` doesn't work, but writing READY=1 to socket from python works fine.
I think that I found the culprit, systemd in upstream adds PPID to every message, ours does not do that. If systemd does not get it, it tries to find the unit from which the message was send, but that is extremely racy.
https://github.com/lnykryn/systemd-rhel/pull/124
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:2297
DESCRIPTION OF PROBLEM: When building a simple Type=notify service, using python to write directly to the sd_notify socket works; however, using the systemd-notify wrapper command to send READY=1 fails. VERSION-RELEASE NUMBER OF SELECTED COMPONENT (IF APPLICABLE): [root@r73beta ~]# rpm -qa systemd\* systemd-219-26.el7.x86_64 systemd-sysv-219-26.el7.x86_64 systemd-libs-219-26.el7.x86_64 systemd-python-219-26.el7.x86_64 I tested this on both RHEL 7.2 and RHEL 7.3beta. HOW REPRODUCIBLE: 100% STEPS TO REPRODUCE: 1. Create service unit [root@r73beta ~]# cat /etc/systemd/system/zz.service [Unit] Description=Test that systemd-notify works [Service] Type=notify ExecStart=/usr/local/sbin/zz.sh TimeoutStartSec=1 StartLimitInterval=0 NotifyAccess=all [Install] WantedBy=multi-user.target 2. Create ExecStart script [root@r73beta ~]# cat /usr/local/sbin/zz.sh #!/bin/bash systemd-notify --status="zz service up and running" systemd-notify --ready sleep 9d [root@r73beta ~]# chmod +x /usr/local/sbin/zz.sh 3. Reload daemon and try to start [root@r73beta ~]# systemctl daemon-reload [root@r73beta ~]# systemctl start zz Job for zz.service failed because a timeout was exceeded. See "systemctl status zz.service" and "journalctl -xe" for details. [root@r73beta ~]# while :; do systemctl restart zz &>/dev/null && printf . || printf X; done XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX^C ADDITIONAL INFO: * The short TimeoutStartSec=1 is just to make testing easier. This is an unloaded system so it's not like the message queue is getting backed up. It still doesn't work if I wait for 20s every time. * Using "systemd-notify READY=1" instead of --ready makes no difference. * The same test always succeeds in Fedora 24 with systemd-229-15.fc24 (though I have to move StartLimitInterval=0 to the [Unit] section of course). * Using python to talk directly to the socket, all is well: [root@r73beta ~]# sed -i '/ExecStart/s/sh/py/' /etc/systemd/system/zz.service [root@r73beta ~]# systemctl daemon-reload [root@r73beta ~]# cat /usr/local/sbin/zz.py #!/bin/python2 import socket from os import getenv from time import sleep s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) e = getenv('NOTIFY_SOCKET') s.connect(e) s.sendall("READY=1") s.close() sleep(900) [root@r73beta ~]# chmod +x /usr/local/sbin/zz.py [root@r73beta ~]# systemctl start zz [root@r73beta ~]# while :; do systemctl restart zz &>/dev/null && printf . || printf X; done .............................................................................^C