Returned strings should not be forced into unicode

Bug #1763179 reported by Sean McGinnis on 2018-04-11
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Cloud Archive
High
Unassigned
Mitaka
High
Unassigned
Ocata
High
Unassigned
Pike
High
Unassigned
Queens
High
Unassigned
oslo.versionedobjects
High
Sean McGinnis
python-oslo.versionedobjects (Ubuntu)
High
Unassigned
Xenial
High
Unassigned
Artful
High
Unassigned
Bionic
High
Unassigned

Bug Description

[Impact]

In Kilo, with ldap integrated, user_id can have non uuid format ( e.g. Gāo )
Then after upgrading kilo to mitaka ( in trusty env )

Gāo user can't create cinder volume with unicode error.

Affected Xenial, UCA Mitaka ( this is modified after i re-testing all )

Please refer to error code like below [1]

[Test Case]

1. deploy openstack env
2. source novarc ( as admin )
3. keystone user-create --name test
4. openstack user set --password-prompt test
4. log into keystone node and install mysql-client
5. connect to mysql with keystone user
6. do below query
- set foreign_key_checks = 0;
- update local_user set user_id='Gāo' where user_id='UUID';
- update user set id='Gāo' where id='UUID';
- set foreign_key_checks = 1;
7. keystone user-role-add --user test --tenant admin --role Admin
8. source novarc ( as test )
9. cinder create --name test 1

got unicode error on cinder-api node logs

[Regression Potential]
This patch make code handles unicode non uuid form user id. Basically this has little risk. but cinder-api service need to be restarted.

[Others]

[1] ###########

2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault File "/usr/lib/python2.7/dist-packages/taskflow/types/failure.py", line 343, in reraise
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault six.reraise(*self._exc_info)
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault File "/usr/lib/python2.7/dist-packages/taskflow/engines/action_engine/executor.py", line 82, in _execute_task
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault result = task.execute(**arguments)
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault File "/usr/lib/python2.7/dist-packages/cinder/volume/flows/api/create_volume.py", line 527, in execute
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault volume = objects.Volume(context=context, **volume_properties)
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault File "/usr/lib/python2.7/dist-packages/cinder/objects/volume.py", line 180, in __init__
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault super(Volume, self).__init__(*args, **kwargs)
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault File "/usr/lib/python2.7/dist-packages/oslo_versionedobjects/base.py", line 304, in __init__
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault setattr(self, key, kwargs[key])
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault File "/usr/lib/python2.7/dist-packages/oslo_versionedobjects/base.py", line 72, in setter
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault field_value = field.coerce(self, name, value)
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault File "/usr/lib/python2.7/dist-packages/oslo_versionedobjects/fields.py", line 192, in coerce
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault return self._type.coerce(obj, attr, value)
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault File "/usr/lib/python2.7/dist-packages/oslo_versionedobjects/fields.py", line 325, in coerce
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault "for further details" % value, FutureWarning)
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault File "/usr/lib/python2.7/logging/__init__.py", line 1709, in _showwarning
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault s = warnings.formatwarning(message, category, filename, lineno, line)
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault File "/usr/lib/python2.7/warnings.py", line 38, in formatwarning
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault s = "%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message)
2018-03-14 10:58:56.932 2198 ERROR cinder.api.middleware.fault UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 9: ordinal not in range(128)

Original Description
--------------------
Change https://review.openstack.org/#/c/557778/ changed the return value for coerce() to explicitly force the value to be unicode. This causes problems with Python 2 runtimes, where the expected value of a string is no longer a string but now unicode (see: https://github.com/openstack/cinder/blob/b89e73a2ac315927d2eee42129597b14e87ba685/cinder/tests/unit/volume/drivers/dell_emc/vmax/test_vmax.py#L3412)

The correct fix should be to use either six.text_type to convert it, or format it into a string as is being done, but without forcing it to be a unicode string. "%s" will end up being the correct type depending on whether it is running under py2 or py3.

Changed in oslo.versionedobjects:
assignee: nobody → Sean McGinnis (sean-mcginnis)

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

Changed in oslo.versionedobjects:
status: New → In Progress
Ben Nemec (bnemec) on 2018-04-11
Changed in oslo.versionedobjects:
importance: Undecided → High

Reviewed: https://review.openstack.org/560639
Committed: https://git.openstack.org/cgit/openstack/oslo.versionedobjects/commit/?id=b719764ba85d5e689d8276ad40c82985c84f03f9
Submitter: Zuul
Branch: master

commit b719764ba85d5e689d8276ad40c82985c84f03f9
Author: Sean McGinnis <email address hidden>
Date: Wed Apr 11 21:02:53 2018 +0000

    Don't force unicode strings for UUID coercion

    Change Ic6b6308fb1960ec40407e6efde30137b64543e72 attempts to
    fix difference between Python 2 and Python 3 values by switching
    from using str() to formatting into a unicode string (u"%s").

    This is equivalent to changing str() to unicode(), but that is
    not correct for expected default string types for Python 2.
    This requires either using six.text_type(), or just formatting
    into a string, without forcing unicode ("%s"), to be correct on
    either runtime.

    Change-Id: I178f14cdc670d7a696778891e587ef75de208fc2
    Closes-bug: #1763179

Changed in oslo.versionedobjects:
status: In Progress → Fix Released
Changed in python-oslo.versionedobjects (Ubuntu Bionic):
status: New → Triaged
importance: Undecided → High
Changed in python-oslo.versionedobjects (Ubuntu Artful):
status: New → Triaged
Changed in python-oslo.versionedobjects (Ubuntu Xenial):
status: New → Triaged
importance: Undecided → High
Changed in python-oslo.versionedobjects (Ubuntu Artful):
importance: Undecided → High
Corey Bryant (corey.bryant) wrote :

I've uploaded this for bionic (queens), artful (pike), and ocata. Bionic and Artful are awaiting SRU team review.

description: updated

Hello Sean, or anyone else affected,

Accepted python-oslo.versionedobjects into ocata-proposed. The package will build now and be available in the Ubuntu Cloud Archive in a few hours, and then in the -proposed repository.

Please help us by testing this new package. To enable the -proposed repository:

  sudo add-apt-repository cloud-archive:ocata-proposed
  sudo apt-get update

Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-ocata-needed to verification-ocata-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-ocata-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

tags: added: verification-ocata-needed
Sean McGinnis (sean-mcginnis) wrote :

Great - thanks Corey! I will try to check those out.

This issue was fixed in the openstack/oslo.versionedobjects 1.33.1 release.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-oslo.versionedobjects - 1.31.2-0ubuntu3

---------------
python-oslo.versionedobjects (1.31.2-0ubuntu3) bionic; urgency=medium

  * d/p/dont-force-unicode-strings-for-UUID-coercion.patch:
    This reverts and changes the fix provided by
    d/p/Fixing-uuid-coerce-function-for-unicode-non-uuid-form.patch
    (LP: #1763179).

 -- Corey Bryant <email address hidden> Tue, 17 Apr 2018 08:33:51 -0400

Changed in python-oslo.versionedobjects (Ubuntu Bionic):
status: Triaged → Fix Released

Hello Sean, or anyone else affected,

Accepted python-oslo.versionedobjects into queens-proposed. The package will build now and be available in the Ubuntu Cloud Archive in a few hours, and then in the -proposed repository.

Please help us by testing this new package. To enable the -proposed repository:

  sudo add-apt-repository cloud-archive:queens-proposed
  sudo apt-get update

Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-queens-needed to verification-queens-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-queens-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

tags: added: verification-queens-needed

The verification of the Stable Release Update for python-oslo.versionedobjects has completed successfully and the package has now been released to -updates. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Corey Bryant (corey.bryant) wrote :

This bug was fixed in the package python-oslo.versionedobjects - 1.31.2-0ubuntu3~cloud0
---------------

 python-oslo.versionedobjects (1.31.2-0ubuntu3~cloud0) xenial-queens; urgency=medium
 .
   * New update for the Ubuntu Cloud Archive.
 .
 python-oslo.versionedobjects (1.31.2-0ubuntu3) bionic; urgency=medium
 .
   * d/p/dont-force-unicode-strings-for-UUID-coercion.patch:
     This reverts and changes the fix provided by
     d/p/Fixing-uuid-coerce-function-for-unicode-non-uuid-form.patch
     (LP: #1763179).

Reviewed: https://review.openstack.org/561674
Committed: https://git.openstack.org/cgit/openstack/oslo.versionedobjects/commit/?id=b607dad267aff8ce87f956e9f2586b9e44a58f44
Submitter: Zuul
Branch: stable/queens

commit b607dad267aff8ce87f956e9f2586b9e44a58f44
Author: Sean McGinnis <email address hidden>
Date: Wed Apr 11 21:02:53 2018 +0000

    Don't force unicode strings for UUID coercion

    Change Ic6b6308fb1960ec40407e6efde30137b64543e72 attempts to
    fix difference between Python 2 and Python 3 values by switching
    from using str() to formatting into a unicode string (u"%s").

    This is equivalent to changing str() to unicode(), but that is
    not correct for expected default string types for Python 2.
    This requires either using six.text_type(), or just formatting
    into a string, without forcing unicode ("%s"), to be correct on
    either runtime.

    Change-Id: I178f14cdc670d7a696778891e587ef75de208fc2
    Closes-bug: #1763179
    (cherry picked from commit b719764ba85d5e689d8276ad40c82985c84f03f9)

tags: added: in-stable-queens
Seyeong Kim (xtrusia) on 2018-04-26
description: updated

Reviewed: https://review.openstack.org/561928
Committed: https://git.openstack.org/cgit/openstack/oslo.versionedobjects/commit/?id=c4e7defc88a79952c93b151310688f6cf39d3e6d
Submitter: Zuul
Branch: stable/pike

commit c4e7defc88a79952c93b151310688f6cf39d3e6d
Author: Sean McGinnis <email address hidden>
Date: Wed Apr 11 21:02:53 2018 +0000

    Don't force unicode strings for UUID coercion

    Change Ic6b6308fb1960ec40407e6efde30137b64543e72 attempts to
    fix difference between Python 2 and Python 3 values by switching
    from using str() to formatting into a unicode string (u"%s").

    This is equivalent to changing str() to unicode(), but that is
    not correct for expected default string types for Python 2.
    This requires either using six.text_type(), or just formatting
    into a string, without forcing unicode ("%s"), to be correct on
    either runtime.

    Change-Id: I178f14cdc670d7a696778891e587ef75de208fc2
    Closes-bug: #1763179
    (cherry picked from commit b719764ba85d5e689d8276ad40c82985c84f03f9)

Hello Sean, or anyone else affected,

Accepted python-oslo.versionedobjects into artful-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-oslo.versionedobjects/1.26.0-0ubuntu2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-artful to verification-done-artful. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-artful. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in python-oslo.versionedobjects (Ubuntu Artful):
status: Triaged → Fix Committed
tags: added: verification-needed verification-needed-artful
Corey Bryant (corey.bryant) wrote :

Hello Sean, or anyone else affected,

Accepted python-oslo.versionedobjects into pike-proposed. The package will build now and be available in the Ubuntu Cloud Archive in a few hours, and then in the -proposed repository.

Please help us by testing this new package. To enable the -proposed repository:

  sudo add-apt-repository cloud-archive:pike-proposed
  sudo apt-get update

Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-pike-needed to verification-pike-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-pike-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

tags: added: verification-pike-needed

This issue was fixed in the openstack/oslo.versionedobjects 1.31.3 release.

This issue was fixed in the openstack/oslo.versionedobjects 1.26.2 release.

Seyeong Kim (xtrusia) wrote :

for artful

I updated it on #1761629

verified.

tags: added: verification-done-artful
removed: verification-needed-artful
Seyeong Kim (xtrusia) wrote :

for pike

tested the same on #1761629

Thanks

tags: added: verification-pike-done
removed: verification-pike-needed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-oslo.versionedobjects - 1.26.0-0ubuntu2

---------------
python-oslo.versionedobjects (1.26.0-0ubuntu2) artful; urgency=medium

  [ Corey Bryant ]
  * d/p/dont-force-unicode-strings-for-UUID-coercion.patch:
    This reverts and changes the fix provided by
    d/p/Fixing-uuid-coerce-function-for-unicode-non-uuid-form.patch
    (LP: #1763179).

  [ Seyeong Kim ]
  * Fixing UUID coerce function for unicode non uuid form id (LP: #1760918)
    - d/p/Fixing-uuid-coerce-function-for-unicode-non-uuid-form.patch

  [ Corey Bryant ]
  * d/gbp.conf: Create stable/pike branch.

 -- Corey Bryant <email address hidden> Tue, 17 Apr 2018 08:47:39 -0400

Changed in python-oslo.versionedobjects (Ubuntu Artful):
status: Fix Committed → Fix Released
Corey Bryant (corey.bryant) wrote :

Regression testing has passed successfully for ocata-proposed:

======
Totals
======
Ran: 102 tests in 1806.1829 sec.
 - Passed: 94
 - Skipped: 8
 - Expected Fail: 0
 - Unexpected Success: 0
 - Failed: 0
Sum of execute time for each test: 1104.3589 sec.

tags: added: verification-ocata-done
removed: verification-ocata-needed

The verification of the Stable Release Update for python-oslo.versionedobjects has completed successfully and the package has now been released to -updates. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Corey Bryant (corey.bryant) wrote :

This bug was fixed in the package python-oslo.versionedobjects - 1.21.0-0ubuntu1~cloud2
---------------

 python-oslo.versionedobjects (1.21.0-0ubuntu1~cloud2) xenial-ocata; urgency=medium
 .
   * d/p/dont-force-unicode-strings-for-UUID-coercion.patch:
     This reverts and changes the fix provided by
     d/p/Fixing-uuid-coerce-function-for-unicode-non-uuid-form.patch
     (LP: #1763179).

Corey Bryant (corey.bryant) wrote :

The verification of the Stable Release Update for python-oslo.versionedobjects has completed successfully and the package has now been released to -updates. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Corey Bryant (corey.bryant) wrote :

This bug was fixed in the package python-oslo.versionedobjects - 1.26.0-0ubuntu2~cloud0
---------------

 python-oslo.versionedobjects (1.26.0-0ubuntu2~cloud0) xenial-pike; urgency=medium
 .
   * New update for the Ubuntu Cloud Archive.
 .
 python-oslo.versionedobjects (1.26.0-0ubuntu2) artful; urgency=medium
 .
   [ Corey Bryant ]
   * d/p/dont-force-unicode-strings-for-UUID-coercion.patch:
     This reverts and changes the fix provided by
     d/p/Fixing-uuid-coerce-function-for-unicode-non-uuid-form.patch
     (LP: #1763179).
 .
   [ Seyeong Kim ]
   * Fixing UUID coerce function for unicode non uuid form id (LP: #1760918)
     - d/p/Fixing-uuid-coerce-function-for-unicode-non-uuid-form.patch
 .
   [ Corey Bryant ]
   * d/gbp.conf: Create stable/pike branch.

Corey Bryant (corey.bryant) wrote :

I've uploaded a new version of the xenial package to the xenial unapproved queue [1] where it is awaiting review by the Ubuntu SRU team.

[1] https://launchpad.net/ubuntu/xenial/+queue?queue_state=1&queue_text=

Hello Sean, or anyone else affected,

Accepted python-oslo.versionedobjects into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-oslo.versionedobjects/1.8.0-1ubuntu1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in python-oslo.versionedobjects (Ubuntu Xenial):
status: Triaged → Fix Committed
tags: added: verification-needed-xenial
Seyeong Kim (xtrusia) wrote :

hello

I verified this is working for xenial.

before patch, return value of command wa 500,
after patch, it successfully created.

thanks

dpkg -l | grep cinder
ii cinder-api 2:8.1.1-0ubuntu3 all Cinder storage service - API server
ii cinder-common 2:8.1.1-0ubuntu3 all Cinder storage service - common files
ii cinder-scheduler 2:8.1.1-0ubuntu3 all Cinder storage service - Scheduler server
ii cinder-volume 2:8.1.1-0ubuntu3 all Cinder storage service - Volume server
ii python-cinder 2:8.1.1-0ubuntu3 all Cinder Python libraries

tags: added: verification-done-xenial
removed: verification-needed-xenial
Łukasz Zemczak (sil2100) wrote :

Could you please mention which version of python-oslo.versionedobjects was used for verification?

Seyeong Kim (xtrusia) wrote :

Sorry about that sil2100,

I re-verified this. and attaching oslo.versionedobjects version

dpkg -l | grep oslo.versionedobjects
ii python-oslo.versionedobjects 1.8.0-1ubuntu1 all deals with DB schema versions and code expectations - Python 2.x

Corey Bryant (corey.bryant) wrote :

Hello Sean, or anyone else affected,

Accepted python-oslo.versionedobjects into mitaka-proposed. The package will build now and be available in the Ubuntu Cloud Archive in a few hours, and then in the -proposed repository.

Please help us by testing this new package. To enable the -proposed repository:

  sudo add-apt-repository cloud-archive:mitaka-proposed
  sudo apt-get update

Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-mitaka-needed to verification-mitaka-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-mitaka-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

tags: added: verification-mitaka-needed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-oslo.versionedobjects - 1.8.0-1ubuntu1

---------------
python-oslo.versionedobjects (1.8.0-1ubuntu1) xenial; urgency=medium

  * d/p/fixing-UUID-coerce-function-for-unicode-non-uuid-for.patch:
    Cherry-pick upstream patches to enable use of unicode user ID in Python2.7
    (LP: #1763179).

 -- Corey Bryant <email address hidden> Mon, 04 Jun 2018 08:29:48 -0400

Changed in python-oslo.versionedobjects (Ubuntu Xenial):
status: Fix Committed → Fix Released
Seyeong Kim (xtrusia) wrote :

Hello,

I verified this with test case's description.

and pkg version is below

dpkg -l | grep python-oslo.versionedobjects
ii python-oslo.versionedobjects 1.8.0-1ubuntu1~cloud0 all deals with DB schema versions and code expectations - Python 2.x

tags: added: verification-mitaka-done
removed: verification-mitaka-needed

The verification of the Stable Release Update for python-oslo.versionedobjects has completed successfully and the package has now been released to -updates. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Corey Bryant (corey.bryant) wrote :

This bug was fixed in the package python-oslo.versionedobjects - 1.8.0-1ubuntu1~cloud0
---------------

 python-oslo.versionedobjects (1.8.0-1ubuntu1~cloud0) trusty-mitaka; urgency=medium
 .
   * New update for the Ubuntu Cloud Archive.
 .
 python-oslo.versionedobjects (1.8.0-1ubuntu1) xenial; urgency=medium
 .
   * d/p/fixing-UUID-coerce-function-for-unicode-non-uuid-for.patch:
     Cherry-pick upstream patches to enable use of unicode user ID in Python2.7
     (LP: #1763179).

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

Other bug subscribers