Bug 1910416 - Stack update reports failure even though everything is o.k. due to encoding issue - UnicodeEncodeError: 'latin-1' codec can't encode character '\u2192' in position 1702: ordinal not in range(256)
Summary: Stack update reports failure even though everything is o.k. due to encoding i...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: python-tripleoclient
Version: 16.1 (Train)
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: ---
Assignee: RHOS Maint
QA Contact: David Rosenfeld
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-12-23 19:43 UTC by Andreas Karis
Modified: 2023-01-12 05:13 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-02-17 16:07:10 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker OSP-1426 0 None None None 2022-03-11 01:15:10 UTC

Description Andreas Karis 2020-12-23 19:43:00 UTC
Description of problem:

Stack update reports failure even though everything is o.k. due to encoding issue:
~~~
WAITING FOR COMPLETION: Wait for containers to start for step 4 using paunch (1178 retries left).
WAITING FOR COMPLETION: Wait for containers to start for step 4 using paunch (1178 retries left).
WAITING FOR COMPLETION: Wait for containers to start for step 4 using paunch (1177 retries left).
WAITING FOR COMPLETION: Wait for containers to start for step 4 using paunch (1177 retries left).
WAITING FOR COMPLETION: Wait for containers to start for step 4 using paunch (1177 retries left).
WAITING FOR COMPLETION: Wait for containers to start for step 4 using paunch (1176 retries left).

Overcloud Endpoint: http://172.16.0.126:5000
Overcloud Horizon Dashboard URL: http://172.16.0.126:80/dashboard
Overcloud rc file: /home/stack/overcloudrc
Overcloud Deployed with error
Exception occured while running the command
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/tripleoclient/command.py", line 32, in run
    super(Command, self).run(parsed_args)
  File "/usr/lib/python3.6/site-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/usr/lib/python3.6/site-packages/cliff/command.py", line 185, in run
    return_code = self.take_action(parsed_args) or 0
  File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 1100, in take_action
    raise(deploy_trace)
  File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 1072, in take_action
    limit_nodes=parsed_args.limit
  File "/usr/lib/python3.6/site-packages/tripleoclient/workflows/deployment.py", line 398, in config_download
    print(payload['message'])
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2192' in position 1702: ordinal not in range(256)
'latin-1' codec can't encode character '\u2192' in position 1702: ordinal not in range(256)
(undercloud) [stack@undercloud-0 ~]$ 
(undercloud) [stack@undercloud-0 ~]$ heat stack-list
WARNING (shell) "heat stack-list" is deprecated, please use "openstack stack list" instead
/usr/lib/python3.6/site-packages/urllib3/connection.py:362: SubjectAltNameWarning: Certificate for 192.168.24.2 has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
  SubjectAltNameWarning
/usr/lib/python3.6/site-packages/urllib3/connection.py:362: SubjectAltNameWarning: Certificate for 192.168.24.2 has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
  SubjectAltNameWarning
+--------------------------------------+------------+-----------------+----------------------+----------------------+----------------------------------+
| id                                   | stack_name | stack_status    | creation_time        | updated_time         | project                          |
+--------------------------------------+------------+-----------------+----------------------+----------------------+----------------------------------+
| 4f06e0d3-cee6-4801-80f0-a347db31f86d | overcloud  | UPDATE_COMPLETE | 2020-12-23T16:34:33Z | 2020-12-23T19:09:29Z | 2bb86ef4ebe14ea48de5fac8f2f319f0 |
+--------------------------------------+------------+-----------------+----------------------+----------------------+----------------------------------+
~~~


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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

/usr/lib/python3.6/site-packages/tripleoclient/workflows/deployment.py
(...)
358         'tags': tags,
359         'limit_hosts': utils.playbook_limit_parse(limit_hosts)
360     }
361     if output_dir:
362         workflow_input.update(dict(work_dir=output_dir))
363     if override_ansible_cfg:
364         with open(override_ansible_cfg) as cfg:
365             override_ansible_cfg_contents = cfg.read()
366         workflow_input.update(
367             dict(override_ansible_cfg=override_ansible_cfg_contents))
368 
369     workflow_name = 'tripleo.deployment.v1.config_download_deploy'
370 
371     # Check to see if any existing executions for the same stack are already in
372     # progress.
373     log.info("Checking for existing executions of config_download for "
374              "%s" % stack.stack_name)
375     for execution in workflow_client.executions.find(
376             workflow_name=workflow_name,
377             state='RUNNING'):
378 
379         try:
380             exec_input = yaml.safe_load(execution.input)
381         except yaml.YAMLError as ye:
382             log.error("YAML error loading input for execution %s: %s" %
383                       (execution.id, str(ye)))
384             raise
385 
386         if exec_input.get('plan_name', 'overcloud') == stack.stack_name:
387             raise exceptions.ConfigDownloadInProgress(execution.id,
388                                                       stack.stack_name)
389 
390     with tripleoclients.messaging_websocket() as ws:
391         execution = base.start_workflow(
392             workflow_client,
393             workflow_name,
394             workflow_input=workflow_input
395         )
396 
397         for payload in base.wait_for_messages(workflow_client, ws, execution):
398             print(payload['message'])
399 
400     if payload['status'] == 'SUCCESS':
401         print("Overcloud configuration completed.")
402     else:
403         raise exceptions.DeploymentError("Overcloud configuration failed.")
404

Comment 1 Alex Schultz 2021-01-27 22:36:23 UTC
This issue stems from the use of LC_CTYPE=latin-1 instead of a utf8 lang time (e.g. en_US.UTF-8).

$ LC_CTYPE=latin-1 python3
Python 3.6.8 (default, Oct  8 2019, 16:29:04) 
[GCC 8.2.1 20180905 (Red Hat 8.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> s = "\u2192"
>>> print(s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character '\u2192' in position 0: ordinal not in range(128)
>>>


LC_CTYPE=en_US.UTF-8 python3
Python 3.6.8 (default, Oct  8 2019, 16:29:04) 
[GCC 8.2.1 20180905 (Red Hat 8.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> s = "\u2192"
>>> print(s)>>>


This will likely lead to other failures in system output. I would recommend ensuring the host system is configured to use UTF-8 rather than latin-1.

Comment 4 Alex Schultz 2021-03-02 21:46:57 UTC
For the record if you use en_US and not en_US.UTF-8, you can also get this error.

[root@undercloud ~]# localectl
   System Locale: LANG=en_US
       VC Keymap: n/a
      X11 Layout: n/a



Should be
 [root@undercloud ~]# localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: n/a


Note You need to log in before you can comment on or make changes to this bug.