On Sat, Mar 12, 2011 at 1:00 PM, Andrey Borzenkov <[email protected]> wrote:
> On Sat, Mar 12, 2011 at 3:14 AM, Michael Biebl <[email protected]> wrote:
>> 2011/3/12 Michael Biebl <[email protected]>:
>>> 2011/3/11 Andrey Borzenkov <[email protected]>:
>>>> On Fri, Mar 11, 2011 at 9:10 PM, Mike Kazantsev <[email protected]>
>>>> wrote:
>>>
>>>>
>>>>> Btw, rsyslog.service seem to be installed into multi-user.target.wants,
>>>>> why not syslog.target, which seem to indicate the point where proper
>>>>> syslog daemon is running (according to systemd.special(7))?
>>>>>
>>>>
>>>> Actually good question (same as for portmap) - who should pull in
>>>> syslog.target then?
>>>
>>> Yeah, I noticed this myself already. Quite a bit of syslog output
>>> ended up in /proc/kmsg during boot because rsyslog was started rather
>>> late (via multi-user.target).
>>> Afaics, there is not explicit symlink pulling in syslog.target, so I
>>> assume it is handled internally by systemd. Lennart?
>>
>> Turns out, that indeed syslog.target is not automatically started.
>> I symlinked syslog.target into multi-user.target.wants and
>> rsyslog.service into syslog.target.wants.
>>
>> Now all services with After=syslog.target are correctly started after
>> rsyslog.service.
>>
>> Lennart, I think we should add those changes to systemd and rsyslog.service.
>>
>
> The problem is not limited to syslog and applies to all special
> targets that serve as "virtual provides"
>
> Actually I think design should be reversed. The service that
> implements this virtual provide (syslog, network, rpcbind, smtp, ...)
> should pull in special target. This way you ensure
>
> - when service that provides functionality is started, corresponding
> virtual target is started as indication, that functionality is
> available
>
> - if there is no service with requested functionality, target is not
> available. In other words - target is not faked to be started unless
> functionality is available. This allows easy and logical check,
> whether syslog (rpcbind, network, ...) was really provided by any
> service - if unit is not started, it was not. To round this off,
> specials should also refuse manual activation.
>
> That does not apply to all specials; some of them do serve as "virtual
> requires" and pull in other services on demand. Think about
> bluetooth.target. Although (as Lennart replied regarding network) it
> should probably in reality be hci.tagret (or more generically -
> bt-device.target) rather than bluetooth.service, as it is exactly what
> we want to *pull* - specific driver for BT device. Which - in turn
> should pull in bluetooth.target as indication that BT is now
> available.
>
> Specials should really be generic statement "this functionality is now
> available". Not means to achieve this functionality.
>
Here is proof of concept patch. Notice that nfs fails utterly because
it is started before rpc is ready without this patch (and yes, I know
about socket activation for rpcbind, It is not the point here).
rpcbind part is fixed by src/service.c patch. syslog part is fixed by
addin Wants=syslog.target to rsyslog.service.
Before
[root@localhost ~]# systemctl --no-pager -p After -p Before -p Wants
-p WantedBy -p Id show syslog.target rsyslog.service rpcbind.service
rpcbind.target
Id=syslog.target
Wants=
WantedBy=
Before=dbus.service prefdm.service networkmanager.service
acpid.service crond.service shorewall.service
console-kit-daemon.service
After=syslog.socket rsyslog.service
Id=rsyslog.service
Wants=
WantedBy=multi-user.target
Before=syslog.target shutdown.target
After=local-fs.target basic.target
Id=rpcbind.service
Wants=
WantedBy=rpcbind.target multi-user.target graphical.target
Before=rpcbind.target shutdown.target multi-user.target graphical.target
After=network.target basic.target
Id=rpcbind.target
Wants=rpcbind.service
WantedBy=
Before=netfs.service nfs-common.service
After=rpcbind.service
[root@localhost ~]# systemctl status syslog.target rsyslog.service
rpcbind.service rpcbind.target
syslog.target - Syslog
Loaded: loaded (/lib/systemd/system/syslog.target)
Active: inactive (dead)
rsyslog.service - System Logging Service
Loaded: loaded (/lib/systemd/system/rsyslog.service)
Active: active (running) since Sat, 12 Mar 2011 13:59:24
+0300; 1min 14s ago
Process: 797 ExecStartPre=/bin/systemctl stop
systemd-kmsg-syslogd.service (code=exited, status=0/SUCCESS)
Main PID: 856 (rsyslogd)
CGroup: name=systemd:/system/rsyslog.service
└ 856 /sbin/rsyslogd -n -c 4
rpcbind.service - LSB: Start the rpcbind daemon
Loaded: loaded (/etc/rc.d/init.d/rpcbind)
Active: active (running) since Sat, 12 Mar 2011 13:59:30
+0300; 1min 8s ago
Process: 1474 ExecStart=/etc/rc.d/init.d/rpcbind start
(code=exited, status=0/SUCCESS)
Main PID: 1499 (rpcbind)
CGroup: name=systemd:/system/rpcbind.service
└ 1499 rpcbind -i
rpcbind.target - RPC Port Mapper
Loaded: loaded (/lib/systemd/system/rpcbind.target)
Active: inactive (dead)
[root@localhost ~]# systemd-cgls /system/nfs-common.service
/system/nfs-common.service:
Failed to list cgroup tree: No such file or directory
[root@localhost ~]# systemd-cgls /system/nfs-server.service
/system/nfs-server.service:
Failed to list cgroup tree: No such file or directory
[root@localhost ~]# systemd-cgls /system/nfs-common.service rpcbind.target^C
[root@localhost ~]# systemctl status nfs-server.service
nfs-common.servicenfs-server.service - LSB: Kernel NFS server support
Loaded: loaded (/etc/rc.d/init.d/nfs-server)
Active: active (exited) since Sat, 12 Mar 2011 13:59:26
+0300; 2min 12s ago
Process: 920 ExecStart=/etc/rc.d/init.d/nfs-server start
(code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/nfs-server.service
nfs-common.service - LSB: NFS support files common to client and server
Loaded: loaded (/etc/rc.d/init.d/nfs-common)
Active: active (exited) since Sat, 12 Mar 2011 13:59:24
+0300; 2min 13s ago
Process: 794 ExecStart=/etc/rc.d/init.d/nfs-common start
(code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/nfs-common.service
After:
[root@localhost ~]# systemctl --no-pager -p After -p Before -p Wants
-p WantedBy -p Id show syslog.target rsyslog.service rpcbind.service
rpcbind.target
Id=syslog.target
Wants=
WantedBy=rsyslog.service
Before=dbus.service prefdm.service networkmanager.service
acpid.service crond.service shorewall.service
console-kit-daemon.service
After=syslog.socket rsyslog.service
Id=rsyslog.service
Wants=syslog.target
WantedBy=multi-user.target
Before=syslog.target shutdown.target
After=local-fs.target basic.target
Id=rpcbind.service
Wants=rpcbind.target
WantedBy=rpcbind.target multi-user.target graphical.target
Before=rpcbind.target shutdown.target multi-user.target graphical.target
After=network.target basic.target
Id=rpcbind.target
Wants=rpcbind.service
WantedBy=rpcbind.service
Before=netfs.service nfs-common.service
After=rpcbind.service
root@localhost ~]# systemctl status syslog.target rsyslog.service
rpcbind.service rpcbind.target
syslog.target - Syslog
Loaded: loaded (/lib/systemd/system/syslog.target)
Active: active since Sat, 12 Mar 2011 13:48:53 +0300; 4min 33s ago
rsyslog.service - System Logging Service
Loaded: loaded (/etc/systemd/system/rsyslog.service)
Active: active (running) since Sat, 12 Mar 2011 13:48:53
+0300; 4min 33s ago
Process: 795 ExecStartPre=/bin/systemctl stop
systemd-kmsg-syslogd.service (code=exited, status=0/SUCCESS)
Main PID: 834 (rsyslogd)
CGroup: name=systemd:/system/rsyslog.service
└ 834 /sbin/rsyslogd -n -c 4
rpcbind.service - LSB: Start the rpcbind daemon
Loaded: loaded (/etc/rc.d/init.d/rpcbind)
Active: active (running) since Sat, 12 Mar 2011 13:48:59
+0300; 4min 28s ago
Process: 1430 ExecStart=/etc/rc.d/init.d/rpcbind start
(code=exited, status=0/SUCCESS)
Main PID: 1441 (rpcbind)
CGroup: name=systemd:/system/rpcbind.service
└ 1441 rpcbind -i
rpcbind.target - RPC Port Mapper
Loaded: loaded (/lib/systemd/system/rpcbind.target)
Active: active since Sat, 12 Mar 2011 13:48:59 +0300; 4min 28s ago
[root@localhost ~]# systemd-cgls /system/nfs-common.service
/system/nfs-common.service:
├ 1463 rpc.statd
└ 1479 rpc.idmapd
[root@localhost ~]# systemd-cgls /system/nfs-server.service
/system/nfs-server.service:
└ 1577 rpc.mountd
From: Andrey Borzenkov <[email protected]>
Subject: [PATCH] service: ensure SysV script pulls in special target it implements
Those virtual provides are not started by anything unless they are
Required. For SysV scripts we add only ordering dependencies; so
even if SysV script that provides $SPECIAL_TARGET is started, the
$SPECIAL_TARGET itself is not. This breaks all units that depend
on it, as they are started too early.
Make sure to add inverse Wants dependency so $SPECIAL_TARGET will be
pulled in transaction.
When SysV scripts are replaced by native units, those units should
keep explicit Before and Wants as well.
---
man/systemd.special.xml.in | 32 ++++++++++++++++++++++++--------
src/service.c | 3 ++-
2 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/man/systemd.special.xml.in b/man/systemd.special.xml.in
index afe882e..69e26c4 100644
--- a/man/systemd.special.xml.in
+++ b/man/systemd.special.xml.in
@@ -334,6 +334,11 @@
referring to the
<literal>$network</literal>
facility.</para>
+
+ <para>Services that start
+ networkig should have Wants
+ and Before dependencies for this
+ target.</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -347,6 +352,11 @@
referring to the
<literal>$named</literal>
facility.</para>
+
+ <para>Services that implement
+ name resolution should have Wants
+ and Before dependencies for this
+ target.</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -420,6 +430,11 @@
referring to the
<literal>$rpcbind</literal>
facility.</para>
+
+ <para>Services that implement
+ port mapping should have Wants
+ and Before dependencies for this
+ target.</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -433,6 +448,11 @@
referring to the
<literal>$time</literal>
facility.</para>
+
+ <para>Services that implement
+ time setting should have Wants
+ and Before dependencies for this
+ target.</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -598,14 +618,10 @@
<literal>$syslog</literal>
facility.</para>
- <para>Administrators should
- ensure that this target pulls
- in a service unit with the
- name or alias of
- <filename>@SPECIAL_SYSLOG_SERVICE@</filename>
- (or a socket unit that
- activates this
- service).</para>
+ <para>Services that implement
+ syslog should have Wants
+ and Before dependencies for this
+ target.</para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/src/service.c b/src/service.c
index 70999f3..3aca21d 100644
--- a/src/service.c
+++ b/src/service.c
@@ -662,7 +662,8 @@ static int service_load_sysv_path(Service *s, const char *path) {
if (s->sysv_enabled) {
int k;
- if ((k = unit_add_dependency_by_name_inverse(u, UNIT_WANTS, m, NULL, true)) < 0)
+ if ((k = unit_add_dependency_by_name_inverse(u, UNIT_WANTS, m, NULL, true)) < 0 ||
+ (k = unit_add_dependency_by_name(u, UNIT_WANTS, m, NULL, true)) < 0)
r = k;
}
}
--
tg: (2570558..) upstream/specials (depends on: origin/master)
_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel