It would be great to see the gate-auto-refresh hook documented along with the other hooks in Supported snap hooks and wherever that page migrated to in the ReadTheDocs.
I have a few questions at the moment:
- Does the
gate-auto-refreshhook run before or after thepre-refreshhook? And if it runs before but setssnapctl refresh --hold, does that prevent thepre-refreshhook from running? - How does
snapctl refresh --holdandsnapctl refresh --proceedcalled from within hooks/scripts interact with settings the user has set withsnap refresh --hold <snapname>? If the user has set a hold, is the snap capable of un-holding itself (I assume that would be bad)? - I’m curious about the output of
snapctl refresh --pending: does it return “inhibited” if there was asnapctl refresh --holdand/orsnap refresh --hold <snapname>? - What happens when
snapctl refresh --proceedis called? Does it immediately trigger a refresh (assuming a previous refresh was held by agate-auto-refreshhook call tosnapctl refresh --hold)? Does thegate-auto-refreshhook get run again, and/or thepre-refreshhook? - If the snap refresh is inhibited by a hold on one of its dependencies, what happens if
snapctl refresh --proceedis called? I assume it still doesn’t proceed until the dependency is un-held?
I think refresh control could be an excellent solution to the problem of creating e.g. database backups before performing a refresh. There’s a timeout in the pre-refresh hook (30s I believe), so if the database backup would take too long, it could be killed and the refresh would fail. I think the gate-auto-refresh hook could be used to avoid this by holding the refresh, triggering a backup service to run separately, then that backup script would run snapctl refresh --proceed when it’s done creating the backup.