Attaching sub-path of a volume does not show up in incus storage volume list

Hi all,

First of all, thanks a lot for the OCI support in incus. This is an awesome feature!
I have already started to migrate some of my app containers (previously running in docker) to natively run on incus. So far this worked great.

However, at the same time I made use of the new feature to only attach sub-paths of a volume to a container.

By doing that, I think incus gets somehow confused about the attached volumes:
If only a sub-path of the volume is attached to a container, it seems that the custom volumes are not anymore listed correctly with the “incus storage volume list <pool>” command,
The issue is not only related to OCI containers, it also happens with normal incus containers.

I am running the stable version (incus 6.4) from the the Zabbly repo on a debian 12 host. My storage is backed by btrfs subvolumes.

To reproduce the issue:

$ incus launch images:debian/bookworm deb1
$ incus launch images:debian/bookworm deb2
$ incus storage volume create default demovol
$ incus config device add deb1 demovol disk pool=default source=demovol path=/mnt/demovol
$ incus shell deb1
root@deb1:~# cd /mnt/demovol
root@deb1:/mnt/demovol# mkdir testdir
root@deb1:/mnt/demovol# echo "test" > testdir/testfile
root@deb1:/mnt/demovol# exit
$ incus config device add deb2 demovol disk pool=default source=demovol/testdir path=/mnt/demovolsub

The testfile is now also available at /mnt/demovolsub in the deb2 container. This is what i expected. However, the “incus storage volume list default” command tells me now, that the custom volume “demovol” is only used by ONE single instance.

Should “USED BY” for the volume “demovol” not be 2 in this case?

$ incus storage volume list default

+-----------+------------------------------------------------------------------+-------------+--------------+---------+
|   TYPE    |                               NAME                               | DESCRIPTION | CONTENT-TYPE | USED BY |
+-----------+------------------------------------------------------------------+-------------+--------------+---------+
....
+-----------+------------------------------------------------------------------+-------------+--------------+---------+
| custom    | demovol                                                          |             | filesystem   | 1       |
+-----------+------------------------------------------------------------------+-------------+--------------+---------+
...
...

Other than the confusing output of the list command, the sub-path mount points seem to work as expected. Or did I misunderstand the new sub-path mounting feature?

Thanks for your help,
Patrik

Yeah, the used-by should count sub-directory usage, that’s a bug in how we handle UsedBy.

Could you file a bug about it at Issues · lxc/incus · GitHub ?

Thanks for looking at it.

Additional note: Since the sub-paths are not counted correctly, the corresponding volume can be deleted, while it is still in use by a container.

I created an issue here: Volume sub-paths are not counted by Incus · Issue #1103 · lxc/incus · GitHub
Let me know if you need anything more.

1 Like