Re: [systemd-devel] No error even a Required= service does not exist

2019-11-29 Thread Andrei Borzenkov

25.11.2019 16:19, Mantas Mikulėnas пишет:

On Mon, Nov 25, 2019 at 3:13 PM Jörg Weinhardt  wrote:


Hi,

the behavior of systemd is not quite clear to me:
I have a service which requires another service to be started and running,
so I use a Requires= dependency to the required service.
But if the required service does not exist at all, there is no error
message from systemd.
e.g.

Requires=xyz.service

produces no complaint and starts the service even if there is no
xyz.service
Is this the normal behavior or can I configure systemd to throw an error
in this case?



The docs say you can get this behavior if you also have After=xyz.service.
(Not entirely sure why.)



Because systemd dependencies are about jobs, not about units. "B 
Requires A" does not mean "unit B should not be active without A being 
active". All that it means - "when submitting start job for B also 
submit start job for A and fail start job for B if start job for A 
failed previously". Without After both start jobs are submitted 
concurrently; there is nothing to check when B is being started (as 
start job for A is not complete at this point) so there is no reason to 
fail start job for B.


Which was the reason to invent BindTo in the first place - as poor man 
simulation of what everyone thinks Requires does (while it does not do it).

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

Re: [systemd-devel] No error even a Required= service does not exist

2019-11-25 Thread Zbigniew Jędrzejewski-Szmek
On Mon, Nov 25, 2019 at 06:13:17PM +0200, Uoti Urpala wrote:
> On Mon, 2019-11-25 at 15:19 +0200, Mantas Mikulėnas wrote:
> > > Requires=xyz.service 
> > > 
> > > produces no complaint and starts the service even if there is no 
> > > xyz.service
> > > Is this the normal behavior or can I configure systemd to throw an error 
> > > in this case?
> > 
> > The docs say you can get this behavior if you also have After=xyz.service. 
> > (Not entirely sure why.)
> 
> No when there IS NOT an "After=xyz.service".
> 
> Without "After=", there is no ordering dependency - it just tells that
> anything starting this unit will effectively order the start of the
> other as well. Without ordering, this unit can be the one to start
> first. If the other one fails to actually start later, that doesn't
> make systemd go back to stop this one (note that this is consistent
> with ordering dependencies - if a depended-on service fails later
> during runtime, that does not automatically force a stop of already
> running depending services). I guess this logic extends to failures of
> the "does not exist at all" type where there was never a chance of
> successfully starting the unit.

Sounds like a bug. I'd expect the transaction to fail if the Required
unit cannot be found.

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

Re: [systemd-devel] No error even a Required= service does not exist

2019-11-25 Thread Jörg Weinhardt

> Mantas Mikulėnas  hat am 25. November 2019 um 14:19 
> geschrieben:
> 
> 
> On Mon, Nov 25, 2019 at 3:13 PM Jörg Weinhardt  wrote:
> 
> > Hi,
> >
> > the behavior of systemd is not quite clear to me:
> > I have a service which requires another service to be started and running,
> > so I use a Requires= dependency to the required service.
> > But if the required service does not exist at all, there is no error
> > message from systemd.
> > e.g.
> >
> > Requires=xyz.service
> >
> > produces no complaint and starts the service even if there is no
> > xyz.service
> > Is this the normal behavior or can I configure systemd to throw an error
> > in this case?
> >
> 
> The docs say you can get this behavior if you also have After=xyz.service.
> (Not entirely sure why.)
> 

Thanks for the quick answer. Require= and After= together also accepts a non 
existing xyz.service. But as I read the docs I found the dependency "BindsTo=" 
which together with "After=" does the job.
Not so easy..

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

Re: [systemd-devel] No error even a Required= service does not exist

2019-11-25 Thread Bruce A. Johnson
Joerg,

I'm not anything near an expert, but perhaps you could try "PartOf=..."
in the Unit section for the dependent service. I'll be interested in
hearing others' opinion of this idea. But, really, a missing service
file shouldn't get out the door.

Bruce A. Johnson 
Chantilly, VA

On 25/11/2019 08.07, Jörg Weinhardt wrote:
> Hi,
>
> the behavior of systemd is not quite clear to me:
> I have a service which requires another service to be started and running,
> so I use a Requires= dependency to the required service.
> But if the required service does not exist at all, there is no error message 
> from systemd.
> e.g. 
>
> Requires=xyz.service 
>
> produces no complaint and starts the service even if there is no xyz.service
> Is this the normal behavior or can I configure systemd to throw an error in 
> this case?
>
> If I write
> "Requires=xyz"
>
> there will be a message: Failed to add dependency on xyz, ignoring: Invalid 
> argument
> Does that error mean that "xyz" is not a valid unit name?
>
> Thank you,
> Joerg
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel

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

Re: [systemd-devel] No error even a Required= service does not exist

2019-11-25 Thread Uoti Urpala
On Mon, 2019-11-25 at 13:22 +, mikko.rap...@bmw.de wrote:
> Maybe you need Wants instead of Requires in the service file.

I don't think so. "Wants" is in the opposite direction - it explicitly
does not require the other unit to successfully start. Even with
"After=" specified, it just makes an attempt to start the other unit,
and will then start this unit whether that succeeded or failed.


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

Re: [systemd-devel] No error even a Required= service does not exist

2019-11-25 Thread Uoti Urpala
On Mon, 2019-11-25 at 15:19 +0200, Mantas Mikulėnas wrote:
> > Requires=xyz.service 
> > 
> > produces no complaint and starts the service even if there is no xyz.service
> > Is this the normal behavior or can I configure systemd to throw an error in 
> > this case?
> 
> The docs say you can get this behavior if you also have After=xyz.service. 
> (Not entirely sure why.)

No when there IS NOT an "After=xyz.service".

Without "After=", there is no ordering dependency - it just tells that
anything starting this unit will effectively order the start of the
other as well. Without ordering, this unit can be the one to start
first. If the other one fails to actually start later, that doesn't
make systemd go back to stop this one (note that this is consistent
with ordering dependencies - if a depended-on service fails later
during runtime, that does not automatically force a stop of already
running depending services). I guess this logic extends to failures of
the "does not exist at all" type where there was never a chance of
successfully starting the unit.


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

Re: [systemd-devel] No error even a Required= service does not exist

2019-11-25 Thread Mikko.Rapeli
Hi,

On Mon, Nov 25, 2019 at 02:07:23PM +0100, Jörg Weinhardt wrote:
> Hi,
> 
> the behavior of systemd is not quite clear to me:
> I have a service which requires another service to be started and running,
> so I use a Requires= dependency to the required service.
> But if the required service does not exist at all, there is no error message 
> from systemd.
> e.g. 
> 
> Requires=xyz.service 
> 
> produces no complaint and starts the service even if there is no xyz.service
> Is this the normal behavior or can I configure systemd to throw an error in 
> this case?
> 
> If I write
> "Requires=xyz"
> 
> there will be a message: Failed to add dependency on xyz, ignoring: Invalid 
> argument
> Does that error mean that "xyz" is not a valid unit name?

I guess all these are by design. Maybe you need Wants instead of Requires in 
the service file.
See:

https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Requires=
and
https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Wants=
and possibly even
https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before=

Cheers,

-Mikko

> 
> Thank you,
> Joerg
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] No error even a Required= service does not exist

2019-11-25 Thread Mantas Mikulėnas
On Mon, Nov 25, 2019 at 3:13 PM Jörg Weinhardt  wrote:

> Hi,
>
> the behavior of systemd is not quite clear to me:
> I have a service which requires another service to be started and running,
> so I use a Requires= dependency to the required service.
> But if the required service does not exist at all, there is no error
> message from systemd.
> e.g.
>
> Requires=xyz.service
>
> produces no complaint and starts the service even if there is no
> xyz.service
> Is this the normal behavior or can I configure systemd to throw an error
> in this case?
>

The docs say you can get this behavior if you also have After=xyz.service.
(Not entirely sure why.)


>
> If I write
> "Requires=xyz"
>
> there will be a message: Failed to add dependency on xyz, ignoring:
> Invalid argument
> Does that error mean that "xyz" is not a valid unit name?
>

It's not a valid unit name if it doesn't have a ".type" suffix.

`systemctl start xyz` will just auto-expand it to xyz.service or something
that makes sense for systemctl, but systemd's configuration files do not
accept such shortcuts.

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

[systemd-devel] No error even a Required= service does not exist

2019-11-25 Thread Jörg Weinhardt
Hi,

the behavior of systemd is not quite clear to me:
I have a service which requires another service to be started and running,
so I use a Requires= dependency to the required service.
But if the required service does not exist at all, there is no error message 
from systemd.
e.g. 

Requires=xyz.service 

produces no complaint and starts the service even if there is no xyz.service
Is this the normal behavior or can I configure systemd to throw an error in 
this case?

If I write
"Requires=xyz"

there will be a message: Failed to add dependency on xyz, ignoring: Invalid 
argument
Does that error mean that "xyz" is not a valid unit name?

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