salt: 2018.3.4 TypeError: unicode argument without an encoding

Description of Issue/Question

Seems similar to other issues (#51298) involving 16 byte long strings, in our case the “master” entry on the minion has exactly 16 bytes and causes an exception.

We didn’t address this problem with prior 2018.3 branch.

Steps to Reproduce Issue

Just installed fresh Debian 9.8. minimal, installed salt-minion, run salt-call grains.items (or any other command).

[ERROR   ] An un-handled exception was caught by salt's global exception handler:
TypeError: unicode argument without an encoding
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 410, in salt_call
    client.run()
  File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 47, in run
    caller = salt.cli.caller.Caller.factory(self.config)
  File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 79, in factory
    return ZeroMQCaller(opts, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 291, in __init__
    super(ZeroMQCaller, self).__init__(opts)
  File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 102, in __init__
    self.minion = salt.minion.SMinion(opts)
  File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 806, in __init__
    lambda: self.eval_master(self.opts, failed=True)
  File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 457, in run_sync
    return future_cell[0].result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 285, in wrapper
    yielded = next(result)
  File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 694, in eval_master
    opts.update(prep_ip_port(opts))
  File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 265, in prep_ip_port
    host, port = parse_host_port(opts['master'])
  File "/usr/lib/python2.7/dist-packages/salt/utils/network.py", line 1956, in parse_host_port
    host_ip = ipaddress.ip_address(host).compressed
  File "/usr/lib/python2.7/dist-packages/salt/ext/ipaddress.py", line 115, in ip_address
    return IPv6Address(address)
  File "/usr/lib/python2.7/dist-packages/salt/_compat.py", line 175, in __init__
    elif self._is_packed_binary(address):
  File "/usr/lib/python2.7/dist-packages/salt/_compat.py", line 194, in _is_packed_binary
    packed = bool(int(str(bytearray(data)).encode('hex'), 16))
TypeError: unicode argument without an encoding
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 410, in salt_call
    client.run()
  File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 47, in run
    caller = salt.cli.caller.Caller.factory(self.config)
  File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 79, in factory
    return ZeroMQCaller(opts, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 291, in __init__
    super(ZeroMQCaller, self).__init__(opts)
  File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 102, in __init__
    self.minion = salt.minion.SMinion(opts)
  File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 806, in __init__
    lambda: self.eval_master(self.opts, failed=True)
  File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 457, in run_sync
    return future_cell[0].result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 285, in wrapper
    yielded = next(result)
  File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 694, in eval_master
    opts.update(prep_ip_port(opts))
  File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 265, in prep_ip_port
    host, port = parse_host_port(opts['master'])
  File "/usr/lib/python2.7/dist-packages/salt/utils/network.py", line 1956, in parse_host_port
    host_ip = ipaddress.ip_address(host).compressed
  File "/usr/lib/python2.7/dist-packages/salt/ext/ipaddress.py", line 115, in ip_address
    return IPv6Address(address)
  File "/usr/lib/python2.7/dist-packages/salt/_compat.py", line 175, in __init__
    elif self._is_packed_binary(address):
  File "/usr/lib/python2.7/dist-packages/salt/_compat.py", line 194, in _is_packed_binary
    packed = bool(int(str(bytearray(data)).encode('hex'), 16))
TypeError: unicode argument without an encoding

Versions Report

2018.3.4+ds-1

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 22 (9 by maintainers)

Most upvoted comments

In case anyone comes here looking for answers, the fix is not in 2018.3.5.

@Ch3LL I applied the changes in PR #51931 to a couple of my 2018.3.4 minions and everything seemed to work just fine! 👍

I have exactly the same issue with pure saltstack 2018.3.4 installation on ubuntu 18.04 with python3 (previously it was working perfectly).

@Ch3LL I can confirmed that https://github.com/saltstack/salt/pull/51298 is working and fixing this issue (I manually applied this patch).