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

Fix salt-ssh state.sls_id TypeError key must be a string #48822

Merged
merged 1 commit into from Jul 30, 2018

Conversation

Projects
None yet
2 participants
@Ch3LL
Contributor

Ch3LL commented Jul 30, 2018

What does this PR do?

Currently the test integration.ssh.test_state.SSHStateTest.test_state_sls_id is failing with error:

Traceback (most recent call last):
  File "/tmp/kitchen/testing/tests/integration/ssh/test_state.py", line 65, in test_state_sls_id
    exp_ret='The file /tmp/test is set to be changed')
  File "/tmp/kitchen/testing/tests/integration/ssh/test_state.py", line 31, in _check_dict_ret
    self.assertIsInstance(ret, dict)
AssertionError: "Target 'localhost' did not return any data, probably due to an error." is not an instance of <class 'dict'>

I found out its not returning any data because of this stack trace when running salt-ssh

Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/home/ch3ll/git/salt/salt/utils/process.py", line 747, in _run
    return self._original_run()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ch3ll/git/salt/salt/client/ssh/__init__.py", line 522, in handle_routine
    stdout, stderr, retcode = single.run()
  File "/home/ch3ll/git/salt/salt/client/ssh/__init__.py", line 995, in run
    stdout, retcode = self.run_wfunc()
  File "/home/ch3ll/git/salt/salt/client/ssh/__init__.py", line 1170, in run_wfunc
    ret = salt.utils.json.dumps({'local': {'return': result}})
  File "/home/ch3ll/git/salt/salt/utils/json.py", line 145, in dumps
    return json_module.dumps(obj, **kwargs)  # future lint: blacklisted-function
  File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
TypeError: keys must be a string

This is because state.sls_id is returning bytes on 2018.3 so using decode() to convert the returned dict's keys back to strings.

What issues does this PR fix or reference?

Fixes saltstack/salt-jenkins#1043

Tests written?

Fixes a test

Commits signed with GPG?

Yes

@rallytime

Nice

@rallytime rallytime merged commit 16ca4ec into saltstack:2018.3 Jul 30, 2018

5 of 7 checks passed

jenkins/pr/py2-centos-7 running py2-centos-7...
Details
jenkins/pr/py3-centos-7 running py3-centos-7...
Details
WIP ready for review
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
jenkins/pr/lint The lint job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment