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

python3: broken pillar cache: yaml: TypeError: a bytes-like object is required, not 'str' #53943

Closed
disaster123 opened this issue Jul 22, 2019 · 13 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix P2 Priority 2 Regression The issue is a bug that breaks functionality known to work in previous releases. severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around v3000.1 vulnerable version
Milestone

Comments

@disaster123
Copy link

disaster123 commented Jul 22, 2019

Description of Issue

Since Upgrading from 2017.7 py2 to 2019.2 py3 i can't issue any salt-call - not even test.ping

All result in:

TypeError: a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/lib/python3/dist-packages/salt/scripts.py", line 431, in salt_call
    client.run()
  File "/usr/lib/python3/dist-packages/salt/cli/call.py", line 47, in run
    caller = salt.cli.caller.Caller.factory(self.config)
  File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 80, in factory
    return ZeroMQCaller(opts, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 332, in __init__
    super(ZeroMQCaller, self).__init__(opts)
  File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 106, in __init__
    self.minion = salt.minion.SMinion(opts)
  File "/usr/lib/python3/dist-packages/salt/minion.py", line 822, in __init__
    salt.utils.yaml.safe_dump(cache_top, fp_)
  File "/usr/lib/python3/dist-packages/salt/utils/yamldumper.py", line 129, in safe_dump
    return yaml.dump(data, stream, Dumper=SafeOrderedDumper, **kwargs)
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 200, in dump
    return dump_all([data], stream, Dumper=Dumper, **kwds)
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 188, in dump_all
    dumper.represent(data)
  File "/usr/lib/python3/dist-packages/yaml/representer.py", line 27, in represent
    self.serialize(node)
  File "ext/_yaml.pyx", line 1350, in _yaml.CEmitter.serialize (ext/_yaml.c:18773)
  File "ext/_yaml.pyx", line 1525, in _yaml.output_handler (ext/_yaml.c:21549)
TypeError: a bytes-like object is required, not 'str'

Steps to Reproduce Issue

just call salt-call test.ping

Versions Report

salt-call --versions-report

Salt Version:
Salt: 2019.2.0

Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.5.3
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.9.4
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.5.3 (default, Sep 27 2018, 17:25:39)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 16.0.2
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.4.3
ZMQ: 4.2.1

System Versions:
dist: debian 9.9
locale: UTF-8
machine: x86_64
release: 4.19.45+26-ph
system: Linux
version: debian 9.9

@disaster123
Copy link
Author

I'm able to fix / workaround this by replacing:

821 with salt.utils.files.fopen(ptop, 'wb') as fp_:
with
821 with salt.utils.files.fopen(ptop, 'w') as fp_:

and
825 with salt.utils.files.fopen(cache_sls, 'wb') as fp_:
with
825 with salt.utils.files.fopen(cache_sls, 'w') as fp_:

in minion.py

@disaster123 disaster123 changed the title yaml: TypeError: a bytes-like object is required, not 'str' python3: broken salt cache: yaml: TypeError: a bytes-like object is required, not 'str' Jul 22, 2019
@disaster123 disaster123 changed the title python3: broken salt cache: yaml: TypeError: a bytes-like object is required, not 'str' python3: broken pillar cache: yaml: TypeError: a bytes-like object is required, not 'str' Jul 23, 2019
@disaster123
Copy link
Author

this one needs: minion_pillar_cache: True

@dwoz
Copy link
Contributor

dwoz commented Jul 29, 2019

@disaster123 Does the minion run fine under python 3 if you remove the cache file?

@dwoz dwoz added the info-needed waiting for more info label Jul 29, 2019
@dwoz dwoz added this to the Blocked milestone Jul 29, 2019
@disaster123
Copy link
Author

No

@dwoz dwoz added Bug broken, incorrect, or confusing behavior and removed info-needed waiting for more info labels Jul 29, 2019
@dwoz
Copy link
Contributor

dwoz commented Jul 29, 2019

@disaster123 Thanks, I've confirmed this is an issue.

>>> a
'abcdé'
>>> with open('test', 'wb') as fp:
...     salt.utils.yaml.safe_dump(a, fp)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/home/dwoz/src/salt-forge/neon-tests/salt/salt/utils/yamldumper.py", line 138, in safe_dump
    return yaml.dump(data, stream, Dumper=SafeOrderedDumper, **kwargs)
  File "/home/dwoz/src/salt-forge/neon-tests/venv3/lib/python3.5/site-packages/yaml/__init__.py", line 200, in dump
    return dump_all([data], stream, Dumper=Dumper, **kwds)
  File "/home/dwoz/src/salt-forge/neon-tests/venv3/lib/python3.5/site-packages/yaml/__init__.py", line 188, in dump_all
    dumper.represent(data)
  File "/home/dwoz/src/salt-forge/neon-tests/venv3/lib/python3.5/site-packages/yaml/representer.py", line 27, in represent
    self.serialize(node)
  File "/home/dwoz/src/salt-forge/neon-tests/venv3/lib/python3.5/site-packages/yaml/serializer.py", line 54, in serialize
    self.serialize_node(node, None, None)
  File "/home/dwoz/src/salt-forge/neon-tests/venv3/lib/python3.5/site-packages/yaml/serializer.py", line 90, in serialize_node
    style=node.style))
  File "/home/dwoz/src/salt-forge/neon-tests/venv3/lib/python3.5/site-packages/yaml/emitter.py", line 115, in emit
    self.state()
  File "/home/dwoz/src/salt-forge/neon-tests/venv3/lib/python3.5/site-packages/yaml/emitter.py", line 228, in expect_document_root
    self.expect_node(root=True)
  File "/home/dwoz/src/salt-forge/neon-tests/venv3/lib/python3.5/site-packages/yaml/emitter.py", line 244, in expect_node
    self.expect_scalar()
  File "/home/dwoz/src/salt-forge/neon-tests/venv3/lib/python3.5/site-packages/yaml/emitter.py", line 268, in expect_scalar
    self.process_scalar()
  File "/home/dwoz/src/salt-forge/neon-tests/venv3/lib/python3.5/site-packages/yaml/emitter.py", line 533, in process_scalar
    self.write_plain(self.analysis.scalar, split)
  File "/home/dwoz/src/salt-forge/neon-tests/venv3/lib/python3.5/site-packages/yaml/emitter.py", line 1131, in write_plain
    self.stream.write(data)
TypeError: a bytes-like object is required, not 'str'

@dwoz dwoz modified the milestones: Blocked, Approved Jul 29, 2019
@dwoz
Copy link
Contributor

dwoz commented Jul 29, 2019

@disaster123 Does the minion run fine without this.

@dwoz dwoz added severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P2 Priority 2 labels Jul 29, 2019
@disaster123
Copy link
Author

with my patch it runs fine - yes

@disaster123
Copy link
Author

can this please be get fixed for 2019.2.1 ?

@disaster123
Copy link
Author

Why is this still unfixed in 2019.2.2?

@sagetherage sagetherage added the Regression The issue is a bug that breaks functionality known to work in previous releases. label Jan 24, 2020
@disaster123
Copy link
Author

@sagetherage salt 2019 is unusable without a fix - why is this a todo in sodium?

@sagetherage
Copy link
Contributor

That is the project of work, and is in "Considering" as I need to have a planning session with the team to understand deeper how, when, what, etc. to get this fixed, not to state that it will be only fixed in Sodium or Master, sorry for the confusion. It is my attempt to move it along.

@disaster123
Copy link
Author

ah ok thx

@twangboy
Copy link
Contributor

twangboy commented May 7, 2020

Looks like this was fixed in #56143. It was part of the 3000.1 release. Could you verify with 3000.2 please?

@twangboy twangboy added the fixed-pls-verify fix is linked, bug author to confirm fix label May 7, 2020
@sagetherage sagetherage added v3000.1 vulnerable version and removed ZRelease-Sodium retired label labels May 22, 2020
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 fixed-pls-verify fix is linked, bug author to confirm fix P2 Priority 2 Regression The issue is a bug that breaks functionality known to work in previous releases. severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around v3000.1 vulnerable version
Projects
None yet
Development

No branches or pull requests

4 participants