Bug 1749493

Summary: Cinder retype from non-type to new type on NFS deletes the Volume
Product: Red Hat OpenStack Reporter: Alan Bishop <abishop>
Component: openstack-cinderAssignee: Alan Bishop <abishop>
Status: CLOSED ERRATA QA Contact: Tzach Shefi <tshefi>
Severity: medium Docs Contact: Chuck Copello <ccopello>
Priority: medium    
Version: 14.0 (Rocky)CC: abishop, j.beisiegel, rheslop, tshefi
Target Milestone: z4Keywords: Triaged, ZStream
Target Release: 14.0 (Rocky)   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: openstack-cinder-13.0.5-7.el7ost Doc Type: Bug Fix
Doc Text:
Previously, using migrate to retype an NFV volume intended to stay on the same NFS server would result in the deletion the NFS volume. This is due to the volume migration code renaming the destination volume to match the source prior to deleting the volume with that name. With this patch, the volume file is renamed only when the source and destination files reside on different NFS servers.
Story Points: ---
Clone Of: 1749491 Environment:
Last Closed: 2019-11-06 16:49:54 UTC Type: ---
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: 1749491    
Bug Blocks: 1740560, 1752560    

Description Alan Bishop 2019-09-05 18:24:57 UTC
+++ This bug was initially created as a clone of Bug #1749491 +++

+++ This bug was initially created as a clone of Bug #1740560 +++

Description of problem:
Migrating a Volume with a none-type to a volume type on the same Backend (NFS) ends up deleting the Volume.

Version-Release number of selected component (if applicable):
RHOSP 13.0.7
rhosp13/openstack-cinder-volume 13.0-79

How reproducible:
Always

Steps to Reproduce:
1.
openstack volume create --size 5 test-vol01
+---------------------+------------------------------------------------------------------+
| Field               | Value                                                            |
+---------------------+------------------------------------------------------------------+
| attachments         | []                                                               |
| availability_zone   | nova                                                             |
| bootable            | false                                                            |
| consistencygroup_id | None                                                             |
| created_at          | 2019-08-13T08:58:15.000000                                       |
| description         | None                                                             |
| encrypted           | False                                                            |
| id                  | ef237fb0-ea21-4881-8042-efcfbb308e9c                             |
| multiattach         | False                                                            |
| name                | test-vol01                                                       |
| properties          |                                                                  |
| replication_status  | None                                                             |
| size                | 5                                                                |
| snapshot_id         | None                                                             |
| source_volid        | None                                                             |
| status              | creating                                                         |
| type                | None                                                             |
| updated_at          | None                                                             |
| user_id             | 9190b5e4dd5f0e1f577df88b0ca669d6e2ba87a2d41bbf6628a5eaf792968e7a |
+---------------------+------------------------------------------------------------------+

2.
openstack volume type list
+--------------------------------------+--------+-----------+
| ID                                   | Name   | Is Public |
+--------------------------------------+--------+-----------+
| 8645458e-062e-4321-9103-cd656ca0cee6 | Legacy | True      |
+--------------------------------------+--------+-----------+
openstack volume type show Legacy
+--------------------+--------------------------------------+
| Field              | Value                                |
+--------------------+--------------------------------------+
| access_project_ids | None                                 |
| description        | Default Storage                      |
| id                 | 8645458e-062e-4321-9103-cd656ca0cee6 |
| is_public          | True                                 |
| name               | Legacy                               |
| properties         | volume_backend_name='tripleo_nfs'    |
| qos_specs_id       | None                                 |
+--------------------+--------------------------------------+

3.
openstack volume set --type Legacy test-vol01 
cinder-volume.log: ERROR oslo_messaging.rpc.server VolumeMigrationFailed: Volume migration failed: Retype requires migration but is not allowed.

4.
openstack volume set  --retype-policy on-demand --type Legacy test-vol01
openstack volume show test-vol01
+------------------------------+------------------------------------------------------------------+
| Field                        | Value                                                            |
+------------------------------+------------------------------------------------------------------+
| attachments                  | []                                                               |
| availability_zone            | nova                                                             |
| bootable                     | false                                                            |
| consistencygroup_id          | None                                                             |
| created_at                   | 2019-08-13T08:58:15.000000                                       |
| description                  | None                                                             |
| encrypted                    | False                                                            |
| id                           | ef237fb0-ea21-4881-8042-efcfbb308e9c                             |
| multiattach                  | False                                                            |
| name                         | test-vol01                                                       |
| os-vol-tenant-attr:tenant_id | dbe2fb6b113b418da018420b7bc88240                                 |
| properties                   |                                                                  |
| replication_status           | None                                                             |
| size                         | 5                                                                |
| snapshot_id                  | None                                                             |
| source_volid                 | None                                                             |
| status                       | available                                                        |
| type                         | Legacy                                                           |
| updated_at                   | 2019-08-13T09:02:25.000000                                       |
| user_id                      | 9190b5e4dd5f0e1f577df88b0ca669d6e2ba87a2d41bbf6628a5eaf792968e7a |
+------------------------------+------------------------------------------------------------------+

Actual results:
The volume is copied to a new ID but cinder ends up deleted both the copy and the original on the Backend.
It then still shows up in cinder but any usage fails (attaching, snapshots etc)

openstack volume snapshot create --volume test-vol01 test-snap01
+-------------+--------------------------------------+
| Field       | Value                                |
+-------------+--------------------------------------+
| created_at  | 2019-08-13T09:05:16.337204           |
| description | None                                 |
| id          | a63a55bd-396b-4597-ad37-18bf4e00a220 |
| name        | test-snap01                          |
| properties  |                                      |
| size        | 5                                    |
| status      | creating                             |
| updated_at  | None                                 |
| volume_id   | ef237fb0-ea21-4881-8042-efcfbb308e9c |
+-------------+--------------------------------------+

openstack volume snapshot show test-snap01
+--------------------------------------------+--------------------------------------+
| Field                                      | Value                                |
+--------------------------------------------+--------------------------------------+
| created_at                                 | 2019-08-13T09:05:16.000000           |
| description                                | None                                 |
| id                                         | a63a55bd-396b-4597-ad37-18bf4e00a220 |
| name                                       | test-snap01                          |
| os-extended-snapshot-attributes:progress   | 0%                                   |
| os-extended-snapshot-attributes:project_id | dbe2fb6b113b418da018420b7bc88240     |
| properties                                 |                                      |
| size                                       | 5                                    |
| status                                     | error                                |
| updated_at                                 | 2019-08-13T09:05:16.000000           |
| volume_id                                  | ef237fb0-ea21-4881-8042-efcfbb308e9c |
+--------------------------------------------+--------------------------------------+

2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server [req-8065c636-b6fe-4d08-80a4-42413a8fa6ee 9190b5e4dd5f0e1f577df88b0ca669d6e2ba87a2d41bbf6628a5eaf792968e7a dbe2fb6b113[5/24919]
420b7bc88240 - f0cab1f633da4ec99b5d2822c5abced5 f0cab1f633da4ec99b5d2822c5abced5] Exception during message handling: ProcessExecutionError: Unexpected error while running command.
Command: /usr/bin/python2 -m oslo_concurrency.prlimit --as=1073741824 --cpu=8 -- env LC_ALL=C qemu-img info --force-share /var/lib/cinder/mnt/8d3227ac12c6118a2bd2f20902437228/volume-ef237fb0-ea21-4881-8042-efcfbb308e9c
Exit code: 1
Stdout: u''
Stderr: u"qemu-img: Could not open '/var/lib/cinder/mnt/8d3227ac12c6118a2bd2f20902437228/volume-ef237fb0-ea21-4881-8042-efcfbb308e9c': Could not open '/var/lib/cinder/mnt/8d3227ac12c6118
a2bd2f20902437228/volume-ef237fb0-ea21-4881-8042-efcfbb308e9c': No such file or directory\n"
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server Traceback (most recent call last):
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/server.py", line 163, in _process_incoming
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     res = self.dispatcher.dispatch(message)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 220, in dispatch
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     return self._do_dispatch(endpoint, method, ctxt, args)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 190, in _do_dispatch
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     result = func(ctxt, **new_args)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "<string>", line 2, in create_snapshot
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/cinder/objects/cleanable.py", line 207, in wrapper
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     result = f(*args, **kwargs)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/cinder/volume/manager.py", line 1096, in create_snapshot
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     snapshot.save()
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     self.force_reraise()
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     six.reraise(self.type_, self.value, self.tb)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/cinder/volume/manager.py", line 1088, in create_snapshot
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     model_update = self.driver.create_snapshot(snapshot)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "<string>", line 2, in create_snapshot
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/cinder/coordination.py", line 151, in _synchronized
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     return f(*a, **k)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/cinder/volume/drivers/nfs.py", line 566, in create_snapshot
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     return self._create_snapshot(snapshot)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/cinder/volume/drivers/remotefs.py", line 1412, in _create_snapshot
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     new_snap_path)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/cinder/volume/drivers/remotefs.py", line 1246, in _do_create_snapshot
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     snapshot.volume.name)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/cinder/volume/drivers/nfs.py", line 542, in _qemu_img_info
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     run_as_root=True)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/cinder/volume/drivers/remotefs.py", line 764, in _qemu_img_info_base
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     run_as_root=run_as_root)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/cinder/image/image_utils.py", line 111, in qemu_img_info
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     prlimit=QEMU_IMG_LIMITS)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/cinder/utils.py", line 126, in execute
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     return processutils.execute(*cmd, **kwargs)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_concurrency/processutils.py", line 424, in execute
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server     cmd=sanitized_cmd)
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server ProcessExecutionError: Unexpected error while running command.
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server Command: /usr/bin/python2 -m oslo_concurrency.prlimit --as=1073741824 --cpu=8 -- env LC_ALL=C qemu-img info --force-share /var/
lib/cinder/mnt/8d3227ac12c6118a2bd2f20902437228/volume-ef237fb0-ea21-4881-8042-efcfbb308e9c
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server Exit code: 1
2019-08-13 11:05:16.890 60 ERROR oslo_messaging.rpc.server Stdout: u''

Expected results:
cinder retype should either just change the Volume type of the original Volume or keep the copied Volume.

Additional info:

cinder.conf backend:

[tripleo_nfs]
backend_host=hostgroup
volume_backend_name=tripleo_nfs
volume_driver=cinder.volume.drivers.nfs.NfsDriver
nfs_shares_config=/etc/cinder/shares-nfs.conf
nfs_mount_options=
nfs_snapshot_support=True
nas_secure_file_operations=False
nas_secure_file_permissions=False
nfs_sparsed_volumes = True

Comment 3 Tzach Shefi 2019-10-02 05:09:08 UTC
Awaiting newer build, insufficient to verify:
14  -p 2019-09-06.1
openstack-cinder-13.0.5-5.el7ost.noarch < fixed-in

Comment 6 errata-xmlrpc 2019-11-06 16:49:54 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, 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-2019:3749