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.
Bug 1775291 - Services with Restart=always fail to restart when it has a dependent service with StopWhenUnneeded=true
Summary: Services with Restart=always fail to restart when it has a dependent service ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd
Version: 7.7
Hardware: Unspecified
OS: Unspecified
urgent
high
Target Milestone: rc
: ---
Assignee: David Tardon
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks: 1773531 1810576
TreeView+ depends on / blocked
 
Reported: 2019-11-21 16:55 UTC by Michael Johnson
Modified: 2020-09-29 20:33 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1810576 (view as bug list)
Environment:
Last Closed: 2020-09-29 20:32:27 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github systemd systemd pull 9853 0 None closed rework StopWhenUnneeded=1 logic 2020-10-23 19:20:59 UTC
Red Hat Bugzilla 1773531 0 high CLOSED Haproxy process failure is not triggering amphora recreation 2022-08-10 17:15:57 UTC
Red Hat Product Errata RHSA-2020:4007 0 None None None 2020-09-29 20:33:15 UTC

Internal Links: 1773531 1784845

Description Michael Johnson 2019-11-21 16:55:57 UTC
Description of problem:
When a service is configured with "Restart=always" has a "Requires" link to a service that has "StopWhenUnneeded=true" defined, the restart of the parent service will fail to restart.

Version-Release number of selected component (if applicable):
systemd-219-67.el7_7.2.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Create a service "A", in this case I will use the HAProxy service as an example.
2. In the service definition, add "[Service] Restart=always" to this definition.
3. Create another service "B", something simple that "cat /proc/cpuinfo" for example.
4. In the definition for "B", add "[Unit] StopWhenUnneeded=true".
5. Not relevant to the bug, but for completeness, in service "B" definition, add "[Service] Type=oneshot RemainAfterExit=yes".
6. In service "A" definition, add "[Unit] After= <Service "B"> Requires=<Service "B">".
7. systemctl start service "A".
8. Confirm that service "A" started successfully and that the HAProxy processes are running ("haproxy-systemd-wrapper" process is the important one).
9. Identify the "haproxy-systemd-wrapper" process PID. It should have a parent process of 1.
10. kill -9 <haproxy-systemd-wrapper process PID>.
11. Search for the haproxy process in the process list. Note that haproxy did not restart.

To see the expected result, comment out the "StopWhenUnneeded=true" in the service "B" definition.

Actual results:
Nov 20 14:59:57 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: haproxy-d3dce9f6-218c-4d8b-90db-233b939922d3.service: main process exited, code=killed, status=9/KILL
Nov 20 14:59:57 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: Unit amphora-netns.service is not needed anymore. Stopping.
Nov 20 14:59:57 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: Stopped HAProxy Load Balancer.
Nov 20 14:59:57 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: Unit amphora-netns.service is not needed anymore. Stopping.
Nov 20 14:59:57 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: Unit haproxy-d3dce9f6-218c-4d8b-90db-233b939922d3.service entered failed state.
Nov 20 14:59:57 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: haproxy-d3dce9f6-218c-4d8b-90db-233b939922d3.service failed.
Nov 20 14:59:57 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: Stopped Configure amphora-haproxy network namespace.

The haproxy processes did not restart.

Expected results:
Nov 21 11:47:12 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: haproxy-d3dce9f6-218c-4d8b-90db-233b939922d3.service: main process exited, code=killed, status=9/KILL
Nov 21 11:47:12 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: Unit haproxy-d3dce9f6-218c-4d8b-90db-233b939922d3.service entered failed state.
Nov 21 11:47:12 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: haproxy-d3dce9f6-218c-4d8b-90db-233b939922d3.service failed.
Nov 21 11:47:13 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: haproxy-d3dce9f6-218c-4d8b-90db-233b939922d3.service holdoff time over, scheduling restart.
Nov 21 11:47:13 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: Stopped HAProxy Load Balancer.
Nov 21 11:47:13 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: Starting HAProxy Load Balancer...
Nov 21 11:47:13 amphora-53c81d62-544a-4d65-b264-c942a638ec43 systemd: Started HAProxy Load Balancer.

The haproxy processes have been restarted

Additional info:
This issue is impacting Red Hat OpenStack Platform 13+.

This issue is not observed on instances running Ubuntu 18.04.

It may be related to upstream bug: https://github.com/systemd/systemd/issues/1154

This is directly impacting the ability for HAProxy processes to automatically recover should it have a fault or run out of memory due to excessive connections.

Comment 2 Michael Johnson 2019-11-21 17:05:00 UTC
This may also be related to upstream bug: https://github.com/systemd/systemd/issues/7377

Comment 3 Carlos Goncalves 2019-11-21 17:14:54 UTC
Systemd in RHEL 8.x might also need to be fixed.

Comment 17 Lukáš Nykrýn 2020-04-29 13:58:44 UTC
fix merged to github master branch -> https://github.com/systemd-rhel/rhel-7/pull/70

Comment 23 errata-xmlrpc 2020-09-29 20:32:27 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 (Low: systemd security and bug fix update), 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/RHSA-2020:4007


Note You need to log in before you can comment on or make changes to this bug.