Re: [systemd-devel] does "Before=network.target" really work

2016-07-06 Thread Michael Biebl
2016-07-06 6:41 GMT+02:00 Lennart Poettering :
> On Fri, 24.06.16 18:53, Xin Long (lucien@gmail.com) wrote:
>> ./firewalld.service:Before=network.target
>
> The line for firewalld appears wrong btw. The firewall should really
> be up before the network is even initiated. Hence it should be
> Before=network-pre.target.

I've filed https://github.com/t-woerner/firewalld/issues/137 for this issue
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] does "Before=network.target" really work

2016-07-05 Thread Lennart Poettering
On Fri, 24.06.16 18:53, Xin Long (lucien@gmail.com) wrote:

> 
> but I can find some services are truly using it now:
> $ grep "Before=network.target" . -R
> ./wpa_supplicant.service:Before=network.target
> ./NetworkManager.service:Before=network.target
> ./NetworkManager-wait-online.service:Before=network.target 
> network-online.target
> ./arp-ethers.service:Before=network.target
> ./firewalld.service:Before=network.target

The line for firewalld appears wrong btw. The firewall should really
be up before the network is even initiated. Hence it should be
Before=network-pre.target.

Lennart

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


Re: [systemd-devel] does "Before=network.target" really work

2016-07-05 Thread Lennart Poettering
On Fri, 24.06.16 18:41, Xin Long (lucien@gmail.com) wrote:

> On Fri, Jun 24, 2016 at 6:23 PM, Andrei Borzenkov  wrote:
> > On Fri, Jun 24, 2016 at 1:11 PM, Xin Long  wrote:
> >> Hi,
> >>
> >> I have a service, and want it to be stopped only after network is
> >> stopped when system shutdown.
> >>
> >> I checked "man systemd.special ", network is a special internal
> >> service for systemd, , and I found "network.target":
> >> "at shutdown, a unit that is ordered after network.target will be
> >> stopped before the network -- to whatever  level it might be set up
> >> then -- is shut down".
> >> That means "After=network.target" can work well.
> >>
> >> But my situation is opposite to that, I need "a unit that is ordered
> >> before network.target will be stopped *after* the network so
> >> shutdown".
> >>
> >> So I added "Before=network.target" to .service file. can it really
> >> work as I expect?
> >>
> >
> > No. That is why systemd was forced to introduce additional
> > network-pre.target to make it possible to explicitly order things
> > before networking is started (or stop after networking has been
> > stopped - assuming of course that all services that implement
> > networking correct order themselves After network-pre.target).
> 
> So you mean "Before=network-pre.target" can work on my case, right ?

Yes, that's what it is for. Also make sure to actually pull in the
target from your service too. Hence you want:

Before=network-pre.target
Wants=network-pre.target

n-p.t is a target that is "passive", it needs to be pulled in by the
implementor of such a service, not by the consumer of it. This has the
benefit that as long as no service wants to hook into this nothing is
added to the transactions for bootup and shutdown and thus more can be
parallelized as one synchronization points less is in the queue.

See systemd.special(7) about it as well as
https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

> >> I have a service, and want it to be stopped only after network is
> >> stopped when system shutdown
> 
> and since which version "network-pre.target" was introduced ?
> cause I didn't find it in "man systemd.special" in my system.

This has been addedin systemd 214.

Lennart

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


Re: [systemd-devel] does "Before=network.target" really work

2016-06-24 Thread Andrei Borzenkov
On Fri, Jun 24, 2016 at 1:41 PM, Xin Long  wrote:
> On Fri, Jun 24, 2016 at 6:23 PM, Andrei Borzenkov  wrote:
>> On Fri, Jun 24, 2016 at 1:11 PM, Xin Long  wrote:
>>> Hi,
>>>
>>> I have a service, and want it to be stopped only after network is
>>> stopped when system shutdown.
>>>
>>> I checked "man systemd.special ", network is a special internal
>>> service for systemd, , and I found "network.target":
>>> "at shutdown, a unit that is ordered after network.target will be
>>> stopped before the network -- to whatever  level it might be set up
>>> then -- is shut down".
>>> That means "After=network.target" can work well.
>>>
>>> But my situation is opposite to that, I need "a unit that is ordered
>>> before network.target will be stopped *after* the network so
>>> shutdown".
>>>
>>> So I added "Before=network.target" to .service file. can it really
>>> work as I expect?
>>>
>>
>> No. That is why systemd was forced to introduce additional
>> network-pre.target to make it possible to explicitly order things
>> before networking is started (or stop after networking has been
>> stopped - assuming of course that all services that implement
>> networking correct order themselves After network-pre.target).
>
> So you mean "Before=network-pre.target" can work on my case, right ?
>

Yes.

>>> I have a service, and want it to be stopped only after network is
>>> stopped when system shutdown
>
> and since which version "network-pre.target" was introduced ?
> cause I didn't find it in "man systemd.special" in my system.

No idea. It is commit a4a878d04045b46fa9783664e3643a890b356790.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] does "Before=network.target" really work

2016-06-24 Thread Xin Long
On Fri, Jun 24, 2016 at 6:22 PM, Michael Hirmke  wrote:
> Hi Xin,
>
>>Hi,
>
>>I have a service, and want it to be stopped only after network is
>>stopped when system shutdown.
>
>>I checked "man systemd.special ", network is a special internal
>>service for systemd, , and I found "network.target":
>>"at shutdown, a unit that is ordered after network.target will be
>>stopped before the network -- to whatever  level it might be set up
>>then -- is shut down".
>>That means "After=network.target" can work well.
>
>>But my situation is opposite to that, I need "a unit that is ordered
>>before network.target will be stopped *after* the network so
>>shutdown".
>
>>So I added "Before=network.target" to .service file. can it really
>>work as I expect?
>
> it depends on what you're trying to do with this information.
> AFAIK network.target is related to the network stack as such. It does
> not apply to a certain interface is up, down, activated or deactivated.
> If you need the information for the network stack being up or down,
> the use of network.target is ok - and works for me.
>
my case only cares about shutdown time.
I do not know "Before=network.target" can make my service stop
after which phase of network is stopped.
and I also cannot find anything in man doc.

but I can find some services are truly using it now:
$ grep "Before=network.target" . -R
./wpa_supplicant.service:Before=network.target
./NetworkManager.service:Before=network.target
./NetworkManager-wait-online.service:Before=network.target network-online.target
./arp-ethers.service:Before=network.target
./firewalld.service:Before=network.target

what I need is just make sure my service will stop after we just can't
communicate with other host. (no need to after device down, or stack
is removed)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] does "Before=network.target" really work

2016-06-24 Thread Xin Long
On Fri, Jun 24, 2016 at 6:23 PM, Andrei Borzenkov  wrote:
> On Fri, Jun 24, 2016 at 1:11 PM, Xin Long  wrote:
>> Hi,
>>
>> I have a service, and want it to be stopped only after network is
>> stopped when system shutdown.
>>
>> I checked "man systemd.special ", network is a special internal
>> service for systemd, , and I found "network.target":
>> "at shutdown, a unit that is ordered after network.target will be
>> stopped before the network -- to whatever  level it might be set up
>> then -- is shut down".
>> That means "After=network.target" can work well.
>>
>> But my situation is opposite to that, I need "a unit that is ordered
>> before network.target will be stopped *after* the network so
>> shutdown".
>>
>> So I added "Before=network.target" to .service file. can it really
>> work as I expect?
>>
>
> No. That is why systemd was forced to introduce additional
> network-pre.target to make it possible to explicitly order things
> before networking is started (or stop after networking has been
> stopped - assuming of course that all services that implement
> networking correct order themselves After network-pre.target).

So you mean "Before=network-pre.target" can work on my case, right ?

>> I have a service, and want it to be stopped only after network is
>> stopped when system shutdown

and since which version "network-pre.target" was introduced ?
cause I didn't find it in "man systemd.special" in my system.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] does "Before=network.target" really work

2016-06-24 Thread Andrei Borzenkov
On Fri, Jun 24, 2016 at 1:11 PM, Xin Long  wrote:
> Hi,
>
> I have a service, and want it to be stopped only after network is
> stopped when system shutdown.
>
> I checked "man systemd.special ", network is a special internal
> service for systemd, , and I found "network.target":
> "at shutdown, a unit that is ordered after network.target will be
> stopped before the network -- to whatever  level it might be set up
> then -- is shut down".
> That means "After=network.target" can work well.
>
> But my situation is opposite to that, I need "a unit that is ordered
> before network.target will be stopped *after* the network so
> shutdown".
>
> So I added "Before=network.target" to .service file. can it really
> work as I expect?
>

No. That is why systemd was forced to introduce additional
network-pre.target to make it possible to explicitly order things
before networking is started (or stop after networking has been
stopped - assuming of course that all services that implement
networking correct order themselves After network-pre.target).
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] does "Before=network.target" really work

2016-06-24 Thread Michael Hirmke
Hi Xin,

>Hi,

>I have a service, and want it to be stopped only after network is
>stopped when system shutdown.

>I checked "man systemd.special ", network is a special internal
>service for systemd, , and I found "network.target":
>"at shutdown, a unit that is ordered after network.target will be
>stopped before the network -- to whatever  level it might be set up
>then -- is shut down".
>That means "After=network.target" can work well.

>But my situation is opposite to that, I need "a unit that is ordered
>before network.target will be stopped *after* the network so
>shutdown".

>So I added "Before=network.target" to .service file. can it really
>work as I expect?

it depends on what you're trying to do with this information.
AFAIK network.target is related to the network stack as such. It does
not apply to a certain interface is up, down, activated or deactivated.
If you need the information for the network stack being up or down,
the use of network.target is ok - and works for me.

>Thanks

Bye.
Michael.
-- 
Michael Hirmke
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel