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

LXC import container from CEPH RBD pool #5183

Closed ncpe20012003 closed 6 years ago

ncpe20012003 commented 6 years ago

I have two LXD clusters, each has it's own CEPH storage backend which is the remote LXC storage. On occasion, from cluster1 "$> LXC copy container1 cluster2:container1" fails leaving container1 on the CEPH RBD storage for cluster2, but doesn't add it to the LXC storage and doesn't appear in "Lxc list". On cluster2, if I issue "$>rbd list" I can verify that container_container1 is stored in the pool. How do I pull container1, that resides on the CEPH storage, into Lxc? Lxc import container1?

stgraber commented 6 years ago

Manually mounting it in place and using "lxd import" on it may work.

stgraber commented 6 years ago

@ncpe20012003 did you have a chance to try this?

ncpe20012003 commented 6 years ago

With container image "container_prov" on rbd and mapped to /dev/rbd1, here are the result and I attempt to import:

root@lxd1-a:/dev/rbd/rbd# lxc import container_prov Importing container: 9888301056% (131.47MB/s)Error: Unsupported compression root@lxd1-a:/dev/rbd/rbd#

stgraber commented 6 years ago

@ncpe20012003 I said lxd import, not lxc import (see backup doc for details on difference).

And I also said mounting, not just mapped, so you'd need to map that rbd device to /var/lib/lxd/storage-pools/NAME-OF-POOL/containers/prov or /var/snap/lxd/common/lxd/storage-pools/NAME-OF-POOL/containers/prov (if using snap).

ncpe20012003 commented 6 years ago

Getting the following: root@lxd1-a:/home/choyle# rbd map container_mongo-bak /dev/rbd2 root@lxd1-a:/home/choyle# mkdir /var/snap/lxd/common/lxd/storage-pools/remote/containers/mongo-bak root@lxd1-a:/home/choyle# mount /dev/rbd1 /var/snap/lxd/common/lxd/storage-pools/remote/containers/mongo-bak root@lxd1-a:/home/choyle# cd /var/snap/lxd/common/lxd/storage-pools/remote/containers/mongo-bak root@lxd1-a:/var/snap/lxd/common/lxd/storage-pools/remote/containers/mongo-bak# ls backup.yaml lost+found metadata.yaml rootfs templates root@lxd1-a:/var/snap/lxd/common/lxd/storage-pools/remote/containers/mongo-bak# cd root@lxd1-a:~# lxd import mongo-bak Error: Create container: Add container info to the database: This container already exists

What did I miss?

ncpe20012003 commented 6 years ago

Do I need to delete the backup.yaml file from the container?

stgraber commented 6 years ago

Well, looks like you're trying to import a container which is already present in your LXD database so LXD won't let you do it as that's usually a very bad idea.

If that's expected, you can force it with --force.

ncpe20012003 commented 6 years ago

Nevermind, figured it out. Had to go into the backup.yaml file and update the container name.

ncpe20012003 commented 6 years ago

Imported, but wont' start.

root@lxd1-a:/var/snap/lxd/common/lxd/storage-pools/remote/containers/mongo-bak# lxc start mongo-bak Error: Common start logic: device or resource busy Try lxc info --show-log mongo-bak for more info root@lxd1-a:/var/snap/lxd/common/lxd/storage-pools/remote/containers/mongo-bak# lxc info --show-log mongo-bak Name: mongo-bak Location: lxd1-a.prod Remote: unix:// Architecture: x86_64 Created: 2018/10/24 18:12 UTC Status: Stopped Type: persistent Profiles: default

Log:

ncpe20012003 commented 6 years ago

Is there a template that should be used for the backup.yaml file for a container to be imported?

stgraber commented 6 years ago

You may need to umount it and unmap it now as it being mounted somewhere else would explain the resource busy error.

ncpe20012003 commented 6 years ago

Only had to umount it, was able to start it. Thanks for the timely responses, great support!

stgraber commented 6 years ago

Perfect