Every hook execution check_refresh_available is called, starting snapd
Bug #1919246 reported by
Xav Paice
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.
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
~xavpaice/layer-snap:bug/1919246
- Stuart Bishop: Approve
- Cory Johns (community): Approve
-
Diff: 17 lines (+1/-1)1 file modifiedreactive/snap.py (+1/-1)
Changed in layer-snap: | |
status: | New → Fix Released |
To post a comment you must log in.
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.