Unable to install core snap in lxd container

I’m in a clean, up-to-date lxd image with squashfuse installed, and I can’t seem to install the core snap.

$ snap --version
snap    2.25
snapd   2.25
series  16
ubuntu  16.04
kernel  4.4.0-83-generic
$ sudo snap install core
error: cannot perform the following tasks:
- Mount snap "core" (2312) (internal error: could not unmarshal state entry "snap-type": invalid snap type: "")
- Setup snap "core" (2312) security profiles (cannot find installed snap "core" at revision 2312)

What I see in the container’s syslog:

Jul 12 22:04:43 test-container /usr/lib/snapd/snapd[24472]: api.go:912: Installing snap "core" revision unset
Jul 12 22:04:43 test-container snapd[24472]: 2017/07/12 22:04:43.614204 api.go:912: Installing snap "core" revision unset
Jul 12 22:04:44 test-container /usr/lib/snapd/snapd[24472]: daemon.go:176: DEBUG: uid=0;@ POST /v2/snaps/core 796.45912ms 202
Jul 12 22:04:44 test-container /usr/lib/snapd/snapd[24472]: taskrunner.go:367: DEBUG: Running task 66 on Do: Download snap "core" (2312) from channel "stable"
Jul 12 22:04:44 test-container /usr/lib/snapd/snapd[24472]: store.go:1261: DEBUG: Available deltas returned by store: []
Jul 12 22:04:55 test-container /usr/lib/snapd/snapd[24472]: taskrunner.go:367: DEBUG: Running task 67 on Do: Fetch and check assertions for snap "core" (2312)
Jul 12 22:04:57 test-container /usr/lib/snapd/snapd[24472]: taskrunner.go:367: DEBUG: Running task 68 on Do: Mount snap "core" (2312)
Jul 12 22:04:57 test-container systemd[1]: Reloading.
Jul 12 22:04:57 test-container systemd[1]: Reloading.
Jul 12 22:04:57 test-container systemd[1]: Mounted Mount unit for core.
Jul 12 22:04:57 test-container /usr/lib/snapd/snapd[24472]: taskrunner.go:367: DEBUG: Running task 69 on Do: Copy snap "core" data
Jul 12 22:04:57 test-container /usr/lib/snapd/snapd[24472]: taskrunner.go:367: DEBUG: Running task 70 on Do: Setup snap "core" (2312) security profiles
Jul 12 22:04:57 test-container /usr/lib/snapd/snapd[24472]: task.go:303: DEBUG: 2017-07-12T22:04:57Z ERROR cannot find installed snap "core" at revision 2312
Jul 12 22:04:57 test-container /usr/lib/snapd/snapd[24472]: taskrunner.go:367: DEBUG: Running task 69 on Undo: Copy snap "core" data
Jul 12 22:04:57 test-container /usr/lib/snapd/snapd[24472]: taskrunner.go:367: DEBUG: Running task 66 on Undo: Download snap "core" (2312) from channel "stable"
Jul 12 22:04:57 test-container /usr/lib/snapd/snapd[24472]: taskrunner.go:367: DEBUG: Running task 68 on Undo: Mount snap "core" (2312)
Jul 12 22:04:57 test-container /usr/lib/snapd/snapd[24472]: task.go:303: DEBUG: 2017-07-12T22:04:57Z ERROR internal error: could not unmarshal state entry "snap-type": invalid snap type: ""
Jul 12 22:04:59 test-container /usr/lib/snapd/snapd[24472]: handlers.go:204: Reported install problem for "core" as 255c06b6-674e-11e7-8c10-fa163e54c21f OOPSID
Jul 12 22:04:59 test-container snapd[24472]: 2017/07/12 22:04:59.233315 handlers.go:204: Reported install problem for "core" as 255c06b6-674e-11e7-8c10-fa163e54c21f OOPSID

I see nothing in the host’s syslog. Any idea what’s happening here?

Interesting… I rebooted and now it installs.

Rebooting is a nice way…

Did you by any chance try this in 14.04? If so rebooting would have switched you to the correct kernel. Still none of this explains the weird error message above (unmarshaling)

I’m afraid not. All xenial.

So I had a look at this and there’s nothing odd on first quick look. My theory would be that something unmounted the core snap (snapd doens’t mount it afterwards) and all hell broke loose later. After reboot it was all fine again.

I did an experiment when I manually unmounted one of the core snap revisions on my system using umount. Surprisingly and sadly there was no trace of this in my system log.

Well, this was during the initial installation of core. Are you saying that something unmounted it right after it was mounted, and before the installation finished?

I don’t know, if this was on the initial installation then perhaps, for whatever reason, the mount unit didn’t actually work and it was not mounted.