Add support for hooks
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Click Reviewers tools (obsolete) |
Fix Released
|
Undecided
|
Jamie Strandboge | ||
Snapcraft |
Fix Released
|
Wishlist
|
Kyle Fazzari | ||
snapd (Ubuntu) |
Fix Released
|
Wishlist
|
Kyle Fazzari |
Bug Description
There are a number of situations where snapd needs to notify a snap that something has happened. For example, when a snap is upgraded, the snap may need to run some sort of migration on the previous version’s data in order to make it consumable by the new version. This is possible today, but it requires that the snap be smart enough to realize that it’s running on old data, and there’s no way for the snap to inform snapd that the upgrade failed.
A new global section should be added to the `snap.yaml` (alongside `apps`), called "hooks." To continue with the example of an upgrade, such a section would look something like this:
hooks:
upgrade: # Actual name TBD
plugs: [network]
The name of the hook ("upgrade" in this example) directly corresponds to its purpose, and must be one of the yet-to-
Hooks may be written in any language that is available to the snap. They will be called with no parameters-- if hooks need information from snapd it can be obtained via a yet-to-
If the hook returns a non-zero exit code the hook is considered to have failed, and snapd will take remedial action accordingly. The action taken depends on system choices made for the hook being run. Potential actions are retrying, or failure which would cause the whole change to be undone per existing semantics.
Changed in snapd (Ubuntu): | |
importance: | Undecided → Wishlist |
Changed in snapcraft: | |
importance: | Undecided → Wishlist |
Changed in snapd (Ubuntu): | |
assignee: | nobody → Kyle Fazzari (kyrofa) |
status: | New → In Progress |
description: | updated |
Changed in click-reviewers-tools: | |
status: | New → Fix Committed |
assignee: | nobody → Jamie Strandboge (jdstrand) |
Changed in snapcraft: | |
status: | In Progress → Triaged |
Changed in snapcraft: | |
status: | In Progress → Fix Committed |
milestone: | none → next |
Changed in snapcraft: | |
status: | Fix Committed → Fix Released |
Changed in snapd (Ubuntu): | |
status: | Fix Committed → Fix Released |
YAML support: https:/ /github. com/snapcore/ snapd/pull/ 1240