canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.38k stars 931 forks source link

lxd import fails with "The instance's directory appears to be empty." when that's not the case #6949

Closed AceSlash closed 4 years ago

AceSlash commented 4 years ago

Required information

Issue description

Trying to restore a container from backup fails with lxd import:

root@srv-308:~ # zfs list nvme/lxd/containers/infra-log-elasticsearch-2
NAME                                            USED  AVAIL  REFER  MOUNTPOINT
nvme/lxd/containers/infra-log-elasticsearch-2   335G  1.31T   335G  /var/snap/lxd/common/lxd/storage-pools/default/containers/infra-log-elasticsearch-2
root@srv-308:~ # lxd import infra-log-elasticsearch-2
Error: The instance's directory "/var/snap/lxd/common/lxd/storage-pools/default/containers/infra-log-elasticsearch-2" appears to be empty. Please ensure that the instance's storage volume is mounted
root@srv-308:~ # ll /var/snap/lxd/common/lxd/storage-pools/default/containers/infra-log-elasticsearch-2
total 5.0K
-r--------  1 root    root    8.1K Feb 26 19:05 backup.yaml
-rw-r--r--  1 root    root     529 Dec  4 06:31 metadata.yaml
drwxr-xr-x 21 1000000 1000000   21 Dec  4 06:31 rootfs
drwxr-xr-x  2 root    root       4 Dec  4 06:31 templates
root@srv-308:~ # zfs get all nvme/lxd/containers/infra-log-elasticsearch-2|grep mount
nvme/lxd/containers/infra-log-elasticsearch-2  mounted               yes                                                                                  -
nvme/lxd/containers/infra-log-elasticsearch-2  mountpoint            /var/snap/lxd/common/lxd/storage-pools/default/containers/infra-log-elasticsearch-2  local
nvme/lxd/containers/infra-log-elasticsearch-2  canmount              on
stgraber commented 4 years ago

It's quite correct, the LXD snap is within a mount namespace, if you can see a mount from the host, then things are wrong.

See: https://discuss.linuxcontainers.org/t/lxd-import-not-working/6702