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

[BUG] TypeError in utils.network._openbsd_remotes_on #61966

Closed
lkubb opened this issue Apr 19, 2022 · 0 comments · Fixed by #62649
Closed

[BUG] TypeError in utils.network._openbsd_remotes_on #61966

lkubb opened this issue Apr 19, 2022 · 0 comments · Fixed by #62649
Labels
Bug broken, incorrect, or confusing behavior bytes-vs-strings py2 vs py3 bytes vs strings encode/decode errors OpenBSD severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone

Comments

@lkubb
Copy link
Contributor

lkubb commented Apr 19, 2022

Description
When issuing a command to an unavailable minion, an exception is thrown after some time.

Setup
Salt master on OpenBSD

Steps to Reproduce the behavior

  • have salt master on OpenBSD
  • have minion that is down
  • run salt 'minion' test.ping

Expected behavior
Timeout.

Screenshots

# salt 'minion' test.ping
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
TypeError: a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "/usr/local/bin/salt", line 8, in <module>
    sys.exit(salt_main())
  File "/usr/local/lib/python3.8/site-packages/salt/scripts.py", line 521, in salt_main
    client.run()
  File "/usr/local/lib/python3.8/site-packages/salt/cli/salt.py", line 200, in run
    for full_ret in cmd_func(**kwargs):
  File "/usr/local/lib/python3.8/site-packages/salt/client/__init__.py", line 833, in cmd_cli
    for fn_ret in self.get_cli_event_returns(
  File "/usr/local/lib/python3.8/site-packages/salt/client/__init__.py", line 1672, in get_cli_event_returns
    connected_minions = salt.utils.minions.CkMinions(
  File "/usr/local/lib/python3.8/site-packages/salt/utils/minions.py", line 636, in connected_ids
    addrs = salt.utils.network.local_port_tcp(int(self.opts["publish_port"]))
  File "/usr/local/lib/python3.8/site-packages/salt/utils/network.py", line 1610, in local_port_tcp
    ret = _remotes_on(port, "local_port")
  File "/usr/local/lib/python3.8/site-packages/salt/utils/network.py", line 1658, in _remotes_on
    return _openbsd_remotes_on(port, which_end)
  File "/usr/local/lib/python3.8/site-packages/salt/utils/network.py", line 1917, in _openbsd_remotes_on
    lines = data.split("\n")

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3004.1

Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: 2.0.5
     gitpython: 2.1.9
        Jinja2: 2.11.3
       libgit2: Not Installed
      M2Crypto: 0.38.0
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: 3.10.1
  pycryptodome: 3.14.1
        pygit2: Not Installed
        Python: 3.8.12 (default, Sep 26 2021, 13:12:50)
  python-gnupg: Not Installed
        PyYAML: 5.3.1
         PyZMQ: 18.0.1
         smmap: 2.0.3
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: openbsd 7.0
        locale: utf-8
       machine: amd64
       release: 7.0
        system: OpenBSD
       version: OpenBSD 7.0

Additional context
The infringing code is found here. subprocess.check_output returns data as bytes by default, so the code should read lines = data.split(b"\n") (edit: actually would need to decode the data first to avoid issues further down or take that into account there as well).

Of course, this is not a breaking issue, more for the record. Thanks for your work on Salt!

@lkubb lkubb added Bug broken, incorrect, or confusing behavior needs-triage labels Apr 19, 2022
@OrangeDog OrangeDog added OpenBSD severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around bytes-vs-strings py2 vs py3 bytes vs strings encode/decode errors and removed needs-triage labels Apr 19, 2022
@OrangeDog OrangeDog added this to the Approved milestone Apr 19, 2022
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 bytes-vs-strings py2 vs py3 bytes vs strings encode/decode errors OpenBSD severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants