Snapd in LXD failing to upgrade to 2.31

In a LXD container managed by a snap installed lxd, I see errors trying to unmount an old core snap when upgrading to 2.31.

On my host

host$ snap version
snap    2.31.1+17.10
snapd   2.31.1+17.10
series  16
ubuntu  17.10
kernel  4.13.0-36-generic

host$ snap list lxd
Name  Version  Rev   Developer  Notes
lxd   2.21     5866  canonical  -

I then have an Ubuntu 16.04 LXD container, running snapd 2.30 (since 2.31 is blocked due to this bug):

container$ snap version
snap    2.30
snapd   2.30
series  16
ubuntu  16.04
kernel  4.13.0-36-generic

We can see that an update to core is still in progress, and another snap fails to refresh (which is where I noticed the problem)…

container$ snap changes
ID   Status  Spawn                 Ready                 Summary
72   Doing   2018-02-19T13:38:52Z  -                     Auto-refresh snap "core"
73   Error   2018-02-22T09:43:47Z  2018-02-22T09:44:07Z  Refresh "REDACTED" snap from "edge" channel

container$ snap change 72
Status  Spawn                 Ready                 Summary
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:52Z  Ensure prerequisites for "core" are available
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:56Z  Download snap "core" (3887) from channel "stable"
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:56Z  Fetch and check assertions for snap "core" (3887)
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:56Z  Mount snap "core" (3887)
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:56Z  Run pre-refresh hook of "core" snap if present
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:56Z  Stop snap "core" services
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:56Z  Remove aliases for snap "core"
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:56Z  Make current revision for snap "core" unavailable
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:56Z  Copy snap "core" data
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:57Z  Setup snap "core" (3887) security profiles
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:57Z  Make snap "core" (3887) available to the system
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:58Z  Setup snap "core" (3887) security profiles (phase 2)
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:58Z  Set automatic aliases for snap "core"
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:58Z  Setup snap "core" aliases
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:58Z  Run post-refresh hook of "core" snap if present
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:58Z  Start snap "core" (3887) services
Done    2018-02-19T13:38:52Z  2018-02-19T13:38:58Z  Remove data for snap "core" (3440)
Doing   2018-02-19T13:38:52Z  -                     Remove snap "core" (3440) from the system
Do      2018-02-19T13:38:52Z  -                     Clean up "core" (3887) install
Do      2018-02-19T13:38:52Z  -                     Run configure hook of "core" snap if present

......................................................................
Make snap "core" (3887) available to the system

2018-02-19T13:38:57Z INFO Requested daemon restart.

......................................................................
Remove snap "core" (3440) from the system

2018-02-22T09:30:17Z ERROR cannot remove snap file "core", will retry in 3 mins: umount: /snap/core/3440: not mounted
2018-02-22T09:33:17Z ERROR cannot remove snap file "core", will retry in 3 mins: umount: /snap/core/3440: not mounted
2018-02-22T09:36:17Z ERROR cannot remove snap file "core", will retry in 3 mins: umount: /snap/core/3440: not mounted
2018-02-22T09:39:17Z ERROR cannot remove snap file "core", will retry in 3 mins: umount: /snap/core/3440: not mounted
2018-02-22T09:42:17Z ERROR cannot remove snap file "core", will retry in 3 mins: umount: /snap/core/3440: not mounted
2018-02-22T09:45:17Z ERROR cannot remove snap file "core", will retry in 3 mins: umount: /snap/core/3440: not mounted
2018-02-22T09:48:17Z ERROR cannot remove snap file "core", will retry in 3 mins: [stop snap-core-3440.mount] failed with exit status 1: Job for snap-core-3440.mount failed. See "systemctl status snap-core-3440.mount" and "journalctl -xe" for details.

2018-02-22T09:51:17Z ERROR cannot remove snap file "core", will retry in 3 mins: umount: /snap/core/3440: not mounted
2018-02-22T09:54:17Z ERROR cannot remove snap file "core", will retry in 3 mins: [stop snap-core-3440.mount] failed with exit status 1: Job for snap-core-3440.mount failed. See "systemctl status snap-core-3440.mount" and "journalctl -xe" for details.

2018-02-22T09:57:17Z ERROR cannot remove snap file "core", will retry in 3 mins: umount: /snap/core/3440: not mounted

The journal entry for the mount unit is at https://paste.ubuntu.com/p/fSFnmZFGP9/

I have a similar issue, but starting out on 2.31 already https://pastebin.ubuntu.com/p/Svkx2KZ8jG/

This is an old issue: LXC: snaps don't update . 2.31 was sadly supposed to fix it.

Yes, sorry I continued this on IRC.

The fix for the core snap is to install 2.31 from packages, i.e. https://wiki.ubuntu.com/Testing/EnableProposed and update snapd

Ah, I’m thrilled to hear that, thank you for the update!