supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* Dependencies in S6
@ 2020-10-21 10:10 Amaresh Kotekal
  2020-10-21 13:17 ` Guillermo
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Amaresh Kotekal @ 2020-10-21 10:10 UTC (permalink / raw)
  To: supervision

[-- Attachment #1: Type: text/plain, Size: 1308 bytes --]

Hi Team,

I have some doubt on dependencies file in S6.

Secnario 1:
1. A & B are one shot services in a s6-rc bundle. Service B is dependent on
A. ( added in dependency file).
2. I think Service B will start after the completion of service A ( A then
B, in serial manner ) is it correct ? or
3. Service B will start immediately after the service A as started (in a
parallel manner) ?

Secnario 2:
1. A is one shot service and B is a long run service. Service B is
dependent on Service A.
2. Service B will start, once th service A as completed (in serial manner)
? or
3. Service B will start immediately after the service A as started (in a
parallel manner) ?

Secnario 3:
1. A is a long run service and B is a one shot service. Service B is
dependent on Service A.
2. Service B will start immediately after the service A as started (in a
parallel manner) ?
3. Do I need to use notification mechanism if I want to start service B
after A service as reached particular point in execution

Secnario 4:
1. A & B both are long run services. Service B is dependent on Service A.
2. Service B will start immediately after the service A as started (in a
parallel manner) ?

If one shot service are dependent on other one shot services. They will be
started in serial manner one after the other ?

Regards,
Amaresh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Dependencies in S6
  2020-10-21 10:10 Dependencies in S6 Amaresh Kotekal
@ 2020-10-21 13:17 ` Guillermo
  2020-10-21 13:23 ` Crest
  2020-10-21 13:26 ` Laurent Bercot
  2 siblings, 0 replies; 5+ messages in thread
From: Guillermo @ 2020-10-21 13:17 UTC (permalink / raw)
  To: Supervision

El mié., 21 oct. 2020 a las 7:10, Amaresh Kotekal escribió:
>
> Secnario 1:
> 1. A & B are one shot services in a s6-rc bundle. Service B is dependent on
> A. ( added in dependency file).
> 2. I think Service B will start after the completion of service A ( A then
> B, in serial manner ) is it correct ? or
> 3. Service B will start immediately after the service A as started (in a
> parallel manner) ?

#2. If A starts successfully, B will be started after A, i.e.
serially. If A fails to start, B won't be started.at all.

> Secnario 2:
> 1. A is one shot service and B is a long run service. Service B is
> dependent on Service A.

Same as scenario #1. Whether B is a longrun or a oneshot does not
change the behaviour.

> Secnario 3:
> 1. A is a long run service and B is a one shot service. Service B is
> dependent on Service A.
> [...]
> 3. Do I need to use notification mechanism if I want to start service B
> after A service as reached particular point in execution

Same as scenario #1, service type does not affect the behaviour. What
does depend on service type is the way s6-rc detects that state
transition has completed, and the way it detects transition failure.
For oneshots, transition completion happens when the oneshot's process
terminates. And transition failure is determined based on the process'
exit code, and, if a timeout was specified with a 'timeout-up' file,
also on whether it terminates before the timeout.

For longruns that support readiness notification, transition
completion happens when the longrun's process notifies readiness. And
if a timeout was specified with a 'timeout-up' file, transition
failure is determined based on whether notification happens before the
timeout.

If there is no support for readiness notification, transition
completion happens when the longrun's process has been spawned by its
corresponding s6-supervise process, because there is no better way. If
the process can be polled for readiness, you can use the
s6-notifyoncheck program to hook to s6-supervise's readiness
notification mechanism.

* http://www.skarnet.org/software/s6/s6-notifyoncheck.html

> Secnario 4:
> 1. A & B both are long run services. Service B is dependent on Service A.

Left as an excercise :)

G.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Dependencies in S6
  2020-10-21 10:10 Dependencies in S6 Amaresh Kotekal
  2020-10-21 13:17 ` Guillermo
@ 2020-10-21 13:23 ` Crest
  2020-10-21 13:26 ` Laurent Bercot
  2 siblings, 0 replies; 5+ messages in thread
From: Crest @ 2020-10-21 13:23 UTC (permalink / raw)
  To: supervision

On 21.10.20 12:10, Amaresh Kotekal wrote:
> Hi Team,
>
> I have some doubt on dependencies file in S6.
>
> Secnario 1:
> 1. A & B are one shot services in a s6-rc bundle. Service B is dependent on
> A. ( added in dependency file).
> 2. I think Service B will start after the completion of service A ( A then
> B, in serial manner ) is it correct ? or
> 3. Service B will start immediately after the service A as started (in a
> parallel manner) ?
>
> Secnario 2:
> 1. A is one shot service and B is a long run service. Service B is
> dependent on Service A.
> 2. Service B will start, once th service A as completed (in serial manner)
> ? or
> 3. Service B will start immediately after the service A as started (in a
> parallel manner) ?
>
> Secnario 3:
> 1. A is a long run service and B is a one shot service. Service B is
> dependent on Service A.
> 2. Service B will start immediately after the service A as started (in a
> parallel manner) ?
> 3. Do I need to use notification mechanism if I want to start service B
> after A service as reached particular point in execution
>
> Secnario 4:
> 1. A & B both are long run services. Service B is dependent on Service A.
> 2. Service B will start immediately after the service A as started (in a
> parallel manner) ?
>
> If one shot service are dependent on other one shot services. They will be
> started in serial manner one after the other ?

The s6-rc service manager is always concurrent while respecting 
dependencies. It starts all services as soon as their requirements are 
satisfied.

Having a single service depend on a single other service is just a 
special case of the more general dependency resolution s6-rc does.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Dependencies in S6
  2020-10-21 10:10 Dependencies in S6 Amaresh Kotekal
  2020-10-21 13:17 ` Guillermo
  2020-10-21 13:23 ` Crest
@ 2020-10-21 13:26 ` Laurent Bercot
  2020-10-21 19:14   ` Steve Litt
  2 siblings, 1 reply; 5+ messages in thread
From: Laurent Bercot @ 2020-10-21 13:26 UTC (permalink / raw)
  To: Amaresh Kotekal, supervision


  Hi Amaresh,

  As long as service B depends on service A, A and B will never start
in parallel; B will always start when A is ready.

  "A is ready" means:
   - if A is a oneshot: when the script has completed
   - if A is a longrun:
     * if there is a notification-fd file in the service definition
directory: when the daemon has notified readiness
     * if there is no such file: as soon as the run script has started
(which is not a good readiness indicator; it is akin to starting B
_right after A_, essentially in parallel, so you may have race
conditions here - which is why you should always use readiness
notifications.)


>Secnario 1:
>1. A & B are one shot services in a s6-rc bundle. Service B is dependent on
>A. ( added in dependency file).
>2. I think Service B will start after the completion of service A ( A then
>B, in serial manner ) is it correct ? or
>3. Service B will start immediately after the service A as started (in a
>parallel manner) ?

  Serial manner, A then B.


>Secnario 2:
>1. A is one shot service and B is a long run service. Service B is
>dependent on Service A.
>2. Service B will start, once th service A as completed (in serial manner)
>? or
>3. Service B will start immediately after the service A as started (in a
>parallel manner) ?

  Serial manner, A then B.


>Secnario 3:
>1. A is a long run service and B is a one shot service. Service B is
>dependent on Service A.
>2. Service B will start immediately after the service A as started (in a
>parallel manner) ?
>3. Do I need to use notification mechanism if I want to start service B
>after A service as reached particular point in execution

  Yes, you need notification; if you don't, then B will start
immediately after A.


>Secnario 4:
>1. A & B both are long run services. Service B is dependent on Service A.
>2. Service B will start immediately after the service A as started (in a
>parallel manner) ?

  Same as above: almost-parallel manner if A does not use notification,
serial manner if it does.


>  If one shot service are dependent on other one shot services. They will be
>started in serial manner one after the other ?

  That is your Scenario 1 above.

  If the case is: "C depends on A and B, but A and B are independent",
then:
  * A and B are started in parallel
  * when both A and B are ready, then C is started.

  Hope this helps,

--
  Laurent


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Dependencies in S6
  2020-10-21 13:26 ` Laurent Bercot
@ 2020-10-21 19:14   ` Steve Litt
  0 siblings, 0 replies; 5+ messages in thread
From: Steve Litt @ 2020-10-21 19:14 UTC (permalink / raw)
  To: supervision

On Wed, 21 Oct 2020 13:26:25 +0000
"Laurent Bercot" <ska-supervision@skarnet.org> wrote:

>   "A is ready" means:
>    - if A is a oneshot: when the script has completed
>    - if A is a longrun:
>      * if there is a notification-fd file in the service definition
> directory: when the daemon has notified readiness
>      * if there is no such file: as soon as the run script has started
> (which is not a good readiness indicator; it is akin to starting B
> _right after A_, essentially in parallel, so you may have race
> conditions here - which is why you should always use readiness
> notifications.)

I seem to remember that s6 also has specially named shellscript to
determine dependency readiness. So, for instance, process B requires a
functioning network, the shellscript would contain a ping command or an
ip command. I do this all the time, informally.
 
SteveT

Steve Litt 
Autumn 2020 featured book: Thriving in Tough Times
http://www.troubleshooters.com/thrive

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-21 19:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21 10:10 Dependencies in S6 Amaresh Kotekal
2020-10-21 13:17 ` Guillermo
2020-10-21 13:23 ` Crest
2020-10-21 13:26 ` Laurent Bercot
2020-10-21 19:14   ` Steve Litt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).