get/set do not work for the core snap

Bug #1780834 reported by Kevin W Monroe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snap Layer
Fix Released
Undecided
Unassigned

Bug Description

The recent commit for configuring the snapd refresh.timer doesn't quite work. It tries to call snap.set to set a core system option, but 'snap.installed.core' isn't set, so we get this warning:

unit-etcd-0: 16:51:04 WARNING unit.etcd/0.juju-log Cannot set core snap config because it is not installed

Consumers would get a similar warning if they try to get a core option:

unit-etcd-0: 16:54:42 WARNING unit.etcd/0.juju-log Cannot get core snap config because it is not installed

I see a couple options to fix this. One is specifically for the snapd_refresh handler; the other more generically sets 'snap.installed.core' any time install() is called. MPs incoming.

Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

@stub, choose your adventure :)

The generic fix that always sets 'snap.installed.core' feels easy, but there may be unintended side effects as it would allow consumers to call disable, enable, and restart (in addition to get/set) on the core snap. That said, it seems to fail safely:

ubuntu@ip-172-31-16-103:~$ sudo snap disable core
error: cannot disable "core": snap "core" cannot be disabled

ubuntu@ip-172-31-16-103:~$ sudo snap enable core
error: cannot enable "core": snap "core" already enabled

ubuntu@ip-172-31-16-103:~$ sudo snap restart core
error: snap "core" has no services

Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

@stub, after further testing, setting 'snap.installed.core' won't help the set_refresh_timer() method. It looks like config-changed can happen early, so the core flag won't be set, and we'll wind up with the same warning from the description:

> Cannot set core snap config because it is not installed

So, I think there are a couple other options. If you think there's value in 'snap.installed.core', we could gate 'config.changed' handlers in layer-snap like this:

@when('snap.installed.core')
@when('config.changed.snapd_refresh')
def change_snapd_refresh():

Or we could set 'snap.installed.core' super early. Or if 'snap.installed.core' is more trouble than it's worth, we could just do the MP that's specific to set_refresh_timer():

https://code.launchpad.net/~kwmonroe/layer-snap/+git/layer-snap/+merge/349203

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

I don't want spam.installed.core being set super early, because that would be a lie; we don't want any snaps installed, including core, until an installation request is made.

I think deferring change_snapd_refresh until the snap.installed.core state is set is fine. And needs to be done in any case, since I expect 'snap set core' to fail if it is called before the core snap is installed, and we need to defer that happening until we know we actually want a snap installed.

Revision history for this message
Stuart Bishop (stub) wrote :
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.