Bug 2165616

Summary: imageutils: calling str on a QemuImgInfo instance raises AttributeError
Product: Red Hat OpenStack Reporter: Hervé Beraud <hberaud>
Component: python-oslo-utilsAssignee: Hervé Beraud <hberaud>
Status: CLOSED ERRATA QA Contact: dabarzil
Severity: medium Docs Contact:
Priority: high    
Version: 17.1 (Wallaby)CC: apevec, dabarzil, lhh, prgutier
Target Milestone: rcKeywords: Triaged
Target Release: 17.1Flags: hberaud: needinfo-
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-oslo-utils-4.8.2-1.20230201111008.a38b56a.el9ost Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 2165620 (view as bug list) Environment:
Last Closed: 2023-08-16 01:13:42 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:    
Bug Blocks: 2165620    

Description Hervé Beraud 2023-01-30 15:06:43 UTC
Description of problem:

When a QemuImgInfo object contains a format_specific value, calling
str() on it raises "AttributeError: 'list' object has no attribute 'appened'"




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


How reproducible:


Steps to Reproduce:
Python 3.9.14 (main, Oct 4 2022, 17:06:42)
>>> from oslo_utils import imageutils
>>> fake_data = imageutils.QemuImgInfo()
>>> fake_data.type = 'vmdk'
>>> fake_data.format_specific = {'type': 'vmdk', 'data': {}}
>>> fake_data.format_specific['data']['create-type'] = 'monolithicSparse'
>>> str(fake_data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".tox/py39/lib/python3.9/site-packages/oslo_utils/imageutils.py", line 103, in __str__
    lines.appened("format_specific: %s" % self.format_specific)
AttributeError: 'list' object has no attribute 'appened'
>>>

Actual results:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".tox/py39/lib/python3.9/site-packages/oslo_utils/imageutils.py", line 103, in __str__
    lines.appened("format_specific: %s" % self.format_specific)
AttributeError: 'list' object has no attribute 'appened'

Expected results:
No attributeError

Additional info:
A fix exist upstream and should be cherry-picked to OSP17.x https://opendev.org/openstack/oslo.utils/commit/d49d5944824f15d00e04e1b9c7f8c3b03b440c95

Comment 1 Hervé Beraud 2023-02-01 12:34:36 UTC
Fixed in version python-oslo-utils-4.8.2-1.20230201104135.a38b56a.el8osttrunk

https://brewweb.engineering.redhat.com/brew/buildinfo?buildID=2355193

Comment 5 dabarzil 2023-03-07 11:11:06 UTC
Verified:
Python 3.9.16 (main, Dec  8 2022, 00:00:00) 
[GCC 11.3.1 20221121 (Red Hat 11.3.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from oslo_utils import imageutils
>>> fake_data = imageutils.QemuImgInfo()
>>> fake_data.type = 'vmdk'
>>> fake_data.format_specific = {'type': 'vmdk', 'data': {}}
>>> fake_data.format_specific['data']['create-type'] = 'monolithicSparse'
>>> str(fake_data)
"image: None\nfile_format: None\nvirtual_size: None\ndisk_size: None\ncluster_size: None\nbacking_file: None\nformat_specific: {'type': 'vmdk', 'data': {'create-type': 'monolithicSparse'}}"
>>>

Comment 15 errata-xmlrpc 2023-08-16 01:13:42 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.1 (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-2023:4577