Refreshing a snap package when not using the default home directory does not transfer save data between revisions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
snapd |
Confirmed
|
High
|
Ghadi Rahme |
Bug Description
[Description]
When the home directory is not /home, snaps who refresh will fail to copy the data from one revision to another. For example lets say the home directory is in /home/canonical. The snap home data directory for user1 would be in /home/canonical
It is important to note that this issue occurs even when running "sudo snap set system homedirs=
[Steps to Reproduce]
Thank you to @fabio.martins for setting up a test snap as well as providing the instructions.
1. Create a new user with a different home directory (I this example I will use user user1 and the home directory will be /home/canonical)
2. Run the following command: $ sudo snap set system homedirs=
3. Install the test snap using the command: $ sudo snap install fabiomirmartestsnap --beta
4. Run the snap with the command: $ fabiomirmartest
5. Inside /home/canonical
6. Print the content of the output.txt file: $ cat /home/canonical
It should display the line "Test 1 complete"
7. Now refresh the snap to a new revision: $ sudo snap refresh fabiomirmartestsnap --channel edge
8. Run the snap again: $ fabiomirmartest
9. Now you should also have a folder named "3" representing the newly installed revision.
10. Print the content of output.txt: $ cat /home/canonical
It will show "Test 2 complete" and not contain the original line "Test 1 complete"
By printing the output.txt file inside "1" we can see that it still contains the original line "Test 1 complete" but when doing the same inside "3" we only have the newly written line "Test 2 complete"
[Expected Behavior]
The expected behavior would be to have output.txt inside "3" have the following content:
Test 1 complete
Test 2 complete
Instead we have:
Test 2 complete
[Solution]
I have written a patch to fix the issue using the latest master branch of snapd, however it seems there is an issue with the master branch at the moment of writing this since it refuses to run any snap application (even without my modification). I have back-ported my changes to the 2.59.5 branch and can confirm that I was successful in resolving the issue. My patch still needs some work to adapt some of the golang test scripts but I will open a PR when it is ready.
This issue is currently affecting AWS, they reported not only this issue but a similar one as well where the snap application data is not deleted when removing the snap using the same setup. My patch fixes both issues.
Changed in snapd: | |
assignee: | nobody → Ghadi Rahme (ghadi-rahme) |
description: | updated |
description: | updated |
Upstream PR: https:/ /github. com/snapcore/ snapd/pull/ 13145