Bug 997031 - StopWhenUnneeded does NOT stop service when there is nothing that Wants/Requires/... it
Summary: StopWhenUnneeded does NOT stop service when there is nothing that Wants/Requi...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: 19
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 997030
TreeView+ depends on / blocked
 
Reported: 2013-08-14 14:12 UTC by Tomáš Hozza
Modified: 2014-06-17 02:43 UTC (History)
8 users (show)

Fixed In Version: systemd-208-14.fc20
Clone Of:
Environment:
Last Closed: 2014-02-24 12:33:22 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hozza 2013-08-14 14:12:04 UTC
Description of problem:
I want to clean up BIND9 unit files. There is a service (two actually) that need to set up a chroot environment before starting the service. bind services Requires the unit for setting up the chroot. The service for setting up chroot has StopWhenUnneeded=yes so it is stopped (and chroot is cleaned up) if the service that started it stopped/crashed/failed while starting and there is no
other service that Requires it.

The problem is that currently with StopWhenUnneeded=yes the service for setting
up the chroot is not stopped even if there is nothing that Requires it (or any
weaker or different relationship).

Version-Release number of selected component (if applicable):
latest (systemd-204-9.fc19)

How reproducible:
always

Steps to Reproduce:
-bash-4.2# more /etc/systemd/system/test*
::::::::::::::
/etc/systemd/system/test.service
::::::::::::::
[Unit]
Description=aaa
Requires=testb.service

[Service]
Type=forking
ExecStart=/bin/sleep 50
TimeoutStartSec=3

::::::::::::::
/etc/systemd/system/testb.service
::::::::::::::
[Unit]
Description=aaa
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/echo hej
ExecStop=/bin/echo hou

-bash-4.2# systemctl status testb test
testb.service - aaa
    Loaded: loaded (/etc/systemd/system/testb.service; static)
    Active: inactive (dead)


test.service - aaa
    Loaded: loaded (/etc/systemd/system/test.service; static)
    Active: inactive (dead)

-bash-4.2# systemctl start test
Job for test.service failed. See 'systemctl status test.service' and 
'journalctl -xn' for details.

-bash-4.2# systemctl status testb test
testb.service - aaa
    Loaded: loaded (/etc/systemd/system/testb.service; static)
    Active: active (exited) since Thu 2013-07-18 15:34:34 CEST; 7s ago
   Process: 45 ExecStart=/bin/echo hej (code=exited, status=0/SUCCESS)

Jul 18 15:34:34 mycontainer systemd[1]: Starting aaa...
Jul 18 15:34:34 mycontainer systemd[1]: Started aaa.

test.service - aaa
    Loaded: loaded (/etc/systemd/system/test.service; static)
    Active: failed (Result: timeout) since Thu 2013-07-18 15:34:37 CEST; 
4s ago
   Process: 46 ExecStart=/bin/sleep 50 (code=killed, signal=TERM)

Jul 18 15:34:34 mycontainer systemd[1]: Starting aaa...
Jul 18 15:34:37 mycontainer systemd[1]: test.service operation timed 
out. Terminating.
Jul 18 15:34:37 mycontainer systemd[1]: Failed to start aaa.
Jul 18 15:34:37 mycontainer systemd[1]: Unit test.service entered failed 
state.

Actual results:
The service with StopWhenUnneeded=yes is NOT stopped if not needed.

Expected results:
The service with StopWhenUnneeded=yes is stopped if not needed.

Additional info:
http://lists.freedesktop.org/archives/systemd-devel/2013-July/012123.html
http://lists.freedesktop.org/archives/systemd-devel/2013-July/012141.html

Comment 1 Lennart Poettering 2014-02-13 01:14:08 UTC
Fixed in git.

Comment 2 Fedora Update System 2014-02-17 07:38:01 UTC
systemd-208-13.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/systemd-208-13.fc20

Comment 3 Fedora Update System 2014-02-17 15:06:00 UTC
systemd-208-14.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/systemd-208-14.fc20

Comment 4 Fedora Update System 2014-02-18 13:37:46 UTC
Package systemd-208-14.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing systemd-208-14.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-2690/systemd-208-14.fc20
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2014-02-24 12:33:22 UTC
systemd-208-14.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.


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