Re: [systemd-devel] How to keep certain services or mounts active during shutdown?

2015-07-14 Thread Frank Steiner
Lennart Poettering wrote

> But this means that wicked is generally incompatible with NFS-root. 

Fortunately not! The SuSE support pointed me to an option that wasn't
documented in the SLES 12 manual section about wicked (but that I could
have found when googling with the correct keywords :-(): Adding

STARTMODE='nfsroot'

in /etc/sysconfig/network/ifcfg-eth0 (instead of auto, onboot, 
manual etc) has exactly the wanted effect: Shutting down wicked, e.g. 
by "systemctl stop wicked" leaves the devices with this option running.
In yast this option can be marked, but I never use yast and to all the
configs manually, so I missed it there, too.

Anyway, problem solved ;-)

cu,
Frank

-- 
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. BioinformatikMail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17   Phone: +49 89 2180-4049
80333 Muenchen, Germany   Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to keep certain services or mounts active during shutdown?

2015-07-03 Thread Lennart Poettering
On Fri, 03.07.15 17:22, Andrei Borzenkov (arvidj...@gmail.com) wrote:

> On Fri, Jul 3, 2015 at 5:03 PM, Frank Steiner
>  wrote:
> > Lennart Poettering wrote
> >
> >> Normally the network mounts should be ordered after network.target,
> >> and wicked before that. Since in systemd the shutdown order is always
> >> the inverse of the startup order this would mean that the mounts are
> >> removed first, and wicked only stopped afterwards.
> >
> > I guess the problem is the root-over-nfs. On reboot I can see all
> > the NFS mounts are unmounted, but not / (which is good :-)). Then wicked
> > stops. It seems the system is not aware of the root fs the way it
> > gets mounted over nfs(v4) in dracut. I can't find any matching .mount
> > in /run/systemd or in "systemctl list-dependencies".
> >
> 
> This would not fit systemd dependency chain anyway. All standard
> services are stopped on shutdown. As long as all existing interfaces
> are represented by a single running service (wickedd) it is
> responsibility of this service to avoid interface shutdown in such
> case. Note that 13.1 tried to use different model where each interface
> had own service. That would allow to easily exempt root filesystem
> interface from shutting down by dropping in DefaultDependency=no.
> 
> Alternative is to always use DefaultDependency=no to keep wikcedd from
> being stopped on shutdown.

I am pretty sure it's simply wrong to shutdown an interface just
because the daemon managing it goes down. Instead the daemon should
maintain its interface state somewhere in /run, and thus support being
restarted or stopped any time, without losing state or breaking the
network connection. That's what we implemented in networkd, basically.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to keep certain services or mounts active during shutdown?

2015-07-03 Thread Lennart Poettering
On Fri, 03.07.15 16:03, Frank Steiner (fsteiner-ma...@bio.ifi.lmu.de) wrote:

> Lennart Poettering wrote
> 
> > Normally the network mounts should be ordered after network.target,
> > and wicked before that. Since in systemd the shutdown order is always
> > the inverse of the startup order this would mean that the mounts are
> > removed first, and wicked only stopped afterwards.
> 
> I guess the problem is the root-over-nfs. On reboot I can see all
> the NFS mounts are unmounted, but not / (which is good :-)). Then wicked
> stops. It seems the system is not aware of the root fs the way it
> gets mounted over nfs(v4) in dracut. I can't find any matching .mount
> in /run/systemd or in "systemctl list-dependencies".

But this means that wicked is generally incompatible with NFS-root. If
it is used in such a setup, then there are two options:

   a) it should be able to leave network interfaces up when it exits

or 

   b) it should run in the initrd, completely outside of all systemd
   management, as something that feels more like a kernel component
   then a userspace component. To make this happen it should run in a
   KillMode=none service, and set its argv[0][0] = '@'. The first
   thing will disable killing in the first shutdown phase, the second
   one also in the second one.

I am pretty sure that a) is the correct option though, and is what we
implement with networkd.

Option b) specifically means that you cannot restart wicked from
binaries of the host, it needs be remain started in the instance from
the initrd, and can never be replaced except via reboot.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to keep certain services or mounts active during shutdown?

2015-07-03 Thread Andrei Borzenkov
On Fri, Jul 3, 2015 at 5:03 PM, Frank Steiner
 wrote:
> Lennart Poettering wrote
>
>> Normally the network mounts should be ordered after network.target,
>> and wicked before that. Since in systemd the shutdown order is always
>> the inverse of the startup order this would mean that the mounts are
>> removed first, and wicked only stopped afterwards.
>
> I guess the problem is the root-over-nfs. On reboot I can see all
> the NFS mounts are unmounted, but not / (which is good :-)). Then wicked
> stops. It seems the system is not aware of the root fs the way it
> gets mounted over nfs(v4) in dracut. I can't find any matching .mount
> in /run/systemd or in "systemctl list-dependencies".
>

This would not fit systemd dependency chain anyway. All standard
services are stopped on shutdown. As long as all existing interfaces
are represented by a single running service (wickedd) it is
responsibility of this service to avoid interface shutdown in such
case. Note that 13.1 tried to use different model where each interface
had own service. That would allow to easily exempt root filesystem
interface from shutting down by dropping in DefaultDependency=no.

Alternative is to always use DefaultDependency=no to keep wikcedd from
being stopped on shutdown.

>> How is that "certaint point" defined? As something like "after service
>> foo has been shut down"? If so, then my recommendation above of adding
>> RequiresMountsFor= to the service sound like the much better solution.
>
> Sounds semantically better! I'll try that!
>
> cu,
> Frank
>
> --
> Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
> Lehrstuhl f. BioinformatikMail: http://www.bio.ifi.lmu.de/~steiner/m/
> LMU, Amalienstr. 17   Phone: +49 89 2180-4049
> 80333 Muenchen, Germany   Fax:   +49 89 2180-99-4049
> * Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to keep certain services or mounts active during shutdown?

2015-07-03 Thread Frank Steiner
Lennart Poettering wrote

> Normally the network mounts should be ordered after network.target,
> and wicked before that. Since in systemd the shutdown order is always
> the inverse of the startup order this would mean that the mounts are
> removed first, and wicked only stopped afterwards.

I guess the problem is the root-over-nfs. On reboot I can see all
the NFS mounts are unmounted, but not / (which is good :-)). Then wicked
stops. It seems the system is not aware of the root fs the way it
gets mounted over nfs(v4) in dracut. I can't find any matching .mount
in /run/systemd or in "systemctl list-dependencies".

> How is that "certaint point" defined? As something like "after service
> foo has been shut down"? If so, then my recommendation above of adding
> RequiresMountsFor= to the service sound like the much better solution.

Sounds semantically better! I'll try that!

cu,
Frank

-- 
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. BioinformatikMail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17   Phone: +49 89 2180-4049
80333 Muenchen, Germany   Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to keep certain services or mounts active during shutdown?

2015-07-03 Thread Lennart Poettering
On Fri, 03.07.15 12:14, Frank Steiner (fsteiner-ma...@bio.ifi.lmu.de) wrote:

Heya,

> > This really depends on the network management service you are
> > using. networkd won't shut down any network connections when you
> > terminate it for example.
> > 
> > Which one are you using?
> 
> it's "wicked" in SLES 12 and it really shuts the network interface down
> (might be configuration issue, though). I managed to keep it up by a 
> drop-in conf with
> ExecStop=
> ExecStop=/usr/bin/true
> (not sure if I need the second one, will check).

Yuck...

Most likely you also need KillMode=none. But this is really a hack...

Normally the network mounts should be ordered after network.target,
and wicked before that. Since in systemd the shutdown order is always
the inverse of the startup order this would mean that the mounts are
removed first, and wicked only stopped afterwards.

Then, after that you should just order the services that need your two
NFS mounts explicitly after them, so that they get stopped first, and
the NFS mounts only removed after that. You can use
RequiresMountsFor=/x/y/z to declar this dep.

> > Note though that there are actual two shutdown phases: the normal one
> > that strictly follows unit dependencies, and which you can influence
> > this way. And a final one, that then tries to clean-up everything that
> > was left over by that first phase. It's basically a umount loop that
> 
> That's ok as I only need to keep the mounts over a certain point, then
> they can go :-)

How is that "certaint point" defined? As something like "after service
foo has been shut down"? If so, then my recommendation above of adding
RequiresMountsFor= to the service sound like the much better solution.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to keep certain services or mounts active during shutdown?

2015-07-03 Thread Frank Steiner
Hi,

Lennart Poettering wrote

>> 1. I want to keep the network running. To avoid problems with dependencies
>>I had to keep it enabled although all the stuff is done in the 
>> kernel/initrd.
>>Thus, it shuts down during reboot and the diskless client hangs
>>of course.
> 
> This really depends on the network management service you are
> using. networkd won't shut down any network connections when you
> terminate it for example.
> 
> Which one are you using?

it's "wicked" in SLES 12 and it really shuts the network interface down
(might be configuration issue, though). I managed to keep it up by a 
drop-in conf with
ExecStop=
ExecStop=/usr/bin/true
(not sure if I need the second one, will check).

> Not sure if I grok why you want to do what you want to do (after all:
> if every user of your two NFS mounts are gone, why keep them around?),

Because we share / read-only with the server and mount only some
stuff (/var e.g.) for the client. To handle own runlevels we create
a tmpfs for /etc/systemd/system in dracut so the client can configure
its own runlevel dependencies.

The drop-in for avoiding the wicked shutdown is, of course, in this
tmpfs and could be unmounted before wicked tries to stop, thus, it
would fail to see the drop-in.

(This tmpfs was a NFS mount yesterday, that's why I wanted to keep it,
but we changed it to a tmpfs now).

> but you can do what you want by writing native .mount unit files for
> the file systems and the set DefaultDependencies=no. This will remove
> the implicit Conflicts= dependencies for shutdown.target. With those
> removed systemd won't try to unmount the mounts during the normal
> shutdown phase (unless there are mounts below them that are unmoutned, of
> course...).

That worked! I created a .mount file for the tmpfs with

DefaultDependencies=no
Before=network-online.target wicked.service

and so it was ordered after wicked during shutdown. 

> Note though that there are actual two shutdown phases: the normal one
> that strictly follows unit dependencies, and which you can influence
> this way. And a final one, that then tries to clean-up everything that
> was left over by that first phase. It's basically a umount loop that

That's ok as I only need to keep the mounts over a certain point, then
they can go :-)

Thanks for your help!
cu,
Frank




-- 
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. BioinformatikMail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17   Phone: +49 89 2180-4049
80333 Muenchen, Germany   Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to keep certain services or mounts active during shutdown?

2015-07-03 Thread Lennart Poettering
On Thu, 02.07.15 12:24, Frank Steiner (fsteiner-ma...@bio.ifi.lmu.de) wrote:

> Hi,
> 
> for our diskless clients I setup the network and the root fs in the 
> kernel/initrd and do two additional mounts in the initrd which are
> specific for every client.
> 
> I understand the boot concept with its dependencies and ordering but I've 
> no idea how to influence the shutdown process in two ways:
> 
> 1. I want to keep the network running. To avoid problems with dependencies
>I had to keep it enabled although all the stuff is done in the 
> kernel/initrd.
>Thus, it shuts down during reboot and the diskless client hangs
>of course.

This really depends on the network management service you are
using. networkd won't shut down any network connections when you
terminate it for example.

Which one are you using?

> 2. The two additional NFS mounts should be kept active, too. There are no
>   *.mount files for them in /run/systemd/generator, because they are
>   mounted in the initrd I guess.
> 
>   Is there a way to exclude certain (NFS) mounts from the umount target
>   (or from sth. else?) during shutting? No matter if they have a *.mount
>   in /run/ or not?

For all mounts created via /etc/fstab, with the exception of mounts
for / and /usr itself, systemd will unmount the file systems after all
units dependning on them have terminated.

Not sure if I grok why you want to do what you want to do (after all:
if every user of your two NFS mounts are gone, why keep them around?),
but you can do what you want by writing native .mount unit files for
the file systems and the set DefaultDependencies=no. This will remove
the implicit Conflicts= dependencies for shutdown.target. With those
removed systemd won't try to unmount the mounts during the normal
shutdown phase (unless there are mounts below them that are unmoutned, of
course...).

Note though that there are actual two shutdown phases: the normal one
that strictly follows unit dependencies, and which you can influence
this way. And a final one, that then tries to clean-up everything that
was left over by that first phase. It's basically a umount loop that
tries to unmount everything until it cannot unmount anything
anymore. You cannot really influence that loop though, but it really
shouldn't matter, since at that point there's nothing running anymore
anyway, except PID 1...

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to keep certain services or mounts active during shutdown?

2015-07-02 Thread Frank Steiner
Mantas Mikulėnas wrote

 > If the 'main' network.service doesn't do anything anyway (since the
> network is already up), you can replace it entirely with Type=oneshot,
> ExecStart=/bin/true, RemainAfterExit=yes, essentially a service that
> does nothing at all (but still satisfies dependencies).

Ok, I'm fine doing it this way! Just thought there might be a better
way.

> 2. The two additional NFS mounts should be kept active, too. There
> are no
>   *.mount files for them in /run/systemd/generator, because they are
>   mounted in the initrd I guess.
> 
> 
> Not sure about this one. I wonder if the "shutdown initramfs" feature
> [1] would help here.

I didn't see how that might help. I'll try to setup *.mount file
for these mounts and try to order them with Before/After directivies
so that they are kept as long as possible during the shutdown.

cu,
Frank

-- 
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. BioinformatikMail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17   Phone: +49 89 2180-4049
80333 Muenchen, Germany   Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to keep certain services or mounts active during shutdown?

2015-07-02 Thread Mantas Mikulėnas
On Thu, Jul 2, 2015 at 1:24 PM, Frank Steiner  wrote:

> Hi,
>
> for our diskless clients I setup the network and the root fs in the
> kernel/initrd and do two additional mounts in the initrd which are
> specific for every client.
>
> I understand the boot concept with its dependencies and ordering but I've
> no idea how to influence the shutdown process in two ways:
>
> 1. I want to keep the network running. To avoid problems with dependencies
>I had to keep it enabled although all the stuff is done in the
> kernel/initrd.
>Thus, it shuts down during reboot and the diskless client hangs of
> course.
>
>Changing the ExecStop to /usr/bin/true does work, but I wonder if there
>is a better way in general to remove a process from the shutdown tree.
>In SysV I just did "inserv -r network" in halt.local so that the
> shutdown
>link was removed before it would be considered.
>
>Is there something similar for systemd? "systemctl disable network"
>didn't work.
>

No. Being an actual service manager, systemd keeps track _internally_ of
which services are active at any moment. Filesystem changes won't affect
that. (Messing around with service state was a bad idea in general, even
with sysvinit.)

If the 'main' network.service doesn't do anything anyway (since the network
is already up), you can replace it entirely with Type=oneshot,
ExecStart=/bin/true, RemainAfterExit=yes, essentially a service that does
nothing at all (but still satisfies dependencies).

(If you _actually_ meant "remove a process" instead of "remove a service",
then yes, there are some other methods, such as KillMethod= or the "@"
prefix [2]. But that isn't of much use for NFS, I think.)

2. The two additional NFS mounts should be kept active, too. There are no
>   *.mount files for them in /run/systemd/generator, because they are
>   mounted in the initrd I guess.
>

Not sure about this one. I wonder if the "shutdown initramfs" feature [1]
would help here.

[1]: http://www.freedesktop.org/wiki/Software/systemd/InitrdInterface/
[2]: http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons/

-- 
Mantas Mikulėnas 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] How to keep certain services or mounts active during shutdown?

2015-07-02 Thread Frank Steiner
Hi,

for our diskless clients I setup the network and the root fs in the 
kernel/initrd and do two additional mounts in the initrd which are
specific for every client.

I understand the boot concept with its dependencies and ordering but I've 
no idea how to influence the shutdown process in two ways:

1. I want to keep the network running. To avoid problems with dependencies
   I had to keep it enabled although all the stuff is done in the kernel/initrd.
   Thus, it shuts down during reboot and the diskless client hangs of course.

   Changing the ExecStop to /usr/bin/true does work, but I wonder if there
   is a better way in general to remove a process from the shutdown tree.
   In SysV I just did "inserv -r network" in halt.local so that the shutdown
   link was removed before it would be considered.
   
   Is there something similar for systemd? "systemctl disable network"
   didn't work.

2. The two additional NFS mounts should be kept active, too. There are no
  *.mount files for them in /run/systemd/generator, because they are
  mounted in the initrd I guess.

  Is there a way to exclude certain (NFS) mounts from the umount target
  (or from sth. else?) during shutting? No matter if they have a *.mount
  in /run/ or not?

cu,
Frank


-- 
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. BioinformatikMail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17   Phone: +49 89 2180-4049
80333 Muenchen, Germany   Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel