Add support for service timers

@mborzecki I think I found unwanted bug in error handling for timer feature.
So I have installed previously snap with timer definition, but this was in time when there was no timer support in edge channel. Now when timer support has landed I wanted to test it again, but I can’t uninstall/refresh this installed snap. Sure I can switch channel or revert back to core snap without timer support so I can uninstall, but error handling should be relaxed enough to allow snap removal as minimum.
I get following error:
error: cannot perform the following tasks:

  • Stop snap “xxxxx” services ([stop snap.xxxxx.xxxxx.timer] failed with exit status 5: Failed to stop snap.xxxxx.xxxxx.timer: Unit snap.xxxxxx.xxxxxx.timer not loaded.
    )

Mh, since all the snapd parts seems to be in place, is it just missing the snapcraft support for this?

Cheers

1 Like

Hello, I am using the timers in the snap I have created to cleanup gce instances. This timer is triggering a service every 15 minutes, where the key here is to passthrough the timer.

This is the snapcraft.yaml which I am using:

name: gce-cleaner
version: 1.0.5
summary: Basic snap used to clean machines on gce
description: Basic snap used to clean machines on gce
confinement: strict
grade: stable

apps:
    runner:
        command: cleaner
        daemon: simple
        plugs: [network]
        passthrough:
            # Run every 15 minutes
            timer: 0:00-24:00/96

parts:
    deps:
        plugin: python
        python-packages: [google-api-python-client, python-dateutil]
        source: .
    copy:
        plugin: dump
        source: .

The code in: https://github.com/sergiocazzolato/gce-cleaner

2 Likes

Can this functionality be documented at The snap format ?

And the “passthrough” app key at the snapcraft.yaml doc: https://docs.snapcraft.io/build-snaps/syntax

1 Like

Note that passthrough is documented here: Snapcraft.yaml reference
and is also on the new staging docs site here: https://discourse-docs.staging.snapcraft.io/t/snapcraft-yaml-reference/4276, which will eventually replace docs.snapcraft.io.

Ping @degville and @mborzecki.

I’ve added it to The snap format a while ago. Timer string format is documented in a separate page.

1 Like