Every hook execution check_refresh_available is called, starting snapd

Bug #1919246 reported by Xav Paice
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snap Layer
Fix Released
Undecided
Unassigned

Bug Description

The bootstrap of the snap layer calls `hookenv.atstart(check_refresh_available)` at the start of every hook execution, including update-status. This runs `snap refresh --list` (even if there's no snaps installed), and that causes at the least some noise in syslog, and a start of snapd plus whatever the refresh actually checks for.

This is likely not necessary for every hook execution - maybe better on config-changed only. It's expensive when there's a lot of LXD containers on a machine all running this same process every 5 mins. The operation looks to be taking approx. 5s each on my small test environment, a busy site may be more.

Related branches

Revision history for this message
Stuart Bishop (stub) wrote :

We need to use hookenv.atstart() to get flags set before the main reactive loop kicks off. However, I see no reason the refresh has to run every update-status hook; it is setting the snap.refresh-available.* flags, but they can just as easily be several hours out of date as they can be 5 minutes out of date. I suspect these flags are just a bad idea and not being used.

We do want to do an unconditional refresh in the upgrade-charm hook, in case channels etc. defined in layer.yaml have changed.

I'm thinking the way forward is a layer.yaml option, enable_refresh_flags, defaulting to False, which simply causes check_refresh_available to do nothing. While backwards incompatible, it is a simple enough tweak by the charm author to turn back on if they are actually using the feature.

Stuart Bishop (stub)
Changed in layer-snap:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.