From 20fe9da98ed69187faab80810c652fdc051b627e Mon Sep 17 00:00:00 2001 From: Paride Legovini Date: Thu, 27 Aug 2020 19:16:13 +0200 Subject: systemd: add Before=shutdown.target when Conflicts=shutdown.target is used (#546) Lintian spotted the following issue: The specified systemd .service file contains both DefaultDependencies=no and Conflicts=shutdown.target directives without Before=shutdown.target. This can lead to problems during shutdown because the service may linger until the very end of shutdown sequence as nothing requests to stop it before (due to DefaultDependencies=no). There is race condition between stopping units and systemd getting a request to exit the main loop, so it may proceed with shutdown before all pending stop jobs have been processed. Please add Before=shutdown.target. [1] https://lintian.debian.org/tags/systemd-service-file-shutdown-problems.html Co-authored-by: Rick Harding --- systemd/cloud-init.service.tmpl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'systemd') diff --git a/systemd/cloud-init.service.tmpl b/systemd/cloud-init.service.tmpl index af6d9a8b..f140344d 100644 --- a/systemd/cloud-init.service.tmpl +++ b/systemd/cloud-init.service.tmpl @@ -25,9 +25,11 @@ Before=sshd-keygen.service Before=sshd.service {% if variant in ["ubuntu", "unknown", "debian"] %} Before=sysinit.target +Before=shutdown.target Conflicts=shutdown.target {% endif %} {% if variant in ["suse"] %} +Before=shutdown.target Conflicts=shutdown.target {% endif %} Before=systemd-user-sessions.service -- cgit v1.2.1