Bug 1599967
| Summary: | glance-manage db_sync failed due to UnicodeEncodeError | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Red Hat OpenStack | Reporter: | Chen <cchen> | ||||
| Component: | puppet-openstacklib | Assignee: | OSP Team <rhos-maint> | ||||
| Status: | CLOSED EOL | QA Contact: | Nobody <nobody> | ||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | medium | ||||||
| Version: | 13.0 (Queens) | CC: | cchen, cyril, eglynn, jjoyce, jschluet, mvalsecc, mzheng, pdeore, pgrist, slinaber, srevivo, tvignaud | ||||
| Target Milestone: | --- | Keywords: | Triaged, ZStream | ||||
| Target Release: | --- | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2023-07-10 19:37:47 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: | |||||||
| Attachments: |
|
||||||
Could you tell me to what values the following environment variables are set? LANG, LC_ALL, LC_TYPES... Giving us the output of "env" would probably be helpful :)
How is "glance manage" run? Manually, through a script, by cron?
Is the output redirected?
2018-07-10 10:18:59.774 12330 ERROR glance print(_('Database is up to date. No migrations needed.'))
Is this string translated? If so, to what?
Created attachment 1458621 [details]
env output on director node
OK, so I talked to Victor Stinner who knows the whole Python/UTF8 quite well and I ran some tests:
$ LANG=ja_JP.utf8 glance-manage db_sync
/usr/local/lib/python3.5/dist-packages/oslo_db/sqlalchemy/enginefacade.py:1334: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo_de
expire_on_commit=expire_on_commit, _conf=conf)
DEBUG oslo_db.sqlalchemy.engines [-] MySQL server mode set to STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_}
INFO alembic.runtime.migration [-] Context impl MySQLImpl.
INFO alembic.runtime.migration [-] Will assume non-transactional DDL.
データベースは最新です。移行は必要ありません。
$ LANG=ja_JP.utf8 glance-manage db_sync | less
DEBUG oslo_db.sqlalchemy.engines [-] MySQL server mode set to STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION {{(pid=5457) _check_effective_sql_mode /usr/local/lib/python2.7/dist-packages/oslo_db/sqlalchemy/engines.py:308}}
INFO alembic.runtime.migration [-] Context impl MySQLImpl.
INFO alembic.runtime.migration [-] Will assume non-transactional DDL.
CRITICAL glance [-] Unhandled error: UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-22: ordinal not in range(128)
ERROR glance Traceback (most recent call last):
ERROR glance File "/usr/local/bin/glance-manage", line 10, in <module>
ERROR glance sys.exit(main())
ERROR glance File "/opt/stack/glance/glance/cmd/manage.py", line 551, in main
ERROR glance return CONF.command.action_fn()
ERROR glance File "/opt/stack/glance/glance/cmd/manage.py", line 383, in sync
ERROR glance self.command_object.sync(CONF.command.version)
ERROR glance File "/opt/stack/glance/glance/cmd/manage.py", line 159, in sync
ERROR glance print(_('Database is up to date. No migrations needed.'))
ERROR glance UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-22: ordinal not in range(128)
ERROR glance
The redirection is the issue. In your case, I believe the way ooo/puppet calls "glance-manage db_sync" causes a similar issue. So, two things we could try:
1) Change the way "glance-manage db_sync" is called
2) Fix the issue in Glance (not sure how to do that)
Note that with Python 3, this bug just disappears, because Python 3 is just that much better than Python 2.
@Pranali: does the above make sense to you? Do you know how ooo/puppet calls Glance?
@Chen: I think the issue is not limited to Glance, though. You could try to remove glance.mo (that would avoid translating the Glance strings), and you'd probably get a failure later on. For instance, cinder-manage has the same kind of issue:
$ LANG=ja_JP.utf8 cinder-manage |less
Traceback (most recent call last):
File "/usr/local/bin/cinder-manage", line 10, in <module>
sys.exit(main())
File "/opt/stack/cinder/cinder/cmd/manage.py", line 813, in main
{'version': version.version_string()})
UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-22: ordinal not in range(128)
This seems like a tricky issue. The short-term workaround is to work without this $LANG, but that's quite inconvenient :/
Apparently it was fixed in puppet-openstacklib. I'm retargeting this bug. Can we backport https://review.opendev.org/#/c/640997/ ? OSP13 support officially ended on 27 June 2023 |
Description of problem: glance-manage db_sync failed due to UnicodeEncodeError: 2018-07-10 10:18:59.758 12330 DEBUG oslo_db.sqlalchemy.engines [-] MySQL server mode set to STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION _check_effective_sql_mode /usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/engines.py:290 2018-07-10 10:18:59.762 12330 INFO alembic.runtime.migration [-] Context impl MySQLImpl. 2018-07-10 10:18:59.762 12330 INFO alembic.runtime.migration [-] Will assume non-transactional DDL. 2018-07-10 10:18:59.774 12330 CRITICAL glance [-] Unhandled error: UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-22: ordinal not in range(128) 2018-07-10 10:18:59.774 12330 ERROR glance Traceback (most recent call last): 2018-07-10 10:18:59.774 12330 ERROR glance File "/usr/bin/glance-manage", line 10, in <module> 2018-07-10 10:18:59.774 12330 ERROR glance sys.exit(main()) 2018-07-10 10:18:59.774 12330 ERROR glance File "/usr/lib/python2.7/site-packages/glance/cmd/manage.py", line 551, in main 2018-07-10 10:18:59.774 12330 ERROR glance return CONF.command.action_fn() 2018-07-10 10:18:59.774 12330 ERROR glance File "/usr/lib/python2.7/site-packages/glance/cmd/manage.py", line 383, in sync 2018-07-10 10:18:59.774 12330 ERROR glance self.command_object.sync(CONF.command.version) 2018-07-10 10:18:59.774 12330 ERROR glance File "/usr/lib/python2.7/site-packages/glance/cmd/manage.py", line 159, in sync 2018-07-10 10:18:59.774 12330 ERROR glance print(_('Database is up to date. No migrations needed.')) 2018-07-10 10:18:59.774 12330 ERROR glance UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-22: ordinal not in range(128) 2018-07-10 10:18:59.774 12330 ERROR glance Version-Release number of selected component (if applicable): OSP13 undercloud How reproducible: 100% at customer's site Steps to Reproduce: 1. openstack undercloud install 2. 3. Actual results: The undercloud installation would fail and glance/api.log will output those error messages Expected results: Additional info: