optionally start daemon only if all interfaces are connected
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
snapd |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
I was asked to file this bug on behalf of a user based on IRC discussion (this is rather long but trying to capture the context and considerations for kyrofa or other implementers/
Consider a router snap that has:
apps:
foo:
daemon: simple
plugs: [ network-control, firewall-control ]
On install the resulting systemd unit will try to restart over and over. What would be great is if the developer had a way to say "don't bother starting me unless all my interfaces are connected" (or change the default behavior).
Once interface hooks are implemented, then snap developer could program this with something like:
* meta/hooks/
* meta/hooks/
* command: bin/foo does 'source SNAP_DATA/config ; if [ "$FIREWALL_
However, perhaps it makes sense to express this in the yaml so developers don't have to do that.
A naive implementation would adjust the yaml to be:
apps:
foo:
daemon: simple
plugs: [ network-control, firewall-control ]
restart-
This doesn't work well since restart-condition has many other options that the user may want (eg, 'on-interface-
An alternative might be ('start-
apps:
foo:
daemon: ...
plugs: [ network-control, firewall-control ]
restart-
start-
stop-
With that we change the default behavior to not start unless all the interfaces are connected and to stop when any interfaces are disconnected, but letting the developer choose to opt out. The problem with this default is that the user loses the ability to have a voice on say, removing 'firewall-control' from the snap but still being able to use the snap. However, we could retain the current behavior (ie, user control by default with snap developer opt in) with:
apps:
foo:
daemon: ...
plugs: [ network-control, firewall-control ]
restart-
start-
stop-
I'm sure there are other options but perhaps the above will spark conversation and ideas on how interfaces connections might influence start and stop behavior.
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
summary: |
- need a way to start daemon only if all interfaces are connected + optionally start daemon only if all interfaces are connected |
tags: | added: conjure |
affects: | snappy → snapd |
The current plan is to support this via a "ready" or "wait-for" (name TBD) expression which may AND together a few factors, including whether particular slots and plugs are connected or not.
This might be defined both at a global level, which would prevent the snap from being available at all before the expression is satisfied, and perhaps also at a daemon level, preventing only that particular daemon from going live.
The global expression should be introspected by the system so that the user is told what the given snap is waiting for in a clear way.