Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode issue in utils/vt.py triggered by salt-cloud #49816

Closed
rbjorklin opened this issue Sep 28, 2018 · 3 comments
Closed

Unicode issue in utils/vt.py triggered by salt-cloud #49816

rbjorklin opened this issue Sep 28, 2018 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone

Comments

@rbjorklin
Copy link
Contributor

Description of Issue/Question

[ERROR   ] There was a query error: 'ascii' codec can't encode character u'\u2192' in position 39: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/cloud/cli.py", line 343, in run
    ret = mapper.run_map(dmap)
  File "/usr/lib/python2.7/site-packages/salt/cloud/__init__.py", line 2237, in run_map
    profile, local_master=local_master
  File "/usr/lib/python2.7/site-packages/salt/cloud/__init__.py", line 1284, in create
    output = self.clouds[func](vm_)
  File "/usr/lib/python2.7/site-packages/salt/cloud/clouds/ec2.py", line 2760, in create
    for key, value in six.iteritems(__utils__['cloud.bootstrap'](vm_, __opts__)):
  File "/usr/lib/python2.7/site-packages/salt/utils/cloud.py", line 566, in bootstrap
    deployed = deploy_script(**deploy_kwargs)
  File "/usr/lib/python2.7/site-packages/salt/utils/cloud.py", line 1547, in deploy_script
    if root_cmd(deploy_command, tty, sudo, **ssh_kwargs) != 0:
  File "/usr/lib/python2.7/site-packages/salt/utils/cloud.py", line 2248, in root_cmd
    retcode = _exec_ssh_cmd(cmd, allow_failure=allow_failure, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/utils/cloud.py", line 1809, in _exec_ssh_cmd
    stdout, stderr = proc.recv()
  File "/usr/lib/python2.7/site-packages/salt/utils/vt.py", line 310, in recv
    return self._recv(maxsize)
  File "/usr/lib/python2.7/site-packages/salt/utils/vt.py", line 688, in _recv
    self.stream_stdout.write(stdout)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2192' in position 39: ordinal not in range(128)

Steps to Reproduce Issue

salt-cloud -m <map-file> with ami-id: ami-436640a8

Suggested fix

Adding .encode('utf-8') to stdout in this line seems to fix the problem but might not be the correct way to fix this?

Versions Report

$ salt --versions-report
Salt Version:
           Salt: 2018.3.2
 
Dependency Versions:
           cffi: 1.6.0
       cherrypy: unknown
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: 0.6.4
      gitpython: 1.0.1
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.28.2
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.5 (default, Apr 11 2018, 07:36:10)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: 0.9.0
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: centos 7.5.1804 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-862.3.3.el7.x86_64
         system: Linux
        version: CentOS Linux 7.5.1804 Core
@garethgreenaway garethgreenaway added this to the Approved milestone Sep 28, 2018
@garethgreenaway garethgreenaway added Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P2 Priority 2 labels Sep 28, 2018
@garethgreenaway
Copy link
Contributor

@rbjorklin Thanks for the report. @terminalmage Does this proposed fix look good to you? If so, @rbjorklin could put in a PR with the fix.

@terminalmage
Copy link
Contributor

We would want to use salt.utils.stringutils.to_bytes(stdout) instead of manually encoding it. That way if something changes under the hood and this IS a bytestring, it doesn't fail on PY3:

>>> b'foo'.encode('utf8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'bytes' object has no attribute 'encode'

@sagetherage sagetherage removed the P2 Priority 2 label Jun 3, 2020
@twangboy
Copy link
Contributor

twangboy commented Sep 6, 2023

Closing this issue due to age and lack of activity. Please test this on version 3006.2 and create a new issue if the problem persists. The new issue template has more information and will allow us to track and reproduce the issue more effectively. Thanks!

@twangboy twangboy closed this as completed Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
Development

No branches or pull requests

5 participants