Bug 1689706

Summary: openstack client does not allow to resize a volume attached to a instance, while cinder client allows it
Product: Red Hat OpenStack Reporter: Takashi Kajinami <tkajinam>
Component: python-openstackclientAssignee: Alan Bishop <abishop>
Status: CLOSED ERRATA QA Contact: Tzach Shefi <tshefi>
Severity: medium Docs Contact:
Priority: high    
Version: 13.0 (Queens)CC: abishop, apevec, erpeters, gcharot, ifrangs, jpichon, lhh, lyarwood, mariel, nlevinki, spower
Target Milestone: betaKeywords: FutureFeature, Triaged
Target Release: 17.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-openstackclient-5.5.1-0.20210904061812.53f1efa.el8ost Doc Type: Enhancement
Doc Text:
This enhancement includes OpenStack CLI (OSC) support for Block Storage service (cinder) API 3.42. This allows OSC to extend an online volume.
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-09-21 12:07:43 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: 1184786    
Bug Blocks:    

Description Takashi Kajinami 2019-03-18 00:33:29 UTC
Description of problem:

Hot-resize of the attached volume is implemented in recent OpenStack.

nova support to enable extension of an attached volume (nova)
 https://blueprints.launchpad.net/nova/+spec/nova-support-attached-volume-extend

Allow the extend of a cinder volume while it is attached to a VM.  (cinder)
 https://blueprints.launchpad.net/cinder/+spec/extend-attached-volume

RHOSP13, which is created based on Queens release, includes this feature,
but OpenStack client does not allow this operation, by rejecting the request
at client level.
I tried to specify volume api version used, but it does not work. 
~~~
$ openstack volume set --size 20 testvolume
Failed to set volume size: Volume is in in-use state, it must be available before size can be extended
~~~

On the other hand, cinder client allows to resize the attached volume,
by specifying api version.

$ cinder --os-volume-api-version 3.42 extend testvolume 20


How reproducible:
Always

Steps to Reproduce:
1. Create a new volume
2. Attach the volume to a nova instance
3. Run the "openstack volume set" command

Actual results:

openstack command shows error, and does not perform resize operation

Expected results:

openstack command allows resize operation, and sends request to volume api

Additional info:

Comment 2 Alan Bishop 2019-03-19 20:40:29 UTC
The upstream community has struggled with the functionality gap between the "cinder" and "openstack volume" commands. Unfortunately, one big problem is "openstack volume" currently does not support API microversions, and an effort to add support seems stalled [1]. I'll target this for OSP-16 with the hope that the situation upstream improves during the Train cycle.

[1] https://review.openstack.org/590807

Comment 3 Gregory Charot 2019-07-10 13:30:50 UTC
This feature is not officially supported, plan is to support it in 16 so approving this bug for 16.

Comment 4 Lee Yarwood 2019-12-05 18:29:20 UTC
Appears this will miss 16.0, can the storage DFG re-target for 16.1/17.0?

Comment 5 Gregory Charot 2019-12-06 10:47:47 UTC
Done thanks for the heads up Lee! We will use the cinder client to start with.

Comment 6 Alan Bishop 2021-04-22 21:14:55 UTC
Looks like someone in the community submitted a patch for this in Wallaby.

Comment 16 Tzach Shefi 2022-05-15 10:26:07 UTC
Verified on:
python-openstackclient-lang-5.5.1-0.20220427021748.53f1efa.el9ost.noarch


On an LVM backed deployment, booted up an instance:
(overcloud) [stack@undercloud-0 ~]$ nova list
+--------------------------------------+-------+--------+------------+-------------+-----------------------------------+
| ID                                   | Name  | Status | Task State | Power State | Networks                          |
+--------------------------------------+-------+--------+------------+-------------+-----------------------------------+
| 6c3e00b4-2c38-44fe-96a9-44881235e125 | inst1 | ACTIVE | -          | Running     | internal=192.168.0.22, 10.0.0.238 |
+--------------------------------------+-------+--------+------------+-------------+-----------------------------------+

Create a Cinder volume:
(overcloud) [stack@undercloud-0 ~]$ cinder create 3 --name volA
+--------------------------------+--------------------------------------+
| Property                       | Value                                |
+--------------------------------+--------------------------------------+
| attachments                    | []                                   |
| availability_zone              | nova                                 |
| bootable                       | false                                |
| consistencygroup_id            | None                                 |
| created_at                     | 2022-05-15T07:01:30.000000           |
| description                    | None                                 |
| encrypted                      | False                                |
| id                             | b37bf456-8da7-446c-b6a1-202c3d477b97 |
| metadata                       | {}                                   |
| migration_status               | None                                 |
| multiattach                    | False                                |
| name                           | volA                                 |
| os-vol-host-attr:host          | None                                 |
| os-vol-mig-status-attr:migstat | None                                 |
| os-vol-mig-status-attr:name_id | None                                 |
| os-vol-tenant-attr:tenant_id   | bf419af7009a41489a85bb52368df800     |
| replication_status             | None                                 |
| size                           | 3                                    |
| snapshot_id                    | None                                 |
| source_volid                   | None                                 |
| status                         | creating                             |
| updated_at                     | None                                 |
| user_id                        | 2837122f17db4eaabe75aaf6993343bb     |
| volume_type                    | tripleo                              |
+--------------------------------+--------------------------------------+

(overcloud) [stack@undercloud-0 ~]$ cinder list
+--------------------------------------+-----------+------+------+-------------+----------+-------------+
| ID                                   | Status    | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+------+------+-------------+----------+-------------+
| b37bf456-8da7-446c-b6a1-202c3d477b97 | available | volA | 3    | tripleo     | false    |             |
+--------------------------------------+-----------+------+------+-------------+----------+-------------+


Attach volume to instance:
(overcloud) [stack@undercloud-0 ~]$ nova volume-attach inst1 b37bf456-8da7-446c-b6a1-202c3d477b97
+-----------------------+--------------------------------------+
| Property              | Value                                |
+-----------------------+--------------------------------------+
| delete_on_termination | False                                |
| device                | /dev/vdb                             |
| id                    | b37bf456-8da7-446c-b6a1-202c3d477b97 |
| serverId              | 6c3e00b4-2c38-44fe-96a9-44881235e125 |
| tag                   | -                                    |
| volumeId              | b37bf456-8da7-446c-b6a1-202c3d477b97 |
+-----------------------+--------------------------------------+

(overcloud) [stack@undercloud-0 ~]$ cinder list
+--------------------------------------+--------+------+------+-------------+----------+--------------------------------------+
| ID                                   | Status | Name | Size | Volume Type | Bootable | Attached to                          |
+--------------------------------------+--------+------+------+-------------+----------+--------------------------------------+
| b37bf456-8da7-446c-b6a1-202c3d477b97 | in-use | volA | 3    | tripleo     | false    | 6c3e00b4-2c38-44fe-96a9-44881235e125 |
+--------------------------------------+--------+------+------+-------------+----------+--------------------------------------+


Inside the instance we confirm the original size of 3G
(overcloud) [stack@undercloud-0 ~]$ ssh cirros.0.238
Warning: Permanently added '10.0.0.238' (ECDSA) to the list of known hosts.
cirros.0.238's password: 
$ 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    3G  0 disk 


Now lets extend the volume:
(overcloud) [stack@undercloud-0 ~]$ openstack --os-volume-api-version 3.42 volume set --size 5 volA
/usr/lib/python3.9/site-packages/ansible/_vendor/__init__.py:42: UserWarning: One or more Python packages bundled by this ansible-core distribution were already loaded (pyparsing). This may result in undefined behavior.
  warnings.warn('One or more Python packages bundled by this ansible-core distribution were already '
(overcloud) [stack@undercloud-0 ~]$ cinder list
+--------------------------------------+--------+------+------+-------------+----------+--------------------------------------+
| ID                                   | Status | Name | Size | Volume Type | Bootable | Attached to                          |
+--------------------------------------+--------+------+------+-------------+----------+--------------------------------------+
| b37bf456-8da7-446c-b6a1-202c3d477b97 | in-use | volA | 5    | tripleo     | false    | 6c3e00b4-2c38-44fe-96a9-44881235e125 |
+--------------------------------------+--------+------+------+-------------+----------+--------------------------------------+

Seems to work OK, despite the warning.
Lets recheck inside the instance volA/vdb bumped to 5G from 3G

cirros.0.238's password: 
$ 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    5G  0 disk

Good to verify.

Comment 24 errata-xmlrpc 2022-09-21 12:07:43 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 (Release of components for Red Hat OpenStack Platform 17.0 (Wallaby)), 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/RHEA-2022:6543