Bug 812554

Summary: Shutting down target does not shutdown it's units.
Product: [Fedora] Fedora Reporter: Jóhann B. Guðmundsson <johannbg>
Component: systemdAssignee: systemd-maint
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 16CC: johannbg, metherid, mschmidt, notting, plautrba, systemd-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-04-16 10:42: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 Jóhann B. Guðmundsson 2012-04-14 19:33:44 UTC
Description of problem:

The summary says it all

Version-Release number of selected component (if applicable):

systemd-37-17.fc16.x86_64

How reproducible:

Always

Steps to Reproduce:
1. Create test target 
2. Create a test service and link it to the test.target.wants directory
3. Start the test target
4. Check the status of the test target and the test service
5. Stop the test target
6. Check the status of the test target and the test service

Actual results:

Starting the test target, starts the test target and it's test service however stopping the test target does not stop the test service

Expected results:

The test service to be stopped when test target is stopped.

Additional info:

Comment 1 Michal Schmidt 2012-04-16 10:42:54 UTC
The expectation is baseless. When the service has no requirement dependency on the target, there's no reason to stop the service.

You can however get the behaviour you want by using StopWhenUnneeded=yes in the service unit. Or you may want to add some kind of a requirement dependency of the service on the target. It depends on the specific scenario.

Comment 2 Jóhann B. Guðmundsson 2012-04-16 19:14:08 UTC
In this case I was testing template units as in creating a test.target then generate 50 dummy services which got linked into the test.target.wants directory then start the target to ensure those 50 template based unit got started and stopping it again to ensure those 50 units got stopped when the test.target was stopped.

So what's the best way you think to solve that to get those 50 template based units stopped when the test.target gets stopped since I think the best way to solve the lack of [Install] section in template based unit is this approach and I'm pretty sure that it would not before long that an request would fly in to be able to shutdown all the units in given target?