Closed breshead closed 5 years ago
ping @terminalmage any ideas here looks like you made this change here: c65d4714e52
So I dug in to the suspect area and turned the one line of stacked commands into several to figure out exactly what is going on..
It became obvious that we are "Double encoding" a string value but I have no idea why we should do such a thing.
Removing the second six.text_type() encode (And renaming tmpRET as needed) seemed to fix the issue.
Can anybody shed some more light on this as to what direction to go. Is it really that simple (don't need the double encode) or is there something deeper that I am not seeing?
# This is the original line, expanded below..
235 #job_ret = {'return': six.text_type(six.text_type(load['return']), 'utf-8', 'replace')}
236
237 # Encode to unicode from ascii type
238 tmpRET = six.text_type(load['return'])
239
240 # Encode already encoded tmpRet from utf-8, replacing errors with 'U+FFFD'
241 tmpRET2 = six.text_type(tmpRET, 'utf-8', 'replace')
242 # So six.text_type gets sent to 'unicode()' in python 2 which only
243 # supports 8-bit strings as input, tmpRET is a 16 or 32 bit string
244 # which is why it is puking.
245 # Why are we "Double Encoding" this load['return'] value?
246
247
248 # Return the encoded/decoded string..
249 job_ret = {'return': tmpRET2}
New Error
File "/usr/lib/python2.7/dist-packages/salt/returners/postgres_local_cache.py", line 241, in returner
tmpRET2 = six.text_type(tmpRET, 'utf-8', 'replace')
TypeError: decoding Unicode is not supported
This puts the error on the second level of encoding, which makes sense. Again removing that second level makes the error go away and the salt-run.* begins working again.
ping @saltstack/team-core any thoughts here? Should we be using salt.utils.stringutils.to_str()
in this instance? or just removing the double encoding?
ping @breshead would you mind pushing up as PR and we will get more eyes on this proposed fix.
I'll get on it as soon as I can.
Pull request created.
Updated pull request for issues raised by terminalmage. Not sure if this is a new request or updated.
Removed the duplicate pull request and updated the current one with the changes.
Description of Issue/Question
When the master job cache is setup using postgres, calling salt-run will throw a 'TypeError' in the postgres_local_cache.py module.
My use case is
salt-run manage.[not_]present
but I triedTo see if it was specific or not. It appears to be all runners.
When I disable the master job cache (remark out in the config file), the salt runner completes successfully.
Setup
/etc/salt/master.d/master_job_cache.conf
Steps to Reproduce Issue
With master job cache setup.. On the command salt-master CLI run..
~# salt-run manage.list_state ---- RESULT ----
----- RESULTS master job cache disabled ----
--------- END RESULTS -----
Versions Report