TypeError: 'NoneType' object has no attribute '__getitem__' when volume_type is not set

Bug #1821818 reported by Guang Yee
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-cinderclient
Fix Released
High
Eric Harney

Bug Description

When creating a volume using cinder CLI without explicitly specifying --volume-type, the volume_type attribute is set to None if there is also no 'default_volume_type' configured in cinder.conf.

With the introduction of this patch in Rocky, cinder CLI always assumes volume_type is not None.

https://review.openstack.org/#/c/570705/

This appears to be incorrect assumption is volume_type is allowed to be null, according to the API schema. When creating an image from volume, cinder CLI will result in "TypeError: 'NoneType' object has no attribute '__getitem__'"

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cinderclient/shell.py", line 909, in main
    for item in sys.argv[1:]])
  File "/usr/lib/python2.7/site-packages/cinderclient/shell.py", line 729, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.7/site-packages/cinderclient/v3/shell.py", line 923, in do_upload_to_image
    args.disk_format))
  File "/usr/lib/python2.7/site-packages/cinderclient/shell_utils.py", line 32, in print_volume_image
    image[1]['os-volume_upload_image']['volume_type']['name'])
TypeError: 'NoneType' object has no attribute '__getitem__'
ERROR: 'NoneType' object has no attribute '__getitem__'

Eric Harney (eharney)
Changed in python-cinderclient:
importance: Undecided → High
Revision history for this message
Eric Harney (eharney) wrote :

Reproduces with:
1. set default_volume_type=None in cinder.conf
2. $ cinder create 1
3. $ cinder upload-to-image 69d43415-76e9-4a58-8c84-5f04ee633344 myimg
ERROR: 'NoneType' object has no attribute '__getitem__'

Changed in python-cinderclient:
status: New → Confirmed
assignee: nobody → Eric Harney (eharney)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-cinderclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/648157

Changed in python-cinderclient:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-cinderclient (master)

Reviewed: https://review.opendev.org/648157
Committed: https://git.openstack.org/cgit/openstack/python-cinderclient/commit/?id=274fa111696783e846561d12f670967ed01ebcbc
Submitter: Zuul
Branch: master

commit 274fa111696783e846561d12f670967ed01ebcbc
Author: Eric Harney <email address hidden>
Date: Wed Mar 27 11:16:15 2019 -0400

    Fix shell upload-to-image with no volume type

    Upload-to-image would error after launching
    the operation if the volume type is None.

    Closes-Bug: #1821818
    Change-Id: I015e0ddfa98d62f25334e2df5effaee72a3988ab

Changed in python-cinderclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-cinderclient (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/662782

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-cinderclient (stable/stein)

Reviewed: https://review.opendev.org/662782
Committed: https://git.openstack.org/cgit/openstack/python-cinderclient/commit/?id=0a2bab1d4d01df99bc9594f3f055ad99584949aa
Submitter: Zuul
Branch: stable/stein

commit 0a2bab1d4d01df99bc9594f3f055ad99584949aa
Author: Eric Harney <email address hidden>
Date: Wed Mar 27 11:16:15 2019 -0400

    Fix shell upload-to-image with no volume type

    Upload-to-image would error after launching
    the operation if the volume type is None.

    Closes-Bug: #1821818
    Change-Id: I015e0ddfa98d62f25334e2df5effaee72a3988ab
    (cherry picked from commit 274fa111696783e846561d12f670967ed01ebcbc)

tags: added: in-stable-stein
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-cinderclient 4.2.1

This issue was fixed in the openstack/python-cinderclient 4.2.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-cinderclient 4.3.0

This issue was fixed in the openstack/python-cinderclient 4.3.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.