Lxd snap: when snap is updated, old non-snap config files are copied instead of last snap ones

[Tech info]
snap --version
snap 2.37.2
snapd 2.37.2
series 16
ubuntu 18.04
kernel 4.15.0-45-generic

lxd snap version: i think all snap ones, since i have this problem since a long time. Currently 3.10
ubuntu: 16 and 18
fs: btrfs

[Question / problem]
I have posted a question in the snapscraft forum, without success:


The problem:
when snapd installs a new lxd revision, it updates users config files too (~/snap/lxd/{revision}). It should simply copy last revision ones.

Instead, it copy old non-snap version config files : ~/.config/lxc/.

How is that possible?

Hi!

I just tried with remmina (mentioned in the snapcraft forum) but I cannot reproduce.
It is a bit difficult to try with LXD, however I have some custom LXD aliases that are preserved during updates.

Could you please write a full reproducible example?
I tried with remmina. I first installed from the beta channel, made some configuration changes (i.e. added a connection profile), then switched to the newer stable channel. My connection profile was still there.

Please note that when you snap remove a package, its snap configuration at ~/snap/mysnap/… is lost.

FYI, i have also tried theses steps (not completly at first times so my tests was not ok, but at the end of thread, i did them completly (today): and it works: it prove that when we use revert / refresh manually, it works): https://forum.snapcraft.io/t/snapd-do-not-copy-my-lxd-configuration-files-when-refreshing/5046/11

So my thoughts are, since i boot my computer every morning, the “bad” things happens at boot time, when snapd updates automaticaly some snaps.

This requires some extra work to get a 100% reproducible case.

If you are familiar with creating snap packages, you can create such a demo snap package and have it release a new version every, let’s say 10 minutes. This might help in figuring out when you reboot, the ~/snap/mysnap/ config is lost during upgrades.

My ~/snap/lxd/current/.config/lxc/config.yaml has been OK with my aliases for quite a few LXD updates.

i am not familiar with snap creation.

But i have another question: what happens to user’s config files if you do not use your snap for a long time, and remove old revisions frequently, to clean space?

Since user’s config files are created when you launch a snap app command the first time (for example, for lxd it is created when i launch a “lxc list” command the first time after refreshed), if several revisions are installed, but not used, there should be a few revisions config files directories? And then, how snap choose config files to copy from?

example with remmina:
ls -la /snap/remmina/
drwxr-xr-x 11 root root 265 févr. 14 10:03 2648
drwxr-xr-x 11 root root 265 févr. 17 21:29 2660
lrwxrwxrwx 1 root root 4 févr. 18 09:00 current -> 2660

-> only 2 versions
-> i have never used 2648 revision, so user’s config files are not created

in ~/snap/remmina: 1782 1833 1893 2055 2066 2070 2660 common current
there is no 2648
The last conf files are in 2070, which are “good config files”, since i have copied them manually from another revision directory, days before (i do that from the beginning …)

But “current” follows 2660, which are fresh reseted config files …
So what config files have been copied?

I am not sure what algorithm is used as to how snapd managed the user configuration for snap packages.
That part becomes a snap question (i.e. snapcraft.io forum).

I think it would be good to separate the snap-specific questions from the LXD questions, and ask them as snap questions on forum.snapcraft.io.

yes, i just did it.