Musn't refresh core concurrently with other snaps when reexec is supported

I found an interesting bug this morning:

zyga@t470:~$ sudo snap refresh
[sudo] hasło użytkownika zyga: 
2018-04-03T08:57:20+02:00 INFO Waiting for restart...
error: cannot perform the following tasks:
- Run configure hook of "lxd" snap if present (run hook "configure": error: cannot communicate with server: Post http://localhost/v2/snapctl: dial unix /run/snapd-snap.socket: connect: no such file or directory)

What just happened is that snapd refreshed from 2.32.1 to 2.32.2 and restarted, during that window LXD snap refreshed concurrently and failed to chat with snapd using snapctl.

I think we should make core (or anything that carries snapd in the future, in general) refresh first, completely, before attempting refreshes on remaining snaps. In general this makes is robust against this issue and should also ensure assumes: snapdXY tags can be safely used without confusing error messages.


refresh first is not very clear, we can have different changes running at the same time, of which only one touches core, what we need to avoid is trying to run hooks while core is inactive