Page MenuHomeVyOS Platform

Dependencies between containers
Open, LowPublic

Description

When starting multiple containers there sometimes are dependencies between them. Right now it seems like the all start at once.

For the CLI this could be something like:

set container name $CONTAINER depends $OTHER-CONTAINER

Withing the systemd file the following is needed:

Requires=vyos-container-$OTHER-CONTAINER.service
After=vyos-container-$OTHER-CONTAINER.service

To be complete, maybe some health checking if necessary. Else the containers my start to fast after each other. The health check should be done with the container that is depended on.

set container name $OTHER-CONTAINER health command $in-continer-health-command
set container name $OTHER-CONTAINER health interval $interval
set container name $OTHER-CONTAINER health retries $retries

$command is some command which should be run inside the container
$interval is a time. Could be 5s
$retries is the amount of retries

With systemd it is something like:

HealthCmd="$in-container-health-command"
HealthInterval=$interval
HealthRetries=$retries
Notify=healthy

Details

Version
1.5
Is it a breaking change?
Perfectly compatible
Issue type
Feature (new functionality)

Event Timeline

roedie created this object in space S1 VyOS Public.

I would prefer to have a startorder by default not depending on if the previous ones succeeded or not.

There should also by design be a way to have containers start at the same time (I assume setting to the same dependency includes that)?

For example first start 1x NTP, then start 3x DNS and finally start 2x WEB.

Also what happens when you later delete or disable a container?

Using a number might be a better option and leave the depends for the case of if you dont want to start a specific container until another have successfully started?

Also with a number when a container is deleted or disabled then the start just continues with next startorder number ascending.

In above usecase even if NTP and one of the DNS fails to start I still want to start 2x webserver.

Example:

set container name NTP startorder 1
set container name DNS1 startorder 2
set container name DNS2 startorder 2
set container name DNS3 startorder 2
set container name WEB1 startorder 3
set container name WEB2 startorder 3

and make startdepends optional (as in dont start this one until that one is started):

set container name SYSLOG startorder 9
set container name SYSLOG startdepends DNS2

When/if using numbers for startorder there should be just like with ACL's an reorder step X command.

Such as:

set container startorder reorder step 5

Which with above example would result in:

set container name NTP startorder 5
set container name DNS1 startorder 10
set container name DNS2 startorder 10
set container name DNS3 startorder 10
set container name WEB1 startorder 15
set container name WEB2 startorder 15
set container name SYSLOG startorder 20
set container name SYSLOG startdepends DNS2

For containers with no startorder set they should by default all be started at once as last container(s), equal to startorder 9999 or whatever the upper limit would be.

This also means if none of the containers have a startorder set they will start all at once (as today).

another case for me is one container waiting for system service mdns , if this service is not ready , all containers would failed ,and have to load manually .

could we use systemd way to handle dependency and order ,as all the above are all systemd services .