Unicode decode error when giving deprecation warning in sqlite3 ext_pillar
Description of Issue/Question
Unicode decide error when trying to give deprecation warning in sqlite3 ext_pillar
The sqlite3 pillar looks for __opts__['sqlite3']['database'] and issues a deprecation warning if it instead finds __opts__['pillar.sqlite3.database']
Stack trace:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/pillar/__init__.py", line 773, in ext_pillar
key)
File "/usr/lib/python2.7/site-packages/salt/pillar/__init__.py", line 713, in _external_pillar_data
ext = self.ext_pillars[key](self.minion_id, pillar, **val)
File "/usr/lib/python2.7/site-packages/salt/pillar/sqlite3.py", line 145, in ext_pillar
return SQLite3ExtPillar().fetch(minion_id, pillar, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/pillar/sql_base.py", line 434, in fetch
with self._get_cursor() as cursor:
File "/usr/lib64/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/lib/python2.7/site-packages/salt/pillar/sqlite3.py", line 126, in _get_cursor
_options = self._get_options()
File "/usr/lib/python2.7/site-packages/salt/pillar/sqlite3.py", line 103, in _get_options
'Configurations under the pillar key are deprecated.'
File "/usr/lib/python2.7/site-packages/salt/utils/__init__.py", line 2208, in warn_until
stacklevel=stacklevel
File "/usr/lib64/python2.7/logging/__init__.py", line 1710, in _showwarning
logger.warning("%s", s)
File "/usr/lib64/python2.7/logging/__init__.py", line 1161, in warning
self._log(WARNING, msg, args, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/log/setup.py", line 310, in _log
self, level, msg, args, exc_info=exc_info, extra=extra
File "/usr/lib64/python2.7/logging/__init__.py", line 1267, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/usr/lib/python2.7/site-packages/salt/log/setup.py", line 344, in makeRecord
exc_info, func)
File "/usr/lib/python2.7/site-packages/salt/log/setup.py", line 191, in __init__
self.colormsg = '%s%s%s' % (cmsg, self.getMessage(), reset)
File "/usr/lib64/python2.7/logging/__init__.py", line 328, in getMessage
msg = msg % self.args
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 228: ordinal not in range(128)
Setup
Add the following line to master config: pillar.sqlite3.database: /path/to/my/sqlite.db (The db doesn't actaully have to exist)
Steps to Reproduce Issue
run salt '*' pillar.items
It returns this in _errors:
- Failed to load ext_pillar sqlite3: 'ascii' codec can't decode byte 0xc2 in position 228: ordinal not in range(128)
Versions Report
Salt Version:
Salt: 2016.3.1
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.21.1
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.7
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.5 (default, Nov 20 2015, 02:00:19)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.7.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: centos 7.2.1511 Core
machine: x86_64
release: 3.10.0-327.el7.x86_64
system: Linux
version: CentOS Linux 7.2.1511 Core
@colinjkevans Does the unicode error go away if you change the master config to use the sqlite3.database syntax instead of the pillar.sqlite3.database syntax? I think that is what you're implying, but I wasn't able to reproduce your issue by setting the old syntax. This indicates to me that something deeper is going on with something in your pillar files that needs to be addressed instead.
I changed:
pillar.sqlite3.database: /var/lib/salt/pillar.db
pillar.sqlite3.timeout: 5.0
to
sqlite3:
database: /var/lib/salt/pillar.db
timeout: 5.0
then restarted salt-master, and it works. Switch back to the former syntax and it gives the unicode error again.
Ok thanks for confirming. I will try to reproduce this again. @Ch3LL Have you seen this before?
Confirming. Getting the same error.
https://github.com/saltstack/salt/issues/42278 salt logging with plain str (ascii) with unicode chars causes UnicodeDecodeError PY2
Contains a workaround
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.