wrappers/services: RemainAfterExit=yes for oneshot daemons w/ stop cmds #2920

Merged
merged 4 commits into from Feb 23, 2017

Conversation

Projects
None yet
4 participants
Contributor

ssweeny commented Feb 22, 2017

systemd complains if you generate a service file for a oneshot daemon
that also includes an ExecStop directive but doesn't specify
RemainAfterExit=yes. systemd needs this keep track of the service after
the command exits.

Also adds a test for this and fixes a typo in the opening comment of the generated systemd unit file.

Fixes: https://bugs.launchpad.net/snappy/+bug/1647169

ssweeny added some commits Feb 22, 2017

wrappers/services: RemainAfterExit=yes for oneshot daemons w/ stop cmds
systemd complains if you generate a service file for a oneshot daemon
that also includes an ExecStop directive but doesn't specify
RemainAfterExit=yes. systemd needs this keep track of the service after
the command exits.

Also adds a test for this.

Fixes: https://bugs.launchpad.net/snappy/+bug/1647169

zyga approved these changes Feb 22, 2017

Looks good to me. Let's get a second review before landing this. I've requested a small change for testing but consider this approved with that change in place.

@@ -170,7 +170,7 @@ func RemoveSnapServices(s *snap.Info, inter interacter) error {
func genServiceFile(appInfo *snap.AppInfo) string {
serviceTemplate := `[Unit]
-# Auto-generated, DO NO EDIT
+# Auto-generated, DO NOT EDIT
@zyga

zyga Feb 22, 2017

Contributor

Nice :-)

@@ -204,6 +205,17 @@ WantedBy={{.ServicesTarget}}
restartCond = systemd.RestartOnFailure.String()
}
+ var remain string
+ if appInfo.Daemon == "oneshot" {
@zyga

zyga Feb 22, 2017

Contributor

Just thinking aloud. Is there any other condition where we would like to have remain-after-exit set?

wrappers/services_gen_test.go
+ daemon: oneshot
+`
+
+ info, err := snap.InfoFromSnapYaml([]byte(yamlText))
@zyga

zyga Feb 22, 2017

Contributor

We have snaptest.MockYaml from snap/snaptest for this purpose. Please use it here

@ssweeny

ssweeny Feb 22, 2017

Contributor

@zyga Do you mean snaptest.MockSnap? I don't see a MockYaml anywhere.

@zyga

zyga Feb 22, 2017

Contributor

Sorry, I meant MockInfo :-) They differ subtly but I think all you need is MockInfo

mvo5 approved these changes Feb 23, 2017

Looks good, please do merge master into this branch, that should fix the test failure.

@chipaca chipaca merged commit e8fc228 into snapcore:master Feb 23, 2017

4 of 6 checks passed

xenial-ppc64el autopkgtest finished (failure)
Details
zesty-amd64 autopkgtest finished (failure)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
xenial-i386 autopkgtest finished (success)
Details
yakkety-amd64 autopkgtest finished (success)
Details

@ssweeny ssweeny deleted the ssweeny:fix-oneshot-daemons branch Feb 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment