Creating multiple servers with a shared volume
Lee Yarwood
lyarwood at redhat.com
Tue Sep 28 13:39:18 UTC 2021
On 28-09-21 18:17:14, open infra wrote:
> On Mon, Sep 27, 2021 at 2:15 PM Lee Yarwood <lyarwood at redhat.com> wrote:
>
> > On 25-09-21 13:11:19, open infra wrote:
> > > On Sat, Sep 25, 2021 at 7:37 AM Laurent Dumont <laurentfdumont at gmail.com
> > >
> > > wrote:
> > >
> > > > Just to be sure, the flow is.
> > > >
> > > > - Create VM with root disk on a volume/image.
> > > > - Create another 1TB volume.
> > > > - Attach the volume to the VM as a second drive using a multi attach
> > > > approach (
> > > >
> > https://docs.openstack.org/cinder/latest/admin/blockstorage-volume-multiattach.html
> > > > )?
> > > > - Create snapshot of the original VM (with it's root drive + 1 TB
> > > > volume)?
> > > > - Create new VM from snapshot.
> > > > - Instead of a new VM + 1 new root volume + the same 1TB multiattach
> > > > volume attached, you get a new multiattach volume (new volume ID and
> > > > everything)?
> >
> > Because you're attaching a snapshot and not the original volume? See
> > below for more.
> >
> > > Yes, here is the block device mapping of the snapshot (from a VM with
> > 100GB
> > > of root disk and 1TB of multiattach volume)
> > >
> > > block_device_mapping[{"image_id": null, "delete_on_termination": true,
> > > "device_name": "/dev/vda", "disk_bus": "virtio", "volume_id": null,
> > > "volume_type": null, "destination_type": "volume", "source_type":
> > > "snapshot", "guest_format": null, "volume_size": 100, "device_type":
> > > "disk", "snapshot_id": "7b2c7f3a-8420-4a33-820e-2d2231d930c7",
> > > "boot_index": 0, "no_device": null, "tag": null}, {"image_id": null,
> > > "delete_on_termination": false, "device_name": "/dev/vdb", "disk_bus":
> > > null, "volume_id": null, "volume_type": null, "destination_type":
> > "volume",
> > > "source_type": "snapshot", "guest_format": null, "volume_size": 1000,
> > > "device_type": null, "snapshot_id":
> > "c2a0695f-8c9e-46f9-80a8-560c47521eeb",
> > > "boot_index": null, "no_device": null, "tag": null}]
> >
> > As you can see above you're using source_type = "snapshot" and
> > destination_type of "volume". As set out in the following docs this
> > creates a new volume from a given snapshot and attaches that to the
> > instance:
> >
> >
> > https://docs.openstack.org/nova/latest/user/block-device-mapping.html#valid-source-destination-combinations
> >
> > snapshot -> volume - this works exactly as passing type=snap does. It
> > would create a volume from a Cinder volume snapshot and attach that
> > volume to the instance. Can be marked bootable.
> >
> >
> > https://docs.openstack.org/api-ref/compute/?expanded=create-server-detail#create-server
> >
> > block_device_mapping_v2.source_type (Optional)
> >
> > The source type of the block device. Valid values are:
> > [..]
> > snapshot: This is only valid with destination_type=volume; creates a
> > volume backed by the given volume snapshot referenced via the
> > block_device_mapping_v2.uuid parameter and attaches it to the server
> >
> > When attaching multiattach enabled volumes to multiple instances you
> > need to use source_type = 'volume' *and* destination_type = 'volume'.
> >
> > Hope this helps,
> >
>
>
> It very clears what went wrong.
> The above block device mapping was found when I try to figure out what went
> wrong.
> But I am not sure where exactly I should define block device mapping when I
> use CLI.
> Appreciate if you can give an example.
>
> Thanks a lot Lee Yarwood!
Okay so given an existing multiattach volume of
02a27e61-b242-460e-8cf6-8525c5353698 I can create two instances with it
attached as a secondary disks as follows:
$ openstack volume show -c multiattach -f json 02a27e61-b242-460e-8cf6-8525c5353698
{
"multiattach": true
}
$ openstack --os-compute-api-version 2.latest server create \
--image cirros-0.5.2-x86_64-disk \
--flavor 1 \
--block-device source_type=volume,destination_type=volume,uuid=02a27e61-b242-460e-8cf6-8525c5353698 \
--network private test-1
$ openstack --os-compute-api-version 2.latest server create \
--image cirros-0.5.2-x86_64-disk \
--flavor 1 \
--block-device source_type=volume,destination_type=volume,uuid=02a27e61-b242-460e-8cf6-8525c5353698 \
--network private test-2
You should be able to see both attachments listed against the volume:
$ openstack volume show 02a27e61-b242-460e-8cf6-8525c5353698 -c attachments -f json
{
"attachments": [
{
"id": "02a27e61-b242-460e-8cf6-8525c5353698",
"attachment_id": "2f3a515a-3ef4-499e-a48a-04c6cd45a05a",
"volume_id": "02a27e61-b242-460e-8cf6-8525c5353698",
"server_id": "74adb548-f3ed-4d68-b282-b278dd1ec3f2",
"host_name": "localhost.localdomain",
"device": "/dev/vdb",
"attached_at": "2021-09-28T13:31:31.000000"
},
{
"id": "02a27e61-b242-460e-8cf6-8525c5353698",
"attachment_id": "5f0cdd6e-4586-4e9d-ad70-dfcf2a093c03",
"volume_id": "02a27e61-b242-460e-8cf6-8525c5353698",
"server_id": "2fdc931e-781a-4430-86af-4debe92c885a",
"host_name": "localhost.localdomain",
"device": "/dev/vdb",
"attached_at": "2021-09-28T13:31:45.000000"
}
]
}
Hope this helps,
--
Lee Yarwood A5D1 9385 88CB 7E5F BE64 6618 BCA6 6E33 F672 2D76
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.openstack.org/pipermail/openstack-discuss/attachments/20210928/4402eaa6/attachment-0001.sig>
More information about the openstack-discuss
mailing list