Leaks snaps in r-a-a mode

Bug #2033268 reported by Michael Vogt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
In Progress
High
Zeyad Gouda

Bug Description

It looks like snapd is leaking snaps when refresh-app-awareness is in use. This got reported in the forum in https://forum.snapcraft.io/t/snaps-autoclean-disable-cache-seeds-for-juju-ci-cd/36363 and indeed on my systems there are many more snaps for firefox than the default retain value of 2:

```
$ ls /var/lib/snapd/snaps/firefox*
/var/lib/snapd/snaps/firefox_2387.snap /var/lib/snapd/snaps/firefox_2531.snap
/var/lib/snapd/snaps/firefox_2391.snap /var/lib/snapd/snaps/firefox_2559.snap
/var/lib/snapd/snaps/firefox_2393.snap /var/lib/snapd/snaps/firefox_2937.snap
/var/lib/snapd/snaps/firefox_2417.snap
```

I looked at the code and it seems the issue is the following:

1. When the refresh starts the soft check that firefox is running reports it is not (this can happen e.g. on startup of the computer when snapd checks for auto-refreshes and the user has not clicked on "firefox" yet)
2. user clicks on firefox, it is now running while the snap is downloading
3. the code path in handlers.go:doPreDownloadSnap() or handlers.go:doUnlinkCurrentSnap() are hit, here firefox is now busy and asyncRefreshOnSnapClose() is called
4. however if firefox is not closed and asyncRefreshOnSnapClose() / continueRefreshOnSnapClose() is aborted it seems no cleanup of the download is happening

One extra complication of this bug is that we will have to write cleanup code that checks the state and clear any unexpected snaps in /var/lib/snapd/snaps that are not either part of a pre-download or in the system.

Michael Vogt (mvo)
description: updated
Changed in snapd:
status: New → Triaged
importance: Undecided → High
Zeyad Gouda (zeyadgouda)
Changed in snapd:
assignee: nobody → Zeyad Gouda (zeyadgouda)
status: Triaged → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.