Loss of zfs quota setting after container move

When I move a container from host1 to host2 the quota on the root device is not set correctly on host2. Both hosts are identical running Ubuntu 20.04 LTS with lxd 4.0.4 using a zfs storage pool.

I move the container from host1 to host2 with the command:

lxc mv mycontainer host2:

The zfs filesystem used by mycontainer on host2 has no quota set.

$ zfs get quota rpool/lxd/containers/mycontainer
NAME                           PROPERTY  VALUE  SOURCE
rpool/lxd/containers/mycontainer  quota     none   default

I can restore the appropriate quota on host2 by running the following on host2.

REQUIRED_SIZE=`lxc config device get mycontainer root size`
lxc config device set mycontainer root size 500GB
lxc config device set mycontainer root size $REQUIRED_SIZE
$ zfs get quota rpool/lxd/containers/mycontainer
NAME                           PROPERTY  VALUE  SOURCE
rpool/lxd/containers/mycontainer  quota     3.73G   default

So lxd knows what the quota should be, but it is not being set in zfs automatically. You have to set the quota to something different than its current value and then back to the correct value, otherwise the zfs quota does not update to the correct value.

The quota used to transfer correctly when I was using lxd 3.0.3 on Ubuntu 16.04 LTS on the two systems, but stopped working after upgrading. Is there a way to get the quota to automatically be set after moving a container?

Sounds like a bug I’ll take a look. Although there have been some recent changes to quota setting during migration that may have already fixed this.

Have re-created this issue on master branch, investigating now.

I am tracking this issue here: