Reviewed: https://review.openstack.org/415898 Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=eda54b1ed73b0c102f4352e1522e34908dc7c17f Submitter: Jenkins Branch: master
commit eda54b1ed73b0c102f4352e1522e34908dc7c17f Author: Matt Riedemann <[email protected]> Date: Fri Dec 30 12:27:48 2016 -0500 Handle unicode when dealing with duplicate flavors during online migrations In python 2.7 you can't cast unicode to str and you'll get a UnicodeEncodeError if you try. Since our exception messages are translated, they can contain unicode and if we hit a duplicate flavor exception while performing online flavor migrations it will break the migration and block any further migrations until resolved - which would require manual intervention. This patch fixes the bug so that we use six.text_type instead of str for logging the duplicate exception and adds a test to exhibit the bug and prove it's fixed. On a side note, it's curious that we don't delete the duplicate flavor from the main database during the online data migration, but it's also strange that you'd have duplicates in the API database because the Flavor.create() checks to see if all flavors have been migrated from the main DB to the API DB and if not you can't create new flavors in the API DB - so the only way to get the duplicates is either by inserting them into the API DB manually or perhaps some other kind of race issue. Anyway, that's not dealt with here. Change-Id: I3bdb1a8ca72c3e72ddc3bc5102cff8df18148617 Partial-Bug: #1653261 ** Changed in: nova Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/1653261 Title: nova-manage db online_data_migrations can fail with UnicodeEncodeError if there are duplicate aggregates or flavors Status in OpenStack Compute (nova): Fix Released Status in OpenStack Compute (nova) newton series: Confirmed Bug description: This was found purely through code inspection, but the online data migration to move aggregates to the nova API database has a problem here: https://github.com/openstack/nova/blob/a74d3ae4e815e3727961ef67bd801dada0267a0b/nova/objects/aggregate.py#L596 The problem is the AggregateNameExists exception message is translatable and could be in unicode characters, and when casting that to str() in python 2.7 it results in a UnicodeEncodeError: Python 2.7.6 (default, Jun 22 2015, 18:00:18) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> msg = u'\xF0\x9F\x92\xA9' >>> msg u'\xf0\x9f\x92\xa9' >>> str(msg) Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128) To manage notifications about this bug go to: https://bugs.launchpad.net/nova/+bug/1653261/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

