Re: [systemd-devel] Requires and After

2019-01-01 Thread Olaf van der Spek
On Wed, Jan 2, 2019 at 4:22 AM James Feeney  wrote:
> systemd has two different classes of "dependencies": 1) "activation" 
> dependencies, and 2) "ordering" dependencies.
>
> An activation dependency does not, a priori, have to obey any rules about 
> ordering.  There are not, automatically, any promises or guarantees about in 
> what order service units, for instance, might be queued for execution, based 
> upon a Requires= dependency.
>
> "Ordering" is an independent characteristic from "Activation".  "Activation" 
> only promises to enqueue a unit, and then, only if the unit is some kind of 
> unit that can be "executed", such as a timer or service unit.  In contrast, 
> for instance, systemd is only a "passive observer" of a device unit.  
> "enqueuing" a device unit for "activation" would make no sense in this 
> context.  A *service* unit that *creates* a device unit could be enqueued for 
> activation, but not the device unit itself.
>
> If "A Requires B", and you don't like that "A" *might* get enqueued, or get 
> executed, before "B", then add an "ordering" dependency.  "Ordering 
> dependencies", then, create guarantees about unit activation *ordering*.

What good is an activation dependency without an ordering dependency?
Activation by itself guarantees basically nothing.

>> . I think a unit in Requires should imply that unit in After too, otherwise 
>> the requirement isn't really met. Is there a use case for Requires but not 
>> After?

> Are you sure that you were not wondering about "Requisite=", instead of 
> "Requires="?

Yes, I am, though Requisite looks interesting too.

> Because, as far as I know, "Requisite=" is completely broken in systemd.

How is it broken?


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


Re: [systemd-devel] .service and .socket

2019-01-01 Thread Michael Chapman
On Tue, 1 Jan 2019, Olaf van der Spek wrote:
> Hi,
> 
> AFAIK socket units require a separate file, which seems more complex
> then it has to be.
> 
> 1. Could sockets be specified directly in the .service file?

If anything, I should think it would work the other way around: a .socket 
without any activatable .service is relatively useless.

But I'm not proposing that this actually be implemented.

> 2. If not, could the .service file gain a default / implicit
> dependency on the .socket file?

There are a some reasons for not having a .service dependent upon its 
.socket. Many services can be started directly and will work correctly 
even when not passed any sockets from systemd.

> 3. AFAIK Install.WantedBy doesn't have a default. Could it get a proper 
> default?

That doesn't make much sense.

Take your example:

> xhp.service:
> [Unit]
> Requires=xhp.socket
> 
> [Install]
> WantedBy=default.target
> 
> xhp.socket:
> [Socket]
> ListenStream=/run/xhp.socket

This would start xhp.service at daemon startup (i.e. boot, for the system 
daemon) whether or not the service is actually required. One of the 
reasons for using socket activation is to _not_ start services when 
they're not required.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Requires and After

2019-01-01 Thread James Feeney
On 1/1/19 8:33 PM, Reindl Harald wrote:
> "After" is a soft dependency, if that unit isn't enabled or don#t exist
> at all it don't matter
> 
> "Requires" is a hard dependency and it makes no sense not imply ordering

And then, what do you mean by "soft dependency" and "hard dependency"?  It 
sounds like you are calling an ordering dependency "soft" and an activation 
dependency "hard".

I'm sorry, I do not understand what you mean by "makes no sense not imply 
ordering".  Do you mean "to not imply ordering makes no sense"?  In which case, 
are you saying that "an activation dependency must imply an ordering"?  That 
would not be true.  Activating a unit does not automatically imply or require 
that that unit be activated or deactivated in any particular order relative to 
any other unit.

Did you also mean to say "If a unit is not active or does not exist then the 
ordering of that unit does not matter"?  Well, the "ordering" of a nonexistent 
unit would not have any meaning.

However there is also the case of an active unit that may become inactive, in 
addition to the case of an inactive unit that may become active.  While the 
order of activation or deactivation, relative to other units, of a unit that 
exists has meaning, that order may not, a priori, be of any importance or 
consequence.  But I would not go so far as to say that the order of activation 
of an inactive unit does not matter.  The order of activation of an inactive 
unit may actually be important, in which case, an ordering dependency can be 
specified.

So, I think that I am missing your point, with respect to "soft" and "hard" 
dependencies.  Maybe you could express your meaning in another way?

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


Re: [systemd-devel] Requires and After

2019-01-01 Thread James Feeney
> It's about Requires and After. I think a unit in Requires should imply
> that unit in After too, otherwise the requirement isn't really met.
> Is there a use case for Requires but not After?

Olaf, previously, on GitHub, you had said:

>> I think I understand Requires and After ...

and, I would suggest that, no - or you would not be asking this question.

systemd has two different classes of "dependencies": 1) "activation" 
dependencies, and 2) "ordering" dependencies.

An activation dependency does not, a priori, have to obey any rules about 
ordering.  There are not, automatically, any promises or guarantees about in 
what order service units, for instance, might be queued for execution, based 
upon a Requires= dependency.

"Ordering" is an independent characteristic from "Activation".  "Activation" 
only promises to enqueue a unit, and then, only if the unit is some kind of 
unit that can be "executed", such as a timer or service unit.  In contrast, for 
instance, systemd is only a "passive observer" of a device unit.  "enqueuing" a 
device unit for "activation" would make no sense in this context.  A *service* 
unit that *creates* a device unit could be enqueued for activation, but not the 
device unit itself.

If "A Requires B", and you don't like that "A" *might* get enqueued, or get 
executed, before "B", then add an "ordering" dependency.  "Ordering 
dependencies", then, create guarantees about unit activation *ordering*.

Are you sure that you were not wondering about "Requisite=", instead of 
"Requires="?  Because, as far as I know, "Requisite=" is completely broken in 
systemd.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Requires and After

2019-01-01 Thread Reindl Harald


Am 01.01.19 um 20:24 schrieb Tomasz Torcz:
> On Tue, Jan 01, 2019 at 08:20:19PM +0100, Olaf van der Spek wrote:
>> On Tue, Jan 1, 2019 at 8:17 PM Ian Pilcher  wrote:
>>>
>>> On 1/1/19 5:44 AM, Jérémy Rosen wrote:
 The short answer is that Requires without after makes little sense,
 since you can't reliably know if your dependency is here without it
 (if it fails at startup, you might or might not be started, depending
 on the startup order systemd chooses)
>>>
>>> There are cases where it makes sense.  For example, most OpenStack
>>> services require both a message bus and a database, but they are smart
>>> enough to wait and re-attempt their connections if either of those
>>> services isn't immediately available.
>>
>> What's the benefit of not having After= for those services?
> 
> I guess they can start and do their initialization in parallel with
> the service they require.

assumption or measured benefit?

most error handling for such cases has some sleep time which tyically
makes things slower than work with the initalization until everything is
in a proper state


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


Re: [systemd-devel] Requires and After

2019-01-01 Thread Tomasz Torcz
On Tue, Jan 01, 2019 at 08:20:19PM +0100, Olaf van der Spek wrote:
> On Tue, Jan 1, 2019 at 8:17 PM Ian Pilcher  wrote:
> >
> > On 1/1/19 5:44 AM, Jérémy Rosen wrote:
> > > The short answer is that Requires without after makes little sense,
> > > since you can't reliably know if your dependency is here without it
> > > (if it fails at startup, you might or might not be started, depending
> > > on the startup order systemd chooses)
> >
> > There are cases where it makes sense.  For example, most OpenStack
> > services require both a message bus and a database, but they are smart
> > enough to wait and re-attempt their connections if either of those
> > services isn't immediately available.
> 
> What's the benefit of not having After= for those services?

  I guess they can start and do their initialization in parallel with
the service they require.

-- 
Tomasz   .. oo o.   oo o. .o   .o o. o. oo o.   ..
Torcz.. .o .o   .o .o oo   oo .o .. .. oo   oo
o.o.o.   .o .. o.   o. o. o.   o. o. oo .. ..   o.

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


Re: [systemd-devel] Requires and After

2019-01-01 Thread Olaf van der Spek
On Tue, Jan 1, 2019 at 8:17 PM Ian Pilcher  wrote:
>
> On 1/1/19 5:44 AM, Jérémy Rosen wrote:
> > The short answer is that Requires without after makes little sense,
> > since you can't reliably know if your dependency is here without it
> > (if it fails at startup, you might or might not be started, depending
> > on the startup order systemd chooses)
>
> There are cases where it makes sense.  For example, most OpenStack
> services require both a message bus and a database, but they are smart
> enough to wait and re-attempt their connections if either of those
> services isn't immediately available.

What's the benefit of not having After= for those services?


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


Re: [systemd-devel] Requires and After

2019-01-01 Thread Ian Pilcher

On 1/1/19 5:44 AM, Jérémy Rosen wrote:

The short answer is that Requires without after makes little sense,
since you can't reliably know if your dependency is here without it
(if it fails at startup, you might or might not be started, depending
on the startup order systemd chooses)


There are cases where it makes sense.  For example, most OpenStack
services require both a message bus and a database, but they are smart
enough to wait and re-attempt their connections if either of those
services isn't immediately available.

--

Ian Pilcher arequip...@gmail.com
 "I grew up before Mark Zuckerberg invented friendship" 


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


[systemd-devel] .service and .socket

2019-01-01 Thread Olaf van der Spek
Hi,

AFAIK socket units require a separate file, which seems more complex
then it has to be.

1. Could sockets be specified directly in the .service file?
2. If not, could the .service file gain a default / implicit
dependency on the .socket file?

3. AFAIK Install.WantedBy doesn't have a default. Could it get a proper default?


xhp.service:
[Unit]
Requires=xhp.socket

[Install]
WantedBy=default.target

xhp.socket:
[Socket]
ListenStream=/run/xhp.socket


Greetings,

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


Re: [systemd-devel] Requires and After

2019-01-01 Thread Reindl Harald


Am 01.01.19 um 12:44 schrieb Jérémy Rosen:
> The short answer is that Requires without after makes little sense,
> since you can't reliably know if your dependency is here without it
> (if it fails at startup, you might or might not be started, depending
> on the startup order systemd chooses)
> 
> however, for backward compatibility reasons, those two will most
> likely stay separate.
> 
> I think a bigger warning in the docs that those two should usually
> be used together would be welcomed.

why?

if it makes little sense than act useful and just make the After
implicit when Requires is in use, it won't harm any "backward
compatibility reasons" which have the After anyways

> On 30/12/2018 12:05, Olaf van der Spek wrote:
>> Evverx suggested I ask here @ https://github.com/systemd/systemd/issues/11284
>> It's about Requires and After. I think a unit in Requires should imply
>> that unit in After too, otherwise the requirement isn't really met.
>> Is there a use case for Requires but not After?
>> If not, would it make sense to change semantics to have Requires imply After?
>>
>> Requires and After are a common source of confusion:
>> https://serverfault.com/questions/812584/in-systemd-whats-the-difference-between-after-and-requires
>> https://unix.stackexchange.com/questions/388586/systemd-requires-vs-wants
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Requires and After

2019-01-01 Thread Olaf van der Spek
On Tue, Jan 1, 2019 at 12:44 PM Jérémy Rosen  wrote:
>
> The short answer is that Requires without after makes little sense,
> since you can't reliably know if your dependency is here without it
> (if it fails at startup, you might or might not be started, depending
> on the startup order systemd chooses)

According to the docs that one doesn't depend on ordering. See how
complicated this is? ;)

>  If one of the other units fails to activate, and an ordering dependency 
> After= on the failing unit is set, this unit will not be started.

> however, for backward compatibility reasons, those two will most
> likely stay separate.
>
> I think a bigger warning in the docs that those two should usually
> be used together would be welcomed.

IMO docs are not a solution, especially long-term.

Greetings,

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


Re: [systemd-devel] Requires and After

2019-01-01 Thread Jérémy Rosen

The short answer is that Requires without after makes little sense,
since you can't reliably know if your dependency is here without it
(if it fails at startup, you might or might not be started, depending
on the startup order systemd chooses)

however, for backward compatibility reasons, those two will most
likely stay separate.

I think a bigger warning in the docs that those two should usually
be used together would be welcomed.

Cheers
Jeremy

On 30/12/2018 12:05, Olaf van der Spek wrote:

Hi,

Evverx suggested I ask here @ https://github.com/systemd/systemd/issues/11284
It's about Requires and After. I think a unit in Requires should imply
that unit in After too, otherwise the requirement isn't really met.
Is there a use case for Requires but not After?
If not, would it make sense to change semantics to have Requires imply After?

Requires and After are a common source of confusion:
https://serverfault.com/questions/812584/in-systemd-whats-the-difference-between-after-and-requires
https://unix.stackexchange.com/questions/388586/systemd-requires-vs-wants



--
SMILE 

20 rue des Jardins
92600 Asnières-sur-Seine


*Jérémy ROSEN*
Architecte technique
Responsable de l'expertise Smile-ECS

email jeremy.ro...@smile.fr 
phone +33141402967
url http://www.smile.eu

Twitter  Facebook 
 LinkedIn 
 Github 




Découvrez l’univers Smile, rendez-vous sur smile.eu 



eco Pour la planète, n'imprimez ce mail que si c'est nécessaire
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel