Showing the size of a custom block volume

It seems odd that neither “incus storage volume show” nor “incus storage volume info” shows the size of a custom block volume (in incus 6.0.2 with zfs storage pool)

$ incus storage volume create zfs testblk --type=block
Storage volume testblk created
$ incus storage volume show zfs testblk
config: {}
description: ""
name: testblk
type: custom
used_by: []
location: none
content_type: block
project: nsrc-builder
created_at: 2024-09-30T10:12:46.832973731Z
$ incus storage volume info zfs testblk
Name: testblk
Type: custom
Content type: block
Usage: 12.00KiB
Created: 2024/09/30 10:12 UTC

To find its size, I looked at the raw zvol properties:

# zfs get all zfs0/lxd/custom/nsrc-builder_testblk
NAME                                  PROPERTY              VALUE                  SOURCE
...
zfs0/lxd/custom/nsrc-builder_testblk  volsize               10G                    local

Am I missing some other option within incus?

EDIT: I also get blank output from this command:

$ incus storage volume get zfs testblk size
$

Although one of the examples given by incus storage volume get --help shows:

Description:
  Get values for storage volume configuration keys
...

Examples:
  incus storage volume get default data size
      Returns the size of a custom volume "data" in pool "default"

Interestingly, after growing the volume I can see the size:

$ incus storage volume set zfs testblk size=11GiB
$ incus storage volume get zfs testblk size
11GiB

$ sudo zfs get volsize zfs0/lxd/custom/nsrc-builder_testblk
NAME                                  PROPERTY  VALUE    SOURCE
zfs0/lxd/custom/nsrc-builder_testblk  volsize   11G      local

I guess that when I was creating a volume with the default size, that the size was not recorded as part of its config? Perhaps it should be?

Default size for all block volumes is 10GiB, that’s why VMs get a 10GiB disk out of the box, similarly with no size config set.

I understand that if you create a block volume and don’t specify the size, it gets created as 10GiB. I was surprised that if you ask for information about the volume, it doesn’t say what size it is. It’s saying “I don’t have any size, therefore you have to assume I am whatever the default size is”.

What if the default size changes after the volume is created? (It’s not likely that a future version of incus will change the default volume size, but it’s not impossible either)

I can set a default volume size myself on the pool:

incus storage volume create --type=block zfs vol1
incus storage set zfs volume.size=15GiB
incus storage volume create --type=block zfs vol2
# zfs get volsize zfs0/lxd/custom/nsrc-builder_vol1
NAME                               PROPERTY  VALUE    SOURCE
zfs0/lxd/custom/nsrc-builder_vol1  volsize   10G      local
# zfs get volsize zfs0/lxd/custom/nsrc-builder_vol2
NAME                               PROPERTY  VALUE    SOURCE
zfs0/lxd/custom/nsrc-builder_vol2  volsize   15G      local
$ incus storage volume show zfs vol1
config: {}
description: ""
name: vol1
type: custom
used_by: []
location: none
content_type: block
project: nsrc-builder
created_at: 2024-10-02T07:47:40.208690269Z
$ incus storage volume show zfs vol2
config:
  size: 15GiB
description: ""
name: vol2
type: custom
used_by: []
location: none
content_type: block
project: nsrc-builder
created_at: 2024-10-02T07:48:16.893992996Z

Ah, so the config.size is stored in the volume if it was created with a non-default size. ISTM it would be clearer if the volume size were always stored.

However, now I understand this issue, I can set an explicit default volume size of 10GiB on the pool, and that is propagated to volumes:

incus storage set zfs volume.size=10GiB
incus storage volume create --type=block zfs vol3
$ incus storage volume show zfs vol3
config:
  size: 10GiB
description: ""
name: vol3
type: custom
used_by: []
location: none
content_type: block
project: nsrc-builder
created_at: 2024-10-02T07:53:07.312067572Z