Can't delete container (on btrfs): "Cannot remove a volume that has snapshots"

Hi, I’m having trouble removing a specific container:

$ lxc list | grep nodered
| nodered                     | RUNNING | 192.xx.xx.xx (eth0)  | xxxxxxxxxxxxxx (eth0)           | CONTAINER | 19        |
| noderedbak                  | STOPPED |                       |                                              | CONTAINER | 0         |
$ lxc delete noderedbak
Error: Error deleting storage volume: Cannot remove a volume that has snapshots
$ lxc info noderedbak
Name: noderedbak
Location: none
Remote: unix://
Architecture: i686
Created: 2018/11/28 21:12 UTC
Status: Stopped
Type: container
Profiles: default

lxd is at version 4.15, storage is btrfs (and has always been) so I’m not sure what ‘volume’ refers to in the error message.

Can you show lxd sql global "SELECT * FROM storage_volumes"?

Thanks for the quick response. Here’s the output you requested. It’s a shortened/redacted version. (Original is huge; I only removed lines that definitely aren’t nodered-related.)

                                                                                                 +------+------------------------------------------------------------------+-----------------+---------+------+-------------+------------+--------------+                                                                                                                                                |  id  |                               name                               | storage_pool_id | node_id | type | description | project_id | content_type |                                                                                                                                                +------+------------------------------------------------------------------+-----------------+---------+------+-------------+------------+--------------+
...                                                                                                                                                 | 108  | noderedbak                                                       | 1               | 1       | 0    |             | 1          | 0            |                                                                                                                                                | 109  | noderedbak/afterupgradeto0.18                                    | 1               | 1       | 0    |             | 1          | 0            |
| 110  | noderedbak/beforeupgradeto0.18                                   | 1               | 1       | 0    |             | 1          | 0            |
| 111  | noderedbak/before-NUT                                            | 1               | 1       | 0    |             | 1          | 0            |
| 125  | noderedbak/before-alpinev3.8-nodered0.19                         | 1               | 1       | 0    |             | 1          | 0            |                                                                                                                                                | 126  | noderedbak/after-alpinev3.8-nodered0.19                          | 1               | 1       | 0    |             | 1          | 0            |                                                                                                                                                ...
| 470  | 06448968297acf4a1bfd100026b84ae50c19412da9750f0694d2fa30f6e25cb3 | 1               | 1       | 1    |             | 1          | 0            |                                                                                                                                                | 471  | 06448968297acf4a1bfd100026b84ae50c19412da9750f0694d2fa30f6e25cb3 | 4               | 1       | 1    |             | 1          | 0            |                                                                                                                                                ...
| 3108 | nodered                                                          | 1               | 1       | 0    |             | 1          | 0            |
| 3109 | nodered/alpine3.10-but-before-npm                                | 1               | 1       | 0    |             | 1          | 0            |
| 3137 | grafana                                                          | 1               | 1       | 0    |             | 1          | 0            |
| 3186 | nodered/fixed-timezone                                           | 1               | 1       | 0    |             | 1          | 0            |
| 3186 | nodered/fixed-timezone                                           | 1               | 1       | 0    |             | 1          | 0            |
| 3192 | mosquitto/still-v37                                              | 1               | 1       | 0    |             | 1          | 0            |                                                                                                                                                | 3193 | mosquitto/v310-working-websockets                                | 1               | 1       | 0    |             | 1          | 0            |
| 3195 | nodered/with-basic-knx-working                                   | 1               | 1       | 0    |             | 1          | 0            |
...
| 3462 | nodered/snap6                                                    | 1               | 1       | 0    |             | 1          | 0            |
| 3463 | noderedbak/snap37                                                | 1               | 1       | 0    |             | 1          | 0            |
...
| 3510 | nodered/snap7                                                    | 1               | 1       | 0    |             | 1          | 0            |
| 3511 | noderedbak/snap38                                                | 1               | 1       | 0    |             | 1          | 0            |
...
| 3547 | nodered/snap8                                                    | 1               | 1       | 0    |             | 1          | 0            |
| 3548 | noderedbak/snap39                                                | 1               | 1       | 0    |             | 1          | 0            |
...
| 3582 | nodered/snap9                                                    | 1               | 1       | 0    |             | 1          | 0            |
| 3583 | noderedbak/snap40                                                | 1               | 1       | 0    |             | 1          | 0            |
...
| 3625 | nodered/snap10                                                   | 1               | 1       | 0    |             | 1          | 0            |
| 3626 | noderedbak/snap41                                                | 1               | 1       | 0    |             | 1          | 0            |
| 3627 | proxy80443ipv4/snap46                                            | 1               | 1       | 0    |             | 1          | 0            |
| 3698 | f3af48e2d957baf4d10b471d149e3a84e71b890cf6fb45f9d971fd314e405373 | 1               | 1       | 1    |             | 1          | 0            |
| 3913 | c081ac4d38ad1cc3d94e9d8d5209a884bcb69a65cb59fca9168ae598ffeb6bc5 | 1               | 1       | 1    |             | 1          | 0            |
| 4891 | 091b1efac72f71fb68d16856d176611c8f2db8cf766872d50c9add06fe0ecc17 | 1               | 1       | 1    |             | 1          | 0            |
...
| 6898 | cea91a28441af36f088f3ae8b637499061518ea2d83c7560a2f7f33d74298968 | 1               | 1       | 1    |             | 1          | 0            |
...
| 7006 | 700f048266dfbd64153bba64b0aca3ac104326b8870f143ac88dc394e5bbc42c | 1               | 1       | 1    |             | 1          | 0            |
| 7043 | 02fca1d87c34645378ee119cf879eba2c4bbad6a748a8b30da8a8e1c8561c4e1 | 4               | 1       | 1    |             | 1          | 0            |
+------+------------------------------------------------------------------+-----------------+---------+------+-------------+------------+--------------+

I see that there are still some snapshots listed that are not in the output of lxc info noderedbak.

Also there seem to be some old snapshots on disk:

$ sudo ls -l /mnt/ssdbtrfs/lxd/containers-snapshots/noderedbak/
total 0
drwx--x--x+ 1 root root 78 Nov 28  2018 snap21
drwx--x--x+ 1 root root 78 Nov 28  2018 snap22
drwx--x--x+ 1 root root 78 Nov 28  2018 snap23

I’m not sure how my installation got into that situation, it’s rather stable and except for the large number of containers and snapshots I tend to be conservative with it.

Can you remove those remaining snap directories?

1 Like

That did it! I’m just confused that I had a similar issue recently (Lxc export: "Snapshot ... in storage but not expected" - #3 by Gilles) but with a different error message.
Anway, thanks a lot!