Any ideas what’s going on? I checked the build log (I’m using the snapcraft build service for this) but there was no mention of this there. Maybe just a bug?
* restart-condition
Defines when a service should be restarted, using values returned from systemd service exit status.
Can be one of [on-failure|on-success|on-abnormal|on-abort|on-watchdog|always|never].
any restart condition other than “no” is invalid for oneshot daemons"
And from what I can tell this isn’t really the case any more. Funnily, one of the links to the systemd issue deals with setting up a WireGuard tunnel (https://github.com/NixOS/nixpkgs/issues/30459), which is exactly my use case here also.
I suppose it would be good to get this straightened out. In the meantime I guess I’ll just work around with a retry loop in the shell script itself.
Also FWIW I did just manually set Restart=on-failure in my systemd unit file, which led to a bad-setting error (Debian buster). So the snapd behavior does actually appear fairly reasonable.
Yes in order to enable specifying Restart=<anything-other-than-no> for oneshot daemons, we need to effectively check what version of systemd is on the system, and if it’s a new enough one, then allow through the setting, but if not then use Restart=no.