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

Bug #1821818 reported by Guang Yee on 2019-03-26
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-cinderclient
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) on 2019-03-27
Changed in python-cinderclient:
importance: Undecided → High
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)

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

Changed in python-cinderclient:
status: Confirmed → In Progress

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
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers