Bug 1956762

Summary: [OSP13][cinder] Issue with volume created from the snapshot of an encrypted volume where cinder backend is ceph
Product: Red Hat OpenStack Reporter: Rohini Diwakar <rdiwakar>
Component: openstack-cinderAssignee: Sofia Enriquez <senrique>
Status: CLOSED ERRATA QA Contact: Tzach Shefi <tshefi>
Severity: high Docs Contact: RHOS Documentation Team <rhos-docs>
Priority: high    
Version: 13.0 (Queens)CC: astillma, astupnik, dmaley, eharney, gcharot, jvisser, pgrist, senrique, slinaber, spower, udesale
Target Milestone: asyncKeywords: Triaged, ZStream
Target Release: 13.0 (Queens)   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: openstack-cinder-12.0.10-25.el7ost Doc Type: If docs needed, set a value
Doc Text:
Usually the source volume would be the same size or smaller than the destination volume and they must share the same volume-type. In particular, when the destination volume is the same size as the source volume, creating an encrypted volume from a snapshot of an encrypted volume truncates the data in the new volume. In order to fix this the RBD workflow would be something like this: A source luks volume would be 1026M, we write some data and create a snap from it. We like to create a new luks volume from a snapshot so the create_volume_from_snapshot() method performs a RBD clone first and then a resize if needed. In addition the _clone() method creates a clone (copy-on-write child) of the parent snapshot. Object size will be identical to that of the parent image unless specified (we don't in cinder) so size will be the same as the parent snapshot. If the desired size of the destination luks volume is 1G the create_volume_from_snapshot() won't perform any resize and will be 1026M as the parent. This solves the bug because we don't force it to resize and because of that we don't truncate the data any more. The second case scenario is when we would like to increase the size of the destination volume. As far as I can tell this won't face the encryption header problem but we still need to calculate the difference size to provide the size that the user is expecting. That's why the fix proposed calculate the new_size based on: size difference = desired size - size of source volume new size = current size + size difference.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-12-15 15:57:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1772531    
Bug Blocks:    

Description Rohini Diwakar 2021-05-04 11:28:23 UTC
Description of problem:
The issue is similar to the upstream bug https://bugs.launchpad.net/cinder/+bug/1852168

Step 1:

[murg@svldev2-cfc-a-mgmt-001 ~]$ cinder create --display-name encrypted-vol-murg-1 --volume-type LUKS-CBS 1
+------------------------------+------------------------------------------------------------------+
| Property                     | Value                                                            |
+------------------------------+------------------------------------------------------------------+
| attachments                  | []                                                               |
| availability_zone            | nova                                                             |
| bootable                     | false                                                            |
| consistencygroup_id          | None                                                             |
| created_at                   | 2021-05-04T04:48:55.000000                                       |
| description                  | None                                                             |
| encrypted                    | True                                                             |
| id                           | 37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb                             |
| metadata                     | {}                                                               |
| multiattach                  | False                                                            |
| name                         | encrypted-vol-murg-1                                             |
| os-vol-tenant-attr:tenant_id | 879af372515f4c7288d4f5818fe962b2                                 |
| replication_status           | None                                                             |
| size                         | 1                                                                |
| snapshot_id                  | None                                                             |
| source_volid                 | None                                                             |
| status                       | creating                                                         |
| updated_at                   | 2021-05-04T04:48:55.000000                                       |
| user_id                      | 3fc690999329c3fd7d9aba6d83c0b0ffd3a16129155a3ef0eeb9dd154ede489d |
| volume_type                  | LUKS-CBS                                                         |
+------------------------------+------------------------------------------------------------------+

Step 2:
[murg@svldev2-cfc-a-mgmt-001 ~]$ nova volume-attach murg-test-vm-1 37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/sdb                             |
| id       | 37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb |
| serverId | 1590bda5-4eac-4f11-89f7-468ec393e405 |
| volumeId | 37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb |
+----------+--------------------------------------+

[murg@svldev2-cfc-a-mgmt-001 ~]$ cinder show 37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb
+------------------------------+------------------------------------------------------------------+
| Property                     | Value                                                            |
+------------------------------+------------------------------------------------------------------+
| attached_servers             | ['1590bda5-4eac-4f11-89f7-468ec393e405']                         |
| attachment_ids               | ['79601c20-fcdd-4d18-8587-f30462ec2943']                         |
| availability_zone            | nova                                                             |
| bootable                     | false                                                            |
| consistencygroup_id          | None                                                             |
| created_at                   | 2021-05-04T04:48:55.000000                                       |
| description                  | None                                                             |
| encrypted                    | True                                                             |
| id                           | 37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb                             |
| metadata                     | attached_mode : rw                                               |
| multiattach                  | False                                                            |
| name                         | encrypted-vol-murg-1                                             |
| os-vol-tenant-attr:tenant_id | 879af372515f4c7288d4f5818fe962b2                                 |
| replication_status           | None                                                             |
| size                         | 1                                                                |
| snapshot_id                  | None                                                             |
| source_volid                 | None                                                             |
| status                       | in-use                                                           |
| updated_at                   | 2021-05-04T04:49:47.000000                                       |
| user_id                      | 3fc690999329c3fd7d9aba6d83c0b0ffd3a16129155a3ef0eeb9dd154ede489d |
| volume_type                  | LUKS-CBS                                                         |
+------------------------------+------------------------------------------------------------------+

Step 3:
Mount the volume,create FS, Mount and copy data.

[root@murg-test-vm-1 cloud-user]# fdisk -l|grep ^Disk|grep /dev
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Disk /dev/sdb: 1 GiB, 1073741824 bytes, 2097152 sectors

[root@murg-test-vm-1 cloud-user]# mkfs.xfs /dev/sdb
meta-data=/dev/sdb               isize=512    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Discarding blocks...Done.

[root@murg-test-vm-1 cloud-user]# mount -t xfs /dev/sdb /mnt
[root@murg-test-vm-1 cloud-user]# df -h /mnt
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb       1014M   40M  975M   4% /mnt

[root@murg-test-vm-1 cloud-user]# cp /var/log/messages /mnt
[root@murg-test-vm-1 cloud-user]# ls /mnt/*
/mnt/messages

Step 4:
Umount the FS and detach the cinder volume from the VM instance
[murg@svldev2-cfc-a-mgmt-001 ~]$ nova volume-detach murg-test-vm-1 37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb
[murg@svldev2-cfc-a-mgmt-001 ~]$ cinder show 37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb
+------------------------------+------------------------------------------------------------------+
| Property                     | Value                                                            |
+------------------------------+------------------------------------------------------------------+
| attached_servers             | []                                                               |
| attachment_ids               | []                                                               |
| availability_zone            | nova                                                             |
| bootable                     | false                                                            |
| consistencygroup_id          | None                                                             |
| created_at                   | 2021-05-04T04:48:55.000000                                       |
| description                  | None                                                             |
| encrypted                    | True                                                             |
| id                           | 37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb                             |
| metadata                     |                                                                  |
| multiattach                  | False                                                            |
| name                         | encrypted-vol-murg-1                                             |
| os-vol-tenant-attr:tenant_id | 879af372515f4c7288d4f5818fe962b2                                 |
| replication_status           | None                                                             |
| size                         | 1                                                                |
| snapshot_id                  | None                                                             |
| source_volid                 | None                                                             |
| status                       | available                                                        |
| updated_at                   | 2021-05-04T04:54:41.000000                                       |
| user_id                      | 3fc690999329c3fd7d9aba6d83c0b0ffd3a16129155a3ef0eeb9dd154ede489d |
| volume_type                  | LUKS-CBS                                                         |
+------------------------------+------------------------------------------------------------------+

Step 5:
Create snapshot from this volume.
[murg@svldev2-cfc-a-mgmt-001 ~]$ cinder snapshot-create --name encrypted-vol-murg-1-snap encrypted-vol-murg-1
+-------------+--------------------------------------+
| Property    | Value                                |
+-------------+--------------------------------------+
| created_at  | 2021-05-04T04:55:38.942664           |
| description | None                                 |
| id          | 9d20be7a-bb48-4e78-be55-8c4e7320ba6d |
| metadata    | {}                                   |
| name        | encrypted-vol-murg-1-snap            |
| size        | 1                                    |
| status      | creating                             |
| updated_at  | None                                 |
| volume_id   | 37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb |
+-------------+--------------------------------------+
[murg@svldev2-cfc-a-mgmt-001 ~]$ cinder snapshot-show 9d20be7a-bb48-4e78-be55-8c4e7320ba6d
+--------------------------------------------+--------------------------------------+
| Property                                   | Value                                |
+--------------------------------------------+--------------------------------------+
| created_at                                 | 2021-05-04T04:55:38.000000           |
| description                                | None                                 |
| id                                         | 9d20be7a-bb48-4e78-be55-8c4e7320ba6d |
| metadata                                   | {}                                   |
| name                                       | encrypted-vol-murg-1-snap            |
| os-extended-snapshot-attributes:progress   | 100%                                 |
| os-extended-snapshot-attributes:project_id | 879af372515f4c7288d4f5818fe962b2     |
| size                                       | 1                                    |
| status                                     | available                            |
| updated_at                                 | 2021-05-04T04:55:41.000000           |
| volume_id                                  | 37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb |
+--------------------------------------------+--------------------------------------+

Step 6:
Create a cinder volume using the snapshot.
[murg@svldev2-cfc-a-mgmt-001 ~]$ openstack volume create --size 1 --snapshot 9d20be7a-bb48-4e78-be55-8c4e7320ba6d encrypted-vol-murg-1-clone
+---------------------+------------------------------------------------------------------+
| Field               | Value                                                            |
+---------------------+------------------------------------------------------------------+
| attachments         | []                                                               |
| availability_zone   | nova                                                             |
| bootable            | false                                                            |
| consistencygroup_id | None                                                             |
| created_at          | 2021-05-04T04:56:42.000000                                       |
| description         | None                                                             |
| encrypted           | True                                                             |
| id                  | bcb95a0a-a0f3-4634-b84c-c02253269c40                             |
| multiattach         | False                                                            |
| name                | encrypted-vol-murg-1-clone                                       |
| properties          |                                                                  |
| replication_status  | None                                                             |
| size                | 1                                                                |
| snapshot_id         | 9d20be7a-bb48-4e78-be55-8c4e7320ba6d                             |
| source_volid        | None                                                             |
| status              | creating                                                         |
| type                | LUKS-CBS                                                         |
| updated_at          | None                                                             |
| user_id             | 3fc690999329c3fd7d9aba6d83c0b0ffd3a16129155a3ef0eeb9dd154ede489d |
+---------------------+------------------------------------------------------------------+

[murg@svldev2-cfc-a-mgmt-001 ~]$ cinder show bcb95a0a-a0f3-4634-b84c-c02253269c40
+------------------------------+------------------------------------------------------------------+
| Property                     | Value                                                            |
+------------------------------+------------------------------------------------------------------+
| attached_servers             | []                                                               |
| attachment_ids               | []                                                               |
| availability_zone            | nova                                                             |
| bootable                     | false                                                            |
| consistencygroup_id          | None                                                             |
| created_at                   | 2021-05-04T04:56:42.000000                                       |
| description                  | None                                                             |
| encrypted                    | True                                                             |
| id                           | bcb95a0a-a0f3-4634-b84c-c02253269c40                             |
| metadata                     |                                                                  |
| multiattach                  | False                                                            |
| name                         | encrypted-vol-murg-1-clone                                       |
| os-vol-tenant-attr:tenant_id | 879af372515f4c7288d4f5818fe962b2                                 |
| replication_status           | None                                                             |
| size                         | 1                                                                |
| snapshot_id                  | 9d20be7a-bb48-4e78-be55-8c4e7320ba6d                             |
| source_volid                 | None                                                             |
| status                       | available                                                        |
| updated_at                   | 2021-05-04T04:56:44.000000                                       |
| user_id                      | 3fc690999329c3fd7d9aba6d83c0b0ffd3a16129155a3ef0eeb9dd154ede489d |
| volume_type                  | LUKS-CBS                                                         |
+------------------------------+------------------------------------------------------------------+

Step 7:
Attach the volume "encrypted-vol-murg-1-clone" to openstack instance and mount.

[murg@svldev2-cfc-a-mgmt-001 ~]$ nova volume-attach murg-test-vm-1 bcb95a0a-a0f3-4634-b84c-c02253269c40
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/sdb                             |
| id       | bcb95a0a-a0f3-4634-b84c-c02253269c40 |
| serverId | 1590bda5-4eac-4f11-89f7-468ec393e405 |
| volumeId | bcb95a0a-a0f3-4634-b84c-c02253269c40 |
+----------+--------------------------------------+

[root@murg-test-vm-1 cloud-user]# fdisk -l|grep ^Disk|grep /dev
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Disk /dev/sdb: 1022 MiB, 1071673344 bytes, 2093112 sectors

Dmesg:
[412440.315332] sd 0:0:0:1: [sdb] Synchronizing SCSI cache
[412440.758658] sd 0:0:0:1: [sdb] Synchronize Cache(10) failed: Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[412440.763957] sd 0:0:0:1: [sdb] Sense Key : Illegal Request [current]
[412440.767631] sd 0:0:0:1: [sdb] Add. Sense: Logical unit not supported
[412650.987667] scsi 0:0:0:1: Direct-Access     QEMU     QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
[412651.000266] sd 0:0:0:1: Attached scsi generic sg1 type 0
[412651.002809] sd 0:0:0:1: Power-on or device reset occurred
[412651.007657] sd 0:0:0:1: [sdb] 2093112 512-byte logical blocks: (1.07 GB/1022 MiB)
[412651.011395] sd 0:0:0:1: [sdb] Write Protect is off
[412651.013654] sd 0:0:0:1: [sdb] Mode Sense: 63 00 00 08
[412651.014653] sd 0:0:0:1: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[412651.028648] sd 0:0:0:1: [sdb] Attached SCSI disk

[root@murg-test-vm-1 cloud-user]#  mount -t xfs /dev/sdb /mnt
mount: /mnt: can't read superblock on /dev/sdb.

we can see there is some size difference of 2 MB on the volume created from the snapshot, the filesystem is not mounting and it is unsuable.

Version-Release number of selected component (if applicable):
RHOSP13

How reproducible:


Steps to Reproduce:
1. Create an encrypted cinder volume.
2. Attach this cinder volume to an instance and create filesystem on this volume, mount the filesystem and add some data.
3. Create a snapshot from this encrypted volume (  encrypted-vol-murg-1  )
4. Create a cinder volume using the snapshot.
5. Attach the volume to an instance.
6. Mount the volume.

Actual results:


Expected results:


Additional info:
$ cat installed-rpms | grep cinder
openstack-cinder-12.0.10-11.el7ost.noarch                   Fri Feb 12 06:44:09 2021
python2-cinderclient-3.5.0-2.el7ost.noarch                  Fri Feb 12 06:43:54 2021
python-cinder-12.0.10-11.el7ost.noarch                      Fri Feb 12 06:44:06 2021

$ cat installed-rpms | grep ceph
ceph-common-12.2.12-124.el7cp.x86_64                        Fri Feb  5 08:32:51 2021
libcephfs2-12.2.12-124.el7cp.x86_64                         Fri Feb  5 08:32:49 2021
python-cephfs-12.2.12-124.el7cp.x86_64                      Fri Feb  5 08:32:49 2021

Comment 1 Rohini Diwakar 2021-05-04 11:57:42 UTC
Hello,

37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb: The source volume
bcb95a0a-a0f3-4634-b84c-c02253269c40: The final volume which is created from snapshot of source volume.  

[root@svl-ceph-110 ~]# rbd info -p cloud-svldev-2-cinder volume-37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb
rbd image 'volume-37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb':
        size 1.00GiB in 257 objects
        order 22 (4MiB objects)
        block_name_prefix: rbd_data.eba40f6b8b4567
        format: 2
        features: layering, exclusive-lock, object-map
        flags:
        create_timestamp: Tue May  4 04:49:01 2021

[root@svl-ceph-110 ~]# rbd info -p cloud-svldev-2-cinder  volume-bcb95a0a-a0f3-4634-b84c-c02253269c40
rbd image 'volume-bcb95a0a-a0f3-4634-b84c-c02253269c40':
        size 1GiB in 256 objects
        order 22 (4MiB objects)
        block_name_prefix: rbd_data.ec05e94113f7ca
        format: 2
        features: layering, exclusive-lock, object-map
        flags:
        create_timestamp: Tue May  4 04:56:43 2021
        parent: cloud-svldev-2-cinder/volume-37bbc0d1-3bfc-4624-a77a-f8fb89db1ccb@snapshot-9d20be7a-bb48-4e78-be55-8c4e7320ba6d
        overlap: 1GiB


After exporting the rbd volumes we can see the difference in their size 

[murg@svldev2-cfc-a-mgmt-001 ~]$ qemu-img info ./source.img
image: ./source.img
file format: luks
virtual size: 1.0G (1073741824 bytes)
disk size: 1.0G
encrypted: yes
Format specific information:
    ivgen alg: plain64
    hash alg: sha256
    cipher alg: aes-256
    uuid: 9f4cbf11-435f-4247-bc05-76090edd9872
    cipher mode: xts
    slots:
        [0]:
            active: true
            iters: 123186
            key offset: 4096
            stripes: 4000
        [1]:
            active: false
            key offset: 262144
        [2]:
            active: false
            key offset: 520192
        [3]:
            active: false
            key offset: 778240
        [4]:
            active: false
            key offset: 1036288
        [5]:
            active: false
            key offset: 1294336
        [6]:
            active: false
            key offset: 1552384
        [7]:
            active: false
            key offset: 1810432
    payload offset: 2068480
    master key iters: 31107

[murg@svldev2-cfc-a-mgmt-001 ~]$ qemu-img info ./final.img
image: ./final.img
file format: luks
virtual size: 1.0G (1071673344 bytes)
disk size: 1.0G
encrypted: yes
Format specific information:
    ivgen alg: plain64
    hash alg: sha256
    cipher alg: aes-256
    uuid: 9f4cbf11-435f-4247-bc05-76090edd9872
    cipher mode: xts
    slots:
        [0]:
            active: true
            iters: 123186
            key offset: 4096
            stripes: 4000
        [1]:
            active: false
            key offset: 262144
        [2]:
            active: false
            key offset: 520192
        [3]:
            active: false
            key offset: 778240
        [4]:
            active: false
            key offset: 1036288
        [5]:
            active: false
            key offset: 1294336
        [6]:
            active: false
            key offset: 1552384
        [7]:
            active: false
            key offset: 1810432
    payload offset: 2068480
    master key iters: 31107

Comment 8 Sofia Enriquez 2021-07-27 20:31:49 UTC
For the sake of completeness I'm adding a summary of the problem and an
explanation of the fix proposed upstream.

Usually the source volume would be the same size or smaller than the
destination volume and they must share the same volume-type.

Current RBD workflow:
A source luks volume would be 1026M, we write some data and create a snap
from it. In order to create a new luks volume from that snapshot the
create_volume_from_snapshot() method performs a RBD clone first and then a
resize.

In particular, the _clone() method creates a clone (copy-on-write child) of
the parent snapshot. The size will be identical to that of the parent unless
specified (we don't in cinder) so size will be the same as the parent
snapshot.

The first scenario is when destination and source volume are the same size.
This fix proposed that create_volume_from_snapshot() won't perform any resize.
In this way the data won't truncate.

The second case scenario is when we would like to increase the size of the
destination volume. As far as I can tell this won't face the encryption header
problem but we still need to calculate the difference size to provide the size
that the user is expecting.

That's why the fix proposed calculate the new_size based on :
size difference = desired size - size of source volume
new size = current size + size difference

Comment 32 Tzach Shefi 2021-10-17 07:41:54 UTC
Verified on:
openstack-cinder-12.0.10-25.el7ost

On a ceph backed deployment, lets follow the reproduce steps:

1. Create an encrypted vol type and a volume.

(overcloud) [stack@undercloud-0 ~]$ cinder type-create LUKS
+--------------------------------------+------+-------------+-----------+
| ID                                   | Name | Description | Is_Public |
+--------------------------------------+------+-------------+-----------+
| 9dc1ea58-97d8-434d-972a-fa2f20bfd3df | LUKS | -           | True      |
+--------------------------------------+------+-------------+-----------+
(overcloud) [stack@undercloud-0 ~]$ cinder encryption-type-create --cipher aes-xts-plain64 --key_size 256   --control_location front-end LUKS nova.volume.encryptors.luks.LuksEncryptor
+--------------------------------------+-------------------------------------------+-----------------+----------+------------------+
| Volume Type ID                       | Provider                                  | Cipher          | Key Size | Control Location |
+--------------------------------------+-------------------------------------------+-----------------+----------+------------------+
| 9dc1ea58-97d8-434d-972a-fa2f20bfd3df | nova.volume.encryptors.luks.LuksEncryptor | aes-xts-plain64 | 256      | front-end        |
+--------------------------------------+-------------------------------------------+-----------------+----------+------------------+
(overcloud) [stack@undercloud-0 ~]$ cinder type-key LUKS set volume_backend_name=tripleo_ceph
(overcloud) [stack@undercloud-0 ~]$ cinder extra-specs-list
+--------------------------------------+---------+-----------------------------------------+
| ID                                   | Name    | extra_specs                             |
+--------------------------------------+---------+-----------------------------------------+
| 84078b67-659c-47fb-9ea0-b5310f259b55 | tripleo | {}                                      |
| 9dc1ea58-97d8-434d-972a-fa2f20bfd3df | LUKS    | {'volume_backend_name': 'tripleo_ceph'} |
+--------------------------------------+---------+-----------------------------------------+

(overcloud) [stack@undercloud-0 ~]$ cinder create 1 --volume-type LUKS --name EncVolA
+--------------------------------+--------------------------------------+
| Property                       | Value                                |
+--------------------------------+--------------------------------------+
| attachments                    | []                                   |
| availability_zone              | nova                                 |
| bootable                       | false                                |
| consistencygroup_id            | None                                 |
| created_at                     | 2021-10-17T06:57:49.000000           |
| description                    | None                                 |
| encrypted                      | True                                 |
| id                             | 8d50602c-e772-401d-a8fb-d1ceef78c260 |
| metadata                       | {}                                   |
| migration_status               | None                                 |
| multiattach                    | False                                |
| name                           | EncVolA                              |
| os-vol-host-attr:host          | hostgroup@tripleo_ceph#tripleo_ceph  |
| os-vol-mig-status-attr:migstat | None                                 |
| os-vol-mig-status-attr:name_id | None                                 |
| os-vol-tenant-attr:tenant_id   | 9e006c53c1434c65b22c5b22c184c560     |
| replication_status             | None                                 |
| size                           | 1                                    |
| snapshot_id                    | None                                 |
| source_volid                   | None                                 |
| status                         | creating                             |
| updated_at                     | 2021-10-17T06:57:49.000000           |
| user_id                        | e5436c0c3b6d4c8d9b8fcf1f82d68559     |
| volume_type                    | LUKS                                 |
+--------------------------------+--------------------------------------+

2. Boot an instance attach said volume, create filesystem on this volume, mount and write data on volume:

(overcloud) [stack@undercloud-0 ~]$ cinder list
nova list
+--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+
| ID                                   | Status    | Name         | Size | Volume Type | Bootable | Attached to                          |
+--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+
| 8d50602c-e772-401d-a8fb-d1ceef78c260 | available | EncVolA      | 1    | LUKS        | false    |                                      |

(overcloud) [stack@undercloud-0 ~]$ nova volume-attach inst1 8d50602c-e772-401d-a8fb-d1ceef78c260
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdb                             |
| id       | 8d50602c-e772-401d-a8fb-d1ceef78c260 |
| serverId | 2454b0b1-ab35-401d-aff7-cb362d3f65f0 |
| volumeId | 8d50602c-e772-401d-a8fb-d1ceef78c260 |
+----------+--------------------------------------+


(overcloud) [stack@undercloud-0 ~]$ ssh cirros.0.219
Warning: Permanently added '10.0.0.219' (ECDSA) to the list of known hosts.
$ sudo -i
# mkfs.ext4 /dev/vd
vda    vda1   vda15  vdb
# mkfs.ext4 /dev/vdb
mke2fs 1.42.12 (29-Aug-2014)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: 82901116-6673-43fa-ba3c-b63c2090263b
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

# mkdir mnt
# mount /dev/vdb mnt/
# echo HelloData > mnt/data.txt
# cat mnt/data.txt 
HelloData


3. Create a snapshot from this encrypted volume:
(overcloud) [stack@undercloud-0 ~]$ cinder snapshot-create EncVolA --force --name snapOfEncVolA
+-------------+--------------------------------------+
| Property    | Value                                |
+-------------+--------------------------------------+
| created_at  | 2021-10-17T07:35:45.644295           |
| description | None                                 |
| id          | 6d54954d-53d6-4d1a-b3e9-4ab58c845688 |
| metadata    | {}                                   |
| name        | snapOfEncVolA                        |
| size        | 1                                    |
| status      | creating                             |
| updated_at  | None                                 |
| volume_id   | 8d50602c-e772-401d-a8fb-d1ceef78c260 |
+-------------+--------------------------------------+
(overcloud) [stack@undercloud-0 ~]$ cinder snapshot-list
+--------------------------------------+--------------------------------------+-----------+---------------+------+
| ID                                   | Volume ID                            | Status    | Name          | Size |
+--------------------------------------+--------------------------------------+-----------+---------------+------+
| 6d54954d-53d6-4d1a-b3e9-4ab58c845688 | 8d50602c-e772-401d-a8fb-d1ceef78c260 | available | snapOfEncVolA | 1    |
+--------------------------------------+--------------------------------------+-----------+---------------+------+


4. Create a cinder volume using the snapshot:
(overcloud) [stack@undercloud-0 ~]$ cinder create 1 --snapshot-id 6d54954d-53d6-4d1a-b3e9-4ab58c845688 --name VolBFromSnapshot
+--------------------------------+--------------------------------------+                                                                                                                                                                    
| Property                       | Value                                |                                                                                                                                                                    
+--------------------------------+--------------------------------------+                                                                                                                                                                    
| attachments                    | []                                   |                                                                                                                                                                    
| availability_zone              | nova                                 |                                                                                                                                                                    
| bootable                       | false                                |                                                                                                                                                                    
| consistencygroup_id            | None                                 |                                                                                                                                                                    
| created_at                     | 2021-10-17T07:38:20.000000           |                                                                                                                                                                    
| description                    | None                                 |                                                                                                                                                                    
| encrypted                      | True                                 |
| id                             | 3f2d5a34-388b-46b4-b5f0-1a007c457d9b |
| metadata                       | {}                                   |
| migration_status               | None                                 |
| multiattach                    | False                                |
| name                           | VolBFromSnapshot                     |
| os-vol-host-attr:host          | hostgroup@tripleo_ceph#tripleo_ceph  |
| os-vol-mig-status-attr:migstat | None                                 |
| os-vol-mig-status-attr:name_id | None                                 |
| os-vol-tenant-attr:tenant_id   | 9e006c53c1434c65b22c5b22c184c560     |
| replication_status             | None                                 |
| size                           | 1                                    |
| snapshot_id                    | 6d54954d-53d6-4d1a-b3e9-4ab58c845688 |
| source_volid                   | None                                 |
| status                         | creating                             |
| updated_at                     | 2021-10-17T07:38:20.000000           |
| user_id                        | e5436c0c3b6d4c8d9b8fcf1f82d68559     |
| volume_type                    | LUKS                                 |
+--------------------------------+--------------------------------------+

(overcloud) [stack@undercloud-0 ~]$ cinder list
+--------------------------------------+-----------+------------------+------+-------------+----------+--------------------------------------+
| ID                                   | Status    | Name             | Size | Volume Type | Bootable | Attached to                          |
+--------------------------------------+-----------+------------------+------+-------------+----------+--------------------------------------+
| 3f2d5a34-388b-46b4-b5f0-1a007c457d9b | available | VolBFromSnapshot | 1    | LUKS        | false    |                                      |
| 8d50602c-e772-401d-a8fb-d1ceef78c260 | in-use    | EncVolA          | 1    | LUKS        | false    | 2454b0b1-ab35-401d-aff7-cb362d3f65f0 |
+--------------------------------------+-----------+------------------+------+-------------+----------+--------------------------------------+


5. Attach the volume to an instance:
(overcloud) [stack@undercloud-0 ~]$ nova volume-attach inst1 3f2d5a34-388b-46b4-b5f0-1a007c457d9b
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdc                             |
| id       | 3f2d5a34-388b-46b4-b5f0-1a007c457d9b |
| serverId | 2454b0b1-ab35-401d-aff7-cb362d3f65f0 |
| volumeId | 3f2d5a34-388b-46b4-b5f0-1a007c457d9b |
+----------+--------------------------------------+

6. Mount the volume:
# lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda     253:0    0    1G  0 disk 
|-vda1  253:1    0 1015M  0 part /
`-vda15 253:15   0    8M  0 part 
vdb     253:16   0    1G  0 disk /root/mnt
vdc     253:32   0    1G  0 disk 
# mkdir mnt2
# mount /dev/vdc mnt2/
# cat mnt2/data.txt 
HelloData


Good to verify, a second mounted volume created from the first volume's snapshot is mountable, data is present.

Comment 34 errata-xmlrpc 2021-12-15 15:57:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Red Hat OpenStack Platform 13 bug fix and enhancement advisory), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:5156